非阻塞延时:
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);
}
转载自:http://blog.csdn.net/alan00000/article/details/9336377