首页 > 其他 > 详细

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

时间:2017-02-03 10:38:23      阅读:1941      评论:0      收藏:0      [点我收藏+]

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

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

原文:http://www.cnblogs.com/findumars/p/6361996.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!