Часовой пояс: UTC + 3 часа




Начать новую тему Новая тема / Ответить на тему Ответить  1 сообщение 
  Пред. тема | След. тема 
В случае проблем с отображением форума, отключите блокировщик рекламы
Автор Сообщение
 

Junior
Статус: Не в сети
Регистрация: 22.02.2008
Откуда: Одесса
Qt как сделать slider который меняет значение переменной от min=0 до max=4880

написал маленькую програмку для изменения яркости подсветки дисплея и клавиатуры
двадцать лет ничего не писал :bandhead:
для програмиста это займет несколько минут и не составит большого труда 8-)

всё работает как на рис1, но яркость меняется дискретно

а хотелось бы чтобы менялась плавно слайдером, как на рис2
для дисплея $lcd мин 0 макс 4880
system("echo $lcd >> /sys/class/backlight/intel_backlight/brightness");

для клавиатуры $kbd от 0 до 3
system("echo $kbd >> /sys/devices/platform/asus-nb-wmi/leds/asus\:\:kbd_backlight/brightness");

рис1 #77
рис2 #77

mainwindow.h
Код:
#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT
   
public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();
   
private slots:
    void on_pushButton_clicked();

    void on_pushButton_2_clicked();

    void on_pushButton_3_clicked();

    void on_pushButton_4_clicked();

    void on_pushButton_5_clicked();

    void on_pushButton_6_clicked();

    void on_pushButton_7_clicked();

    void on_pushButton_8_clicked();

    void on_pushButton_9_clicked();

    void on_pushButton_10_clicked();

    void on_pushButton_11_clicked();

    void on_pushButton_12_clicked();

    void on_pushButton_13_clicked();

    void on_pushButton_14_clicked();

    void on_pushButton_15_clicked();

private:
    Ui::MainWindow *ui;
};

#endif // MAINWINDOW_H


main.cpp
Код:
#include "mainwindow.h"
#include <QApplication>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    MainWindow w;
    w.show();
   
    return a.exec();
}


mainwindow.cpp
Код:
#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
}

MainWindow::~MainWindow()
{
    delete ui;
}


void MainWindow::on_pushButton_clicked()
{
    system("echo 488 >> /sys/class/backlight/intel_backlight/brightness");
}

void MainWindow::on_pushButton_2_clicked()
{
    system("echo 976 >> /sys/class/backlight/intel_backlight/brightness");
}

void MainWindow::on_pushButton_3_clicked()
{
    system("echo 1464 >> /sys/class/backlight/intel_backlight/brightness");
}

void MainWindow::on_pushButton_4_clicked()
{
    system("echo 1952 >> /sys/class/backlight/intel_backlight/brightness");
}

void MainWindow::on_pushButton_5_clicked()
{
    system("echo 2440 >> /sys/class/backlight/intel_backlight/brightness");
}

void MainWindow::on_pushButton_6_clicked()
{
    system("echo 2928 >> /sys/class/backlight/intel_backlight/brightness");
}

void MainWindow::on_pushButton_7_clicked()
{
    system("echo 3416 >> /sys/class/backlight/intel_backlight/brightness");
}

void MainWindow::on_pushButton_8_clicked()
{
    system("echo 3904 >> /sys/class/backlight/intel_backlight/brightness");
}

void MainWindow::on_pushButton_9_clicked()
{
    system("echo 4392 >> /sys/class/backlight/intel_backlight/brightness");
}

void MainWindow::on_pushButton_10_clicked()
{
    system("echo 4880 >> /sys/class/backlight/intel_backlight/brightness");
}

void MainWindow::on_pushButton_11_clicked()
{
    system("echo 0 >> /sys/devices/platform/asus-nb-wmi/leds/asus\:\:kbd_backlight/brightness");
}

void MainWindow::on_pushButton_12_clicked()
{
    system("echo 1 >> /sys/devices/platform/asus-nb-wmi/leds/asus\:\:kbd_backlight/brightness");
}

void MainWindow::on_pushButton_13_clicked()
{
    system("echo 2 >> /sys/devices/platform/asus-nb-wmi/leds/asus\:\:kbd_backlight/brightness");
}

void MainWindow::on_pushButton_14_clicked()
{
    system("echo 3 >> /sys/devices/platform/asus-nb-wmi/leds/asus\:\:kbd_backlight/brightness");
}

void MainWindow::on_pushButton_15_clicked()
{
    system("echo 122 >> /sys/class/backlight/intel_backlight/brightness");
}


