Important: Please read the Qt Code of Conduct -

How to sleep in Qt4

  • I have a sleep call in Qt5 code, @QThread::msleep(100);@. and want to convert to Qt4 code. cannot find direct answer online.

  • The sleep function in Qt5 is obsolete when coding QThread correctly. You probably subclassed the QThread class?? It is discouraged to do so. Please search this forum and the answer is there.

  • No, I didn't subclass the QThread. I just made a call to QThread::msleep() in my main(). But Qt4 doesn't like it:

    src\main.cpp:38: error: C2248: 'QThread::msleep' : cannot access protected member declared in class 'QThread'

  • Hi,
    sleep isn't a good practice.
    Depending on what do you need, there are different alternative solutions.

    Tell us your needs and show some piece of code.

Log in to reply