//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里面的函数就可以实现变速啦