Results 1 to 10 of 10

Thread: QTimer and main eventLoop is there possible race condition?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: QTimer and main eventLoop is there possible race condition?

    Actually it depends what you mean. Timers as such do not generate events but are rather checked as part of the event loop whether they reached their timeout. If so, then the application will generate a timer event for the object interested in the timer's timeout (be it the timer object itself or the QObject instance calling startTimer() or using QBasicTimer).

    So to sum things up, this will execute the slot only once:

    Qt Code:
    1. connect(&t, SIGNAL(timeout()), ..., ...);
    2. t.start(1000); // 1s
    3. sleep(100); // 100s
    4. qApp->processEvents();// lets the timeout be checked and generates an event for the 't' object that will eventually call the slot from line #2
    To copy to clipboard, switch view to plain text mode 
    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.


  2. The following user says thank you to wysota for this useful post:

    franki (5th July 2012)

Similar Threads

  1. Replies: 0
    Last Post: 11th December 2011, 22:51
  2. Replies: 0
    Last Post: 14th April 2011, 15:10
  3. Problem with eventloop in QThread
    By speedy_gonzales in forum Qt Programming
    Replies: 2
    Last Post: 25th February 2010, 19:17
  4. 2D Race Car collision detection
    By neonnds in forum Qt Programming
    Replies: 0
    Last Post: 6th July 2008, 08:10
  5. Thread eventLoop and run
    By ^NyAw^ in forum Qt Programming
    Replies: 2
    Last Post: 8th May 2008, 19:36

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
  •  
Qt is a trademark of The Qt Company.