PDA

View Full Version : How to set the QTIMER active only once ?



wter27
28th February 2011, 02:16
I use the QTIMER ,QTIMEEDIT,QTIME to show the time passed away.Here is the processment:When clicked the button.the QTIME timer_seconds minus one second and the QTIMEEDIT part show the time passed away.But if I clicked the button too fast.The timer_seconds would minus more than one second ,it might be minus two or three seconds which in fact that it only passed one second.The reason which i thought is I active the QTIMER function more than one times at a short time.So how to control the qtimer class to make sure the qtimer being actived at only one time.Do i need to use the QTHREAD and QMUAX some classes like that?And how?

Lykurg
28th February 2011, 06:16
I don't get what you are doing, so could you please post a short example.

ChrisW67
28th February 2011, 06:40
As Lykurg says, it is not clear what you want.

If you connect the timer signal to a slot every time the button is pressed then you can get multiple connections. Each connection will be called when the timer expires.

Lesiok
28th February 2011, 09:06
Just use QTimer::singleShot