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