QTimer简介

The QTimer class provides repetitive and single-shot timers.
The QTimer class provides a high-level programming interface for timers. To use it, create a QTimer, connect its timeout() signal to the appropriate slots, and call start(). From then on it will emit the timeout() signal at constant intervals.
Example for a one second (1000 millisecond) timer (from the Analog Clock example):

QTimer类提供了重复的和信号槽的记时器。QTimer为记时器提供了一个高级程序接口。创建一个记时器实例,连接它的timeout()信号到适当的槽。然后执行start()函数,从这时开始,它将以一个恒定的间隔发射timeout()信号。
例如:一个一秒(1000豪秒)的记时器(来自于例子模拟时钟)。

 

     QTimer *timer = new QTimer(this);
     connect(timer, SIGNAL(timeout()), this, SLOT(update()));
     timer->start(1000);

 

From then on, the update() slot is called every second.
从那时起,update()函数每隔一秒就会被调用一次。

 

还有些高级的功能,比如在多线程里的QTimer,等需要的时候再翻译。

 

你可能感兴趣的:(QTimer简介)