利用事件循环实现主线程sleep 不会导致gui无响应

it2023-05-30  70

QEventLoop eloop; QTimer::singleShot(10000, &eloop, SLOT(quit())); eloop.exec(); [static] void QTimer::singleShot(int msec, const QObject *receiver, const char *member) This static function calls a slot after a given time interval. It is very convenient to use this function because you do not need to bother with a timerEvent or create a local QTimer object.

这个静态函数在给定的时间间隔后调用一个槽。 使用此函数非常方便,因此您不需要为timerEvent或创建本地QTimer对象而烦恼。

最新回复(0)