非忙等:

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

}

05-04 06:05