How to pause and resume QTimer?
How to pause and resume QTimer?
Heavy Metal Rules. For those about to rock, we salute you.
HIT THANKS IF I HELPED.
As far as I know you cant. Use QTimeLine instead.
And what is wrong with the methods start() and stop() ?
Can you try this
Qt Code:
{ Q_OBJECT public: , mRemainingTime(0) { ; } public slots: void pause(void) { mRemainingTime = remainingTime(); stop(); } void resume(void) { start(mRemainingTime); } private: int mRemainingTime; };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.
QTimer::remainingTime() is only available in Qt 5
Bookmarks