千家信息网

<Qt C++>Timer实现变速

发表于:2025-02-01 作者:千家信息网编辑
千家信息网最后更新 2025年02月01日,//Dialog.hprivate:QTimer *timer;//Dialog.cpp//构造函数里timer = new QTimer(this);connect(timer, SIGNAL(ti
千家信息网最后更新 2025年02月01日<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里面的函数就可以实现变速啦

0