一:方法1
QTime t; t.start(); while(t.elapsed()<1000){ QCoreApplication::processEvents();} 二:方法2
QElapsedTimer t; t.start(); while(t.elapsed()<1000){ QCoreApplication::processEvents();} 三:方法3
QTest::qWait
源代码:
namespace QTest { inline static void qWait(int ms) { Q_ASSERT(QCoreApplication::instance()); QElapsedTimer timer; timer.start(); do { QCoreApplication::processEvents(QEventLoop::AllEvents, ms); QTest::qSleep(10); } while (timer.elapsed() < ms); } ... 四:方法4QEventLoop eventloop;
QTimer::singleShot(100, &eventloop, SLOT(quit())); eventloop.exec();
时间: 2024-10-09 12:53:30