1、多次使用,最简单实例
头文件:<QTimer>
.h
private slots:
void fun();
//放置构造函数或者其他
QTimer *timer = new QTimer(this);
connect(timer,SIGNAL(timeout()),this,SLOT(fun()));//注意第一个为timer
timer->start(1000);
void ****::fun()
{
//添加操作,每秒钟相应一次
}
2、单次使用
QTimer::singleShot(200,this,SLOT(fun()));//200毫秒后启动功能函数