#include <QTime>void MainWindow::Sleep(unsigned int msec) { QTime reachTime=QTime::currentTime().addMSecs(msec); while(QTime::currentTime()<reachTime) { QCoreApplication::processEvents(QEventLoop::AllEvents,); } }