qt忙等与非忙等

非忙等:

void delay(int msec) {    

  QTime end = QTime::currentTime().addMSecs(msec);

      while( QTime::currentTime() < end)

      QCoreApplication::processEvents(QEventLoop::AllEvents, 100);

}

 

 

忙等:

void delayBlock(int msec) {

    QTime start = QTime::currentTime();

    QTime now;    

  do{      

      now=QTime::currentTime();    

 }while (start.msecsTo(now)<=msec);

}

posted on 2013-08-22 14:45  wps712  阅读(523)  评论(0编辑  收藏  举报

导航