Results 1 to 4 of 4

Thread: QTimer resolution.

  1. #1
    Join Date
    Sep 2009
    Posts
    15
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QTimer resolution.

    Hi, i am using QTimer in my application to set the frecuency of my main loop, and trying to set the FPS of my app.
    First, ill post the values i put in setInterval(), and the values i get between elapsed():

    setInterval() - elapsed()
    1 ------------- 1
    2 ------------- 2
    3 ------------- 3
    ... ----------- ...
    19 ----------- 19
    20 ----------- 20

    21..31 --------- 31

    32..46 --------- 46

    47..62 --------- 62

    etc...

    I know windows have a resolution of 15.625 ms, and the results from 20 miliseconds work as expected, but under 20ms, its gives a nice 1ms resolution, so i guess QTimer uses another implementation (Multimedia timers??) when you set the interval under 20ms. I have also noticed that CPU is higher under 20 ms and drops to nearly 0 after 21 ms, so this would confirm that the more demanding multimedia timers are used.

    I hope we can clarify this, as QTimer documentation is very short for this...

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

    dashesy (31st March 2010)

  3. #2
    Join Date
    Sep 2009
    Posts
    15
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QTimer resolution.

    Ive found this in the changelog of 4.6 (which im using). This confirms that MM timers are used below 20ms

    Qt Code:
    1. - QEventDispatcherWin32 (internal class)
    2. 90 * Changed the threshold for using multimedia timers to 20ms (was 10ms).
    To copy to clipboard, switch view to plain text mode 

    Now the question is how to change it so QTimer can be used like a multimedia timer to get linear FPS in our loops...

  4. The following user says thank you to Netich for this useful post:

    dashesy (31st March 2010)

  5. #3
    Join Date
    Sep 2009
    Posts
    15
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QTimer resolution.

    Ive implemented my own Multimedia timer, so i can get any framerate i want, (well, any 1000/integer interval). I hope Qt devs add the option to set the threshold for QTimer to use Multimedia timers, so you dont have to use platform-specific timers.

  6. #4
    Join Date
    Mar 2010
    Posts
    6
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTimer resolution.

    Wow, thanks for the finding and posting it here!

    I was wondering why the sudden CPU usage when I changed the interval. I am glad the MM timers are used when needed.
    I also wish the document were more clear on that.

Similar Threads

  1. Change The VGA Resolution On The Fly
    By guninia in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 11th November 2009, 06:22
  2. Screen resolution
    By sabeesh in forum Qt Programming
    Replies: 4
    Last Post: 7th September 2007, 17:00
  3. how to scale according to the used resolution
    By rmagro in forum Qt Programming
    Replies: 1
    Last Post: 3rd July 2007, 10:43
  4. Trouble with resolution
    By Xaar in forum Newbie
    Replies: 6
    Last Post: 23rd February 2007, 18:58

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.