Results 1 to 3 of 3

Thread: Event loop

  1. #1
    Join Date
    Jan 2011
    Posts
    1

    Default Event loop

    What is the best way to get a message for each loop? I want to use the loop to update my game engine.

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Event loop

    What if you used a QTimer, with a short timeout? Use a connection to the timeout signal as the trigger to update your engine.

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Event loop

    Quote Originally Posted by jefs View Post
    What is the best way to get a message for each loop? I want to use the loop to update my game engine.
    That would probably not be a good idea. The game loop should be executed at constant intervals of time and event loop doesn't guarantee anything like that. Better calculate how many iterations per second you need and use an adaptive timer to trigger the game loop (you can use QTimer::singleShot() for that if you calculate corrections to the time in each interation or you can use QObject::startTimer() if you don't want your timer to be adaptive).
    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. Event loop does not start
    By koan in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 31st August 2010, 15:26
  2. Replies: 10
    Last Post: 15th January 2010, 15:35
  3. Event Loop
    By node_ex in forum Qt Programming
    Replies: 1
    Last Post: 12th December 2008, 08:52
  4. Replies: 0
    Last Post: 23rd October 2008, 13:43
  5. calling event through in loop
    By raghvendramisra in forum Qt Programming
    Replies: 3
    Last Post: 28th February 2008, 06:41

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.