Results 1 to 2 of 2

Thread: QObject::timerEvent() time resolution

  1. #1
    Join Date
    Apr 2009
    Posts
    5
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QObject::timerEvent() time resolution

    It appears that on my system (WinXP, MinGW) the resolution of QTime::currentTime() is between 15 and 16 milliseconds.

    The output of this increases in steps of 15 and 16:
    Qt Code:
    1. QTime tt = QTime::currentTime();
    2. for (;;) {
    3. std::cout << tt.msecsTo(QTime::currentTime()) << std::endl;
    4. }
    To copy to clipboard, switch view to plain text mode 

    I believe the resolution of intervals between QObject::timerEvent() calls to be the same (i.e ~15 ms).

    I noticed this when I was using QObject::timerEvent() to draw the frames of an animation. I implemented the animation in Processing earlier, and strangely the Processing version was running faster than the Qt version, even though the Qt version's CPU usage was always under 10%. It turns out that this is because the frame rates were not the same---because of the 15 ms resolution, in Qt I could only get frame rates of 1000/(N*15) with N=1,2,3,...

    My question is: Is it possible to remedy this problem and have more precise frame rate control? Can I do anything to increase the resolution of Qt's timers? It is clearly possible to do more precise time measurements in Windows (the Java-based Processing appears to be able to do it), but is it possible to use them with Qt?

  2. #2
    Join Date
    Apr 2009
    Posts
    5
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QObject::timerEvent() time resolution

    I found the timeBeginPeriod and timeEndPeriod Windows functions, and tried calling them at the beginning and end of the main() function, but this seems to have no effect on the resolution of Qt timers. The resolution is still 15 ms. Does Qt use a timer that's unaffected by timeBeginPeriod, or was there something that I was doing wrong?

Similar Threads

  1. How to constantly refresh time on a view
    By salmanmanekia in forum Qt Programming
    Replies: 5
    Last Post: 23rd June 2008, 12:44
  2. file time stamp preservation
    By baray98 in forum Qt Programming
    Replies: 0
    Last Post: 8th April 2008, 00:13
  3. Replies: 1
    Last Post: 1st February 2008, 18:55
  4. QDateTime GMT add sec. or - sec. from locale time....
    By patrik08 in forum Qt Programming
    Replies: 2
    Last Post: 20th February 2007, 16:39
  5. Problem with pointers while using localtime() and time()
    By jamadagni in forum General Programming
    Replies: 7
    Last Post: 11th January 2006, 15:48

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.