Qt4——程序延时的方法

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:以毫秒计

    QTimen=QTime::currentTime();
    QTimenow;
    do{
         qDebug()<<"jjmm";
        now=QTime::currentTime();
    }   while(n.msecsTo(now)<=1);


3:以秒计

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






参考来源:http://blog.sina.com.cn/s/blog_640531380100txlt.html

你可能感兴趣的:(Qt4)