[Qt-interest] QTimer not firing while GUI busy
Thiago Macieira
thiago at kde.org
Tue Jan 12 01:06:17 CET 2010
Em Terça-feira 12. Janeiro 2010, às 00.46.18, Joshua Grauman escreveu:
> Hello all,
>
> I just upgraded my system from Slackware 12.0 to Kubuntu 9.10, and my
> application is no longer working. It appears that the QTimer is not firing
> as frequently as before and therefore is not able to record a measurment
> accurately. I see in the docs that QTimer won't fire while the application
> is busy. Is there any way around this? I would like my QTimer to fire
> every 20 msec, even if it has to interrupt the gui for a microsecond to
> record a measurement... Thoughts? Thanks.
Hi Joshua
There's no way that QTimer can interrupt processing of anything. QTimer is
simply a window into the event loop mechanism, indicating when it should post
an event (when the timer has expired). But, in order to do that, it needs the
control to be passed to the event loop before the timer expires.
Your option is to move your timer to a thread. Even then, scheduling is a
decision by the operating system: to get precise timers, you need a thread
with real-time priority and only root can do that. From people that have
tried, I heard that QTimer on a real-time otherwise idle thread fires with
exact precision.
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Senior Product Manager - Nokia, Qt Development Frameworks
PGP/GPG: 0x6EF45358; fingerprint:
E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100112/c035abca/attachment.bin
More information about the Qt-interest-old
mailing list