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);
}