Qt 定时器
毫秒级定时器
#include <QTimerEvent>
public:
void handleTimeout(); //超时处理函数
virtual void timerEvent(QTimerEvent *event);
private:
int timerID;
#define TIMER_TIMEOUT (5*1000)
timerID = this->startTimer(TIMER_TIMEOUT);
void timerEvent(QTimerEvent *event)
{
if(event->timerId() == timerID){
handleTimeout();
}
}
void handleTimeout()
{
qDebug() << "handleTimeout here\n";
killTimer(timerID);
}