QTimer使用方法

1、包含头文件

  #include<QTimer>

2、

QTimer *timer = new QTimer(this);      //this 指定父对象,可自动回收
connect(timer, SIGNAL(timeout()), this, SLOT(update()));
timer->start(1000);

startTimer()函数的作用是使定时器开始,并且返回一个定时器标识符,或者如果不能开始计时,返回0。当定时器事件发生时,虚函数timeEvent(QTimeEvent*)被调用为QTimerEvent时间参数类。重新实现这个函数可以获得定时器事件。 

posted @ 2019-04-19 09:15  Werial  阅读(2617)  评论(0编辑  收藏  举报