Qt 延时函数
读取本地时间,计算本地时间与延时时间的和,当本地时间超过前面之和时,即计时到了,跳出循环
void Delay_MSec(unsigned int msec)
{
QThread::msleep(100);
qDebug() << "start" << msec << endl;
qDebug() << QTime::currentTime() << endl;
QTime _Timer = QTime::currentTime().addMSecs(msec);
while (QTime::currentTime() < _Timer)
QThread::usleep(1000);
qDebug() << QTime::currentTime() << endl;
}
后知后觉、越学越菜