<Qt C++>Timer實現變速

//Dialog.h

private:
QTimer *timer;

//Dialog.cpp

//構造函數裏
timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(update())); 
updatetime();

//構造函數外
void Dialog::updatetime()
{
    if(speed==1)
        timer->stop();
    else
      timer->start(300-speed*10);

}

之後SLOT裏面的函數就可以實現變速啦

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章