Results 1 to 2 of 2

Thread: timer->isActive bug

  1. #1
    Join Date
    Jan 2009
    Qt products

    Default timer->isActive bug


    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:

    Qt Code:
    1. timer2= new QTimer(); // timer2 is a global QTimer
    2. timer2->setSingleShot(true);
    3. connect(timer2, SIGNAL(timeout()),this, SLOT(go()));
    4. timer2->start(10000);
    6. while( true && timer2->isActive()){
    8. }
    To copy to clipboard, switch view to plain text mode 

    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.

  2. #2
    Join Date
    Jan 2006
    Warsaw, Poland
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits

    Default Re: timer->isActive bug

    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?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.

Similar Threads

  1. implemet a timer
    By adamatic in forum Qt Programming
    Replies: 12
    Last Post: 17th February 2009, 07:31
  2. how to enable a timer in a non-gui thread?
    By zeopha in forum Qt Programming
    Replies: 3
    Last Post: 5th August 2008, 09:29
  3. Thread(s) and socket, timer slots
    By stephdev1965 in forum Qt Programming
    Replies: 1
    Last Post: 8th November 2006, 14:04
  4. How and when to repaint a widget ?
    By yellowmat in forum Newbie
    Replies: 7
    Last Post: 3rd April 2006, 16:36
  5. Timer call
    By mahe2310 in forum Qt Programming
    Replies: 1
    Last Post: 28th March 2006, 08:57


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.