Results 1 to 5 of 5

Thread: QT QTimer

  1. #1
    Join Date
    May 2012
    Location
    Bangalore, India
    Posts
    271
    Thanks
    29
    Thanked 50 Times in 47 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default QT QTimer

    How to pause and resume QTimer?
    Heavy Metal Rules. For those about to rock, we salute you.
    HIT THANKS IF I HELPED.

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: QT QTimer

    As far as I know you cant. Use QTimeLine instead.

  3. #3
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QT QTimer

    And what is wrong with the methods start() and stop() ?

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

    Default Re: QT QTimer

    Can you try this
    Qt Code:
    1. class Timer : public QTimer
    2. {
    3. Q_OBJECT
    4. public:
    5. explicit Timer(QObject * parent)
    6. : QTimer(parent)
    7. , mRemainingTime(0)
    8. {
    9. ;
    10. }
    11.  
    12. public slots:
    13. void pause(void)
    14. {
    15. mRemainingTime = remainingTime();
    16. stop();
    17. }
    18.  
    19. void resume(void)
    20. {
    21. start(mRemainingTime);
    22. }
    23.  
    24. private:
    25. int mRemainingTime;
    26. };
    To copy to clipboard, switch view to plain text mode 

    One downside is that the interval() is not consistent through out the Timer's running cycle, interval() changes when ever time is pause()ed and resume()ed.
    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.

  5. #5
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QT QTimer

    QTimer::remainingTime() is only available in Qt 5

  6. The following user says thank you to ChrisW67 for this useful post:


Similar Threads

  1. Replies: 1
    Last Post: 25th October 2012, 19:47
  2. Replies: 15
    Last Post: 4th August 2012, 19:11
  3. Use of QTimer
    By A.H.M. Mahfuzur Rahman in forum Qt Programming
    Replies: 4
    Last Post: 7th August 2009, 13:52
  4. QTimer
    By Ahmad in forum Qt Programming
    Replies: 1
    Last Post: 22nd October 2007, 18:26
  5. QTimer
    By nirup in forum Qt Programming
    Replies: 1
    Last Post: 29th May 2007, 14:13

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.