字體:小 中 大 | |
|
|
2021/05/10 15:05:24瀏覽71|回應0|推薦0 | |
mainwindow.h #include <QTimer> private slots: void on_tmr(); private: Ui::MainWindow *ui; QTimer *tmr1; //------------------------ mainwindow.cpp #include <QTimer> void MainWindow::on_pushButton_clicked() MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { tmr1= new QTimer; connect(tmr1,SIGNAL(timeout()),this,SLOT(on_tmr())); ui->setupUi(this); } { if (tmr1->isActive()) { tmr1->stop(); } else { tmr1->start(100); } } void MainWindow::on_tmr() { int i1; i1 = ui->dial->value(); if (i1 < 90) { i1++; ui->dial->setValue(i1); } else { tmr1->stop(); } } void MainWindow::on_pushButton_2_clicked() { tmr1->stop(); } |
|
( 不分類|不分類 ) |