///
/// \brief MainWindow::sleep make the process wait a period of time
/// \param msec milliseconds num
///
void MainWindow::sleep(unsigned int msec)
{
QTime reachTime = QTime::currentTime().addMSecs(msec);
while (QTime::currentTime()<reachTime) {
QCoreApplication::processEvents(QEventLoop::AllEvents, 100);
}
}
- 借用系统时间来判断延时时长是否满足后跳出循环