标题:【提问】请问single-shot timer是什么?
作者:kytexzy
日期:2005-11-21 08:43
内容:
QTimer also provides a static function for single-shot timers.
请问single-shot timer是什么类型的计时器啊?
#1 [youngki 11-21 08:46]
单触发计时器?
#2 [tdrhsb 11-22 23:23]
void QTimer::singleShot ( int msec, QObject * receiver, const char * member )
This static function calls a slot after a given time interval.
It is very convenient to use this function because you do not need to bother with a timerEvent or to create a local QTimer object.
Example:
#include
#include
int main( int argc, char **argv )
{
QApplication a( argc, argv );
QTimer::singleShot( 10*60*1000, &a, SLOT(quit()) );
... // create and show your widgets
return a.exec();
}
This sample program automatically terminates after 10 minutes (i.e. 600000 milliseconds).
//////////////////////////////////////
QTimer::singleShot ()是一个static 函数,你不需要new一个QTimer就可以来定时了!
好像它的机制跟new一个QTimer是一样的!