win32 有一个消息是 WM_IDLE,而在MFC里面的也有一个virtualBOOLOnIdle(LONGlCount)的函数与之相对应,而在MSDN中对该函数的解释是:

  Override this member function to perform idle-time processing. OnIdle is called in the default message loop when the application’s message queue is empty. Use your override to call your own background idle-handler tasks.


   大概意思是重写这个成员方法去执行空闲处理。OnIdle函数将在应用程序的消息队列为空时在默认的消息循环队列中被调用。你可以用你的重载函数去调用你自已的后台空闲处理任务。


   用Qt做开发时,我需要在空闲时在后台调用的我空闲处理地,那么Qt里面有这个东西吗?

   经过查阅QT的帮助文档,发现startTime除了能够开起一个定时执行的定时器外还能实现这一功能。看看QT中该函数的解说。

int QObject::startTimer ( intinterval)

Starts a timer and returns a timer identifier, or returns zero if it could not start a timer.

A timer event will occur everyintervalmilliseconds untilkillTimer() is called. Ifintervalis 0, then the timer event occurs once every time there are no more window system events to process.


    如果将传入参数设置为0,这个时钟在每一次窗口系统事件为空时就会发生。也就是说我们就可以将传入参数设置为0,然后在重写的函数中实现我们自已的空闲处理。