c_cpp QT - 线程睡眠

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了c_cpp QT - 线程睡眠相关的知识,希望对你有一定的参考价值。

//METODO 1:
//Using the class QTest
QTest::qSleep(100); // it block the event processing
QTest::qWait(100);  // it does not block the event processing
 
//METODO 2:
//Using the classes QWaitCondition and QMutex
QWaitCondition waitCondition;
QMutex mutex;
 
waitCondition.wait(&mutex, 100);
 
//METODO 3:
//Or derive our class from QThread
class Thread : public QThread
{
public:
    static void msleep(int ms)
    {
        QThread::msleep(ms);
    }
};
 
Thread::msleep(100);

以上是关于c_cpp QT - 线程睡眠的主要内容,如果未能解决你的问题,请参考以下文章