漏了#endif
Qt自定义延时函数:
void Wait(int ms)
{
QElapsedTimer timer;
timer.start();
do {
QCoreApplication::processEvents(QEventLoop::AllEvents, ms);
#ifdef Q_OS_WIN
Sleep(1);
#else
struct timespec ts = { 0, 1 * 1000 * 1000 };
nanosleep(&ts, NULL);
#endif
} while (timer.elapsed() < ms);
}