Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to sleep in Qt4
Qt 6.11 is out! See what's new in the release blog

How to sleep in Qt4

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 2.7k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    user001
    wrote on last edited by
    #1

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

    1 Reply Last reply
    0
    • JeroentjehomeJ Offline
      JeroentjehomeJ Offline
      Jeroentjehome
      wrote on last edited by
      #2

      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.

      Greetz, Jeroen

      1 Reply Last reply
      0
      • U Offline
        U Offline
        user001
        wrote on last edited by
        #3

        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'

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mcosta
          wrote on last edited by
          #4

          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.

          Once your problem is solved don't forget to:

          • Mark the thread as SOLVED using the Topic Tool menu
          • Vote up the answer(s) that helped you to solve the issue

          You can embed images using (http://imgur.com/) or (http://postimage.org/)

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved