QT延时方法整理(QTimer::singleShot,QWaitCondition,QDateTime.secsTo三种新方法)


1:

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

样例:

 #include <QApplication>

 #include <QTimer>

 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为需要延时的秒数

 

http://blog.csdn.net/liuguangzhou123/article/details/7399253


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM