QT遅延関数


void MainWindow::usleep(unsigned int msec)
{
#if 1  /*   1 */
    QElapsedTimer t;

    t.start();
    while (t.elapsed() < msec) {
        QCoreApplication::processEvents();
    }
#endif

#if 1  /*   2 */
    QTime dieTime = QTime::currentTime().addMSecs(msec);

    while (QTime::currentTime() < dieTime) {
        QCoreApplication::processEvents(QEventLoop::AllEvents, 100);
    }
#endif
}