Results 1 to 4 of 4

Thread: I need a pause (QTimer)

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Aug 2007
    Posts
    275
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    28
    Thanked 2 Times in 2 Posts

    Default Re: I need a pause (QTimer)

    Good, that might work for me i dont have multiple threads i tried to make my life simple...
    Any more ways gentlemen

    baray98

  2. #2
    Join Date
    Aug 2006
    Location
    Bangalore,India
    Posts
    419
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11
    Thanks
    37
    Thanked 53 Times in 40 Posts

    Default Re: I need a pause (QTimer)

    If you aren't using multiple thread and if you can assure no reentrancy then there is chance that this following method will also work for you
    Again stressing the fact that this will fail miserably if there is chance of you calling the manualPause function while it is already in progress.
    Probably you can disable the buttons/control widgets when the manualPause is in progress. (also function using manualPause won't be reentrant)

    Qt Code:
    1. enum State
    2. {
    3. Paused,
    4. Run
    5. };
    6.  
    7. State state;
    8.  
    9. /** This function won't return till the time delay */
    10. void manualPause()
    11. {
    12. state = Paused;
    13. QTimer::singleShot(delay, this, SLOT(setRunState());
    14. while(1) {
    15. qApp->processEvents();
    16. if(state == Run) break;
    17. }
    18. }
    19.  
    20. void setRunState()
    21. {
    22. state = Run;
    23. }
    To copy to clipboard, switch view to plain text mode 
    The biggest difference between time and space is that you can't reuse time.
    -- Merrick Furst

  3. The following user says thank you to Gopala Krishna for this useful post:

    baray98 (17th January 2008)

Similar Threads

  1. Replies: 1
    Last Post: 14th June 2007, 15:52
  2. QTimer single shot and too busy app.
    By Pier in forum Qt Programming
    Replies: 3
    Last Post: 20th March 2007, 14:02
  3. Replies: 5
    Last Post: 6th March 2007, 05:34
  4. using QTimer in staticlib
    By jeetu_happy in forum Qt Programming
    Replies: 4
    Last Post: 22nd January 2007, 09:34
  5. QTimer problem ... it runs but never triggs
    By yellowmat in forum Newbie
    Replies: 4
    Last Post: 4th July 2006, 12:54

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.