Solved QTimer, start, stop and start again
-
Hello,
I have a
QTimer
that repeatedly runs a function. I start it with an interval of 20 ms. Later I stop it. Then I start it again with the same interval of 20 ms. After that, I realize that the function is called twice as much as it was before I stopped theQTimer
for the first time. If I stop and start it again, then the function will be called thrice as much.It looks like
QTimer::stop
doesn't do what I hoped it would. How exactly can I stop aQTimer
from running a function for some time, then make it resume with the same interval ? -
Hi,
Can you share the code you use to start and stop your QTimer ?
If it's called twice as much after a single stop/start sequence, it might be that you're connecting again your QTimer object to your slot.
-
@SGaist said:
it might be that you're connecting again your QTimer object to your slot.
That's exactly what I was doing! Thanks a lot, everything works perfectly now.