QT延时方法整理(转)

1:

void QTimer::singleShot ( int msec, QObject * receiver, const char * member ) [static]   

样例:

 #include

 #include

 int main(int argc, char *argv[])

 {

  QApplication app(argc, argv);

  QTimer::singleShot(600000, &app, SLOT(quit()));

  ...

  return app.exec();

 }

 

2:

QWaitCondition waitCond;

waitCond.wait (400); // or any other time in [ms]

 

3:

QDateTime n2=QDateTime::currentDateTime();

  QDateTime now;

  do{

      now=QDateTime::currentDateTime();

  } while (n2.secsTo(now)<=6);  //6为需要延时的秒数

你可能感兴趣的:(QT)