View Full Version : timer->isActive bug

18th March 2009, 10:52

I am implementing a QTimer and my intention is to wait in a while loop until any of two conditins is true. One is refering to my aplication and is going to be all the time true, and the other condition is true until the timer have expired.

This is more or less the code which I am refering:

timer2= new QTimer(); // timer2 is a global QTimer
connect(timer2, SIGNAL(timeout()),this, SLOT(go()));

while( true && timer2->isActive()){


The problem is that the execution is all the time at the while loop and it is never conitnued, because although the time in running the timer2->isActive returns always true. And it is never gone to the SLOT go().

I have read that there is a qt bug related with this but it is resolved. I am using QT 4.4.4 on Windows Xp.

Cheers, and thank you in advance.

19th March 2009, 13:44
That's a very bad idea. You have to enter the event loop for the timer to timeout. Otherwise you can wait endlessly and the timer will remain active.
Read this article, especially the section about a local event loop.

It's not a bug by the way. Where did you here that?