//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裏面的函數就可以實現變速啦