Solved If the execution time of slot function is greater than the interval of qtimer?
-
slots: /* if it will need 1000ms to finish */ void doBusyThings() { ... ... } QTimer* timer = new QTimer(this); connect(timer, SIGNAL(tiermOut()), this, SLOT(doBusyThings())); timer->start(500);
What happens to
doBusyThings()
?I mean
doBusyThings()
will be pushed into a queue and wait to execute? Or kill the runningdoBusyThings()
and continue to execute the next? -
@Limer
that depends, do you do sketchy stuff in busyThings, like start a QEventLoop or call ProcessEvents ?If not, than the timeout events are queued and executed the next eventloop cycle.
-
Hi @Limer,
just to add to @J-Hilk: The events will be queued, but during your long slot no events will be processed.
That means, if you resize your window in that time, it will not be redrawn (Except you use ProcessEvents or start a local event loop).
So there are two solutions:
- split doBusyThings() into smaller pieces that take much shorter time to execute
- use a separate thread to execute the long lasting tasks
Regards
-