mainwindow.ui
Код:
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
 <class>MainWindow</class>
 <widget class="QMainWindow" name="MainWindow">
  <property name="geometry">
   <rect>
    <x>0</x>
    <y>0</y>
    <width>89</width>
    <height>398</height>
   </rect>
  </property>
  <property name="windowTitle">
   <string>MainWindow</string>
  </property>
  <widget class="QWidget" name="centralWidget">
   <widget class="QPushButton" name="pushButton">
    <property name="geometry">
     <rect>
      <x>10</x>
      <y>40</y>
      <width>31</width>
      <height>27</height>
     </rect>
    </property>
    <property name="text">
     <string>01</string>
    </property>
   </widget>
   <widget class="QPushButton" name="pushButton_2">
    <property name="geometry">
     <rect>
      <x>10</x>
      <y>70</y>
      <width>31</width>
      <height>27</height>
     </rect>
    </property>
    <property name="text">
     <string>02</string>
    </property>
   </widget>
   <widget class="QPushButton" name="pushButton_3">
    <property name="geometry">
     <rect>
      <x>10</x>
      <y>100</y>
      <width>31</width>
      <height>27</height>
     </rect>
    </property>
    <property name="text">
     <string>03</string>
    </property>
   </widget>
   <widget class="QPushButton" name="pushButton_4">
    <property name="geometry">
     <rect>
      <x>10</x>
      <y>130</y>
      <width>31</width>
      <height>27</height>
     </rect>
    </property>
    <property name="text">
     <string>04</string>
    </property>
   </widget>
   <widget class="QPushButton" name="pushButton_5">
    <property name="geometry">
     <rect>
      <x>10</x>
      <y>160</y>
      <width>31</width>
      <height>27</height>
     </rect>
    </property>
    <property name="text">
     <string>05</string>
    </property>
   </widget>
   <widget class="QPushButton" name="pushButton_6">
    <property name="geometry">
     <rect>
      <x>10</x>
      <y>190</y>
      <width>31</width>
      <height>27</height>
     </rect>
    </property>
    <property name="text">
     <string>06</string>
    </property>
   </widget>
   <widget class="QPushButton" name="pushButton_7">
    <property name="geometry">
     <rect>
      <x>10</x>
      <y>220</y>
      <width>31</width>
      <height>27</height>
     </rect>
    </property>
    <property name="text">
     <string>07</string>
    </property>
   </widget>
   <widget class="QPushButton" name="pushButton_8">
    <property name="geometry">
     <rect>
      <x>10</x>
      <y>250</y>
      <width>31</width>
      <height>27</height>
     </rect>
    </property>
    <property name="text">
     <string>08</string>
    </property>
   </widget>
   <widget class="QPushButton" name="pushButton_9">
    <property name="geometry">
     <rect>
      <x>10</x>
      <y>280</y>
      <width>31</width>
      <height>27</height>
     </rect>
    </property>
    <property name="text">
     <string>09</string>
    </property>
   </widget>
   <widget class="QPushButton" name="pushButton_10">
    <property name="geometry">
     <rect>
      <x>10</x>
      <y>310</y>
      <width>31</width>
      <height>27</height>
     </rect>
    </property>
    <property name="text">
     <string>10</string>
    </property>
   </widget>
   <widget class="QPushButton" name="pushButton_11">
    <property name="geometry">
     <rect>
      <x>50</x>
      <y>10</y>
      <width>31</width>
      <height>27</height>
     </rect>
    </property>
    <property name="text">
     <string>00</string>
    </property>
   </widget>
   <widget class="QPushButton" name="pushButton_12">
    <property name="geometry">
     <rect>
      <x>50</x>
      <y>40</y>
      <width>31</width>
      <height>27</height>
     </rect>
    </property>
    <property name="text">
     <string>01</string>
    </property>
   </widget>
   <widget class="QPushButton" name="pushButton_13">
    <property name="geometry">
     <rect>
      <x>50</x>
      <y>70</y>
      <width>31</width>
      <height>27</height>
     </rect>
    </property>
    <property name="text">
     <string>02</string>
    </property>
   </widget>
   <widget class="QPushButton" name="pushButton_14">
    <property name="geometry">
     <rect>
      <x>50</x>
      <y>100</y>
      <width>31</width>
      <height>27</height>
     </rect>
    </property>
    <property name="text">
     <string>03</string>
    </property>
   </widget>
   <widget class="QPushButton" name="pushButton_15">
    <property name="geometry">
     <rect>
      <x>10</x>
      <y>10</y>
      <width>31</width>
      <height>27</height>
     </rect>
    </property>
    <property name="text">
     <string>00</string>
    </property>
   </widget>
  </widget>
  <widget class="QMenuBar" name="menuBar">
   <property name="geometry">
    <rect>
     <x>0</x>
     <y>0</y>
     <width>89</width>
     <height>30</height>
    </rect>
   </property>
  </widget>
  <widget class="QToolBar" name="mainToolBar">
   <attribute name="toolBarArea">
    <enum>TopToolBarArea</enum>
   </attribute>
   <attribute name="toolBarBreak">
    <bool>false</bool>
   </attribute>
  </widget>
  <widget class="QStatusBar" name="statusBar"/>
 </widget>
 <layoutdefault spacing="6" margin="11"/>
 <resources/>
 <connections/>
</ui>



Партнер
Показать сообщения за:  Поле сортировки  
Начать новую тему Новая тема / Ответить на тему Ответить  1 сообщение 
-

Часовой пояс: UTC + 3 часа


Кто сейчас на конференции

Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 4


Вы не можете начинать темы
Вы не можете отвечать на сообщения
Вы не можете редактировать свои сообщения
Вы не можете удалять свои сообщения
Вы не можете добавлять вложения

Перейти:  
Создано на основе phpBB® Forum Software © phpBB Group
Русская поддержка phpBB | Kolobok smiles © Aiwan