QT的阻塞与非阻塞延时

非阻塞延时:

void GreenPass3::delaymsec(int msec) {     QTime dieTime = QTime::currentTime().addMSecs(msec);

    while( QTime::currentTime() < dieTime )

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

 

 

阻塞延时:

void GreenPass3::delaymsec(int msec) {

    QTime n=QTime::currentTime();

    QTime now;     do{       now=QTime::currentTime();     }while (n.msecsTo(now)<=msec);

}

你可能感兴趣的:(QT的阻塞与非阻塞延时)