非阻塞延时:
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);
}
时间: 2024-10-12 16:44:57