However, they are marked as protected, so you can call them only in a QThread subclass.
If for some reason you can't use QThread methods, the following small utility class will help you:
#include <QWaitCondition> #include <QMutex> class Sleep { public: // Causes the current thread to sleep for msecs milliseconds. static void msleep(unsigned long msecs) { QMutex mutex; mutex.lock(); QWaitCondition waitCondition; waitCondition.wait(&mutex, msecs); mutex.unlock(); } };
Thanks, your solution worked very well for me. No subclassing required :)
ReplyDeleteThanks you save my life
ReplyDeleteepic win
ReplyDeletethanks
thanks worked for main thread
ReplyDeleteQThread::currentThread()->wait(msecs);
ReplyDeleteis a bit easier