Results 1 to 7 of 7

Thread: How to "sleep" inside QRunnable-derived class?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Nov 2009
    Location
    US, Midwest
    Posts
    215
    Thanks
    62
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to "sleep" inside QRunnable-derived class?

    I am surprised the there is no qt-way of doing it in platform-independent manner.
    Will this hack work?

    Qt Code:
    1. class mythreadhelper : public QThread
    2. {
    3. public:
    4. static void mysleep(int ms)
    5. {
    6. return sleep(ms);
    7. }
    8. };
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to "sleep" inside QRunnable-derived class?

    Considering QThread::sleep() calls ::Sleep, I'd have to say yes.

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,370
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to "sleep" inside QRunnable-derived class?

    Quote Originally Posted by TorAn View Post
    Will this hack work?
    It would be much easier if you just called ::Sleep() or ::sleep(). Or better yet if you used a wait condition.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Replies: 1
    Last Post: 14th August 2009, 21:17
  2. Can not cast into the derived class from QScrollBar
    By learning_qt in forum Qt Programming
    Replies: 2
    Last Post: 19th December 2008, 10:23
  3. [SOLVED] Q_ENUMS from another class inside a plugin
    By desch in forum Qt Programming
    Replies: 1
    Last Post: 1st December 2007, 15:44
  4. rtti() of derived class
    By quickNitin in forum Newbie
    Replies: 4
    Last Post: 8th October 2006, 14:20
  5. Signal/slot looking in base class, not derived class
    By georgie in forum Qt Programming
    Replies: 2
    Last Post: 12th May 2006, 07:36

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.