Results 1 to 5 of 5

Thread: QThread::Sleep goes to not responding state

  1. #1
    Join Date
    Oct 2012
    Posts
    27
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default QThread::Sleep goes to not responding state

    Hi guys,

    I'm currently using QThread::Sleep yet i have observe the application went to "not responding" state during sleep.Is there a way to prevent this? Is there any option to set the application into halt for several seconds without experiencing not responding? I want that the UI wont be accessible during the specified time frame.

    Thanks!

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 453 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: QThread::Sleep goes to not responding state

    Where did you use QThread::Sleep in code?

    One way to stop UI responding is don;t let the control go back to event loop. (Block/Loop/Sleep in a Slot, and signal the slot as required)
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  3. #3
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QThread::Sleep goes to not responding state

    Quote Originally Posted by Santosh Reddy View Post
    Where did you use QThread::Sleep in code?
    Good question!

    Quote Originally Posted by Santosh Reddy View Post
    One way to stop UI responding is don;t let the control go back to event loop. (Block/Loop/Sleep in a Slot, and signal the slot as required)
    True, but the problem is the UI not responding so another way to achieve an unresponsive UI is probably not that helpful

    Everything that blocks the main thread will lead to an unresponsive UI. The good thing is that the main thread doesn't do anything if doesn't have to, so it will "sleep" by default.

    Cheers,
    _

  4. #4
    Join Date
    May 2009
    Location
    Canada
    Posts
    163
    Thanks
    7
    Thanked 20 Times in 20 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Windows Android

    Default Re: QThread::Sleep goes to not responding state

    In lieu of sleeping or blocking per se, you might consider simply disabling your interface: highLevelWidget.setEnabled(false). When the "specified time frame" has elapsed, you then simply re-enable the interface using a signal-slot connection.

  5. #5
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QThread::Sleep goes to not responding state

    Quote Originally Posted by kiboi View Post
    Hi guys,

    I'm currently using QThread::Sleep yet i have observe the application went to "not responding" state during sleep.Is there a way to prevent this? Is there any option to set the application into halt for several seconds without experiencing not responding? I want that the UI wont be accessible during the specified time frame.

    Thanks!
    use a modal dialog.
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

Similar Threads

  1. Change state property within a current state?
    By prophet0 in forum Qt Quick
    Replies: 1
    Last Post: 30th May 2012, 19:23
  2. Replies: 14
    Last Post: 13th October 2011, 15:24
  3. State Machine returning to previous state
    By akiross in forum Qt Programming
    Replies: 2
    Last Post: 10th May 2011, 00:39
  4. Replies: 0
    Last Post: 19th December 2010, 16:03
  5. sleep - sleeps, but not when I want it to sleep
    By nongentesimus in forum Newbie
    Replies: 2
    Last Post: 2nd March 2006, 14:43

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.