PDA

View Full Version : Program freeze when timer->stop();



gQt
8th January 2009, 13:42
Hi all,

My program gives a command to a device. The device needs some time to respond to adjust to the command value. The program then reads values each second and tests if the system is stable (when max value-min value of the last n measurements < limit).


QTimer *timer;
Connect (timer,SIGNAL(timeout),this,SLOT(read_values());
timer->start(1000);


<The read_values function>



Void read_values()
{
stability=stability_test();
if(! stability)
{
<read values from device>
}
else
{
< stop timer>
timer->stop();
}
}


The problem is that the program freeze after timer->stop(). Is there a way around this problem?
Any help is deeply appreciated!

(The main class of the program subclass QDialog. Read_values() is a privat slot)

<Main.cpp>


int main(int argc, char *argv[])
{
Client client(parent,QString::fromLocal8Bit(argv[1]));
client.show();
client.exec();
}

jpn
8th January 2009, 13:46
Did you declare "QTimer* timer" as a member variable and local variable by accident?

gQt
8th January 2009, 14:05
Thanks for the quick reply.
Sorry, no QTimer * timer is just declared in the class. There is no declaration of *timer before the connect - statement I wrote that in the post by accident.