Results 1 to 3 of 3

Thread: Program freeze when timer->stop();

  1. #1
    Join Date
    Feb 2008
    Posts
    36
    Thanks
    4

    Default Program freeze when timer->stop();

    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).

    Qt Code:
    1. QTimer *timer;
    2. Connect (timer,SIGNAL(timeout),this,SLOT(read_values());
    3. timer->start(1000);
    To copy to clipboard, switch view to plain text mode 

    <The read_values function>

    Qt Code:
    1. Void read_values()
    2. {
    3. stability=stability_test();
    4. if(! stability)
    5. {
    6. <read values from device>
    7. }
    8. else
    9. {
    10. < stop timer>
    11. timer->stop();
    12. }
    13. }
    To copy to clipboard, switch view to plain text mode 

    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>

    Qt Code:
    1. int main(int argc, char *argv[])
    2. {
    3. Client client(parent,QString::fromLocal8Bit(argv[1]));
    4. client.show();
    5. client.exec();
    6. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by jpn; 8th January 2009 at 13:45. Reason: missing [code] tags

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Program freeze when timer->stop();

    Did you declare "QTimer* timer" as a member variable and local variable by accident?
    J-P Nurmi

  3. #3
    Join Date
    Feb 2008
    Posts
    36
    Thanks
    4

    Default Re: Program freeze when timer->stop();

    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.

Similar Threads

  1. QT MySQL
    By sabeeshcs in forum Newbie
    Replies: 6
    Last Post: 12th January 2007, 04:19
  2. Replies: 1
    Last Post: 20th January 2006, 12:01

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.