[Qt-interest] QTimer on Windows in Unreliable for Small (16ms - 30ms) Delays

Thiago Macieira thiago.macieira at trolltech.com
Mon Sep 7 07:40:49 CEST 2009


Em Segunda-feira 7. Setembro 2009, às 02.48.17, você escreveu:
> I'm a bit confused - the description for QTimer says:
> 
> "Note that QTimer's accuracy depends on the underlying operating system and
>  hardware." "Most platforms support an accuracy of 1 millisecond, but
>  Windows 98 supports only 55." "If Qt is unable to deliver the requested
>  number of timer clicks, it will silently discard some"
> 
> while you said:
> >That said, QTimer uses the system timer which is unreliable and
> >inaccurate. You should use the Windows Multimedia Timers if you
> >something accurate. In fact, QTimer uses multimedia timers for interval
> >< 10ms (maybe it's <= 10ms, not sure). You can either use 8ms timer and
> >process every alternate one or use the Windows MM Timer Api directly.
> 
> so with Win XP, what is the accuracy of QTimer for periods of greater than
> 10 msecs - is it 1 millisecond or is it more?  Why doesn't QTimer use the
> Multimedia Timers for all periods?

Because QTimer isn't a precise timer. It's not guaranteed to be and it doesn't 
pretend to be.

If you need high-precision timers, you'll have to find a way of getting them 
yourself. QTimer is meant for normal-priority tasks where being a few 
milliseconds late is ok. Conserving power (reducing the number of CPU wakeups) 
is more important than precision.

-- 
Thiago Macieira - thiago.macieira (AT) nokia.com
  Senior Product Manager - Nokia, Qt Development Frameworks
     Sandakerveien 116, NO-0402 Oslo, Norway

Qt Developer Days 2009 | Registration Now Open!
Munich, Germany: Oct 12 - 14     San Francisco, California: Nov 2 - 4
      http://qt.nokia.com/qtdevdays2009




More information about the Qt-interest-old mailing list