///
/// \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);
}
}
- 借用系统时间来判断延时时长是否满足后跳出循环
更多内容
- 语雀
https://www.yuque.com/wangxi_chn
欢迎关注公众号,交流每日所见所想、学习经验