[Qt-interest] Realtime timing in Qt

Daniel Price daniel.price at fxhome.com
Wed Sep 8 13:51:29 CEST 2010


What's the simplest way to implement 'realtime' timing in Qt? I'm using a QGLWidget and I want to do some animation such that the framerate remains constants regardless of the size of the view or the complexity of the scene.

I've done this kind of thing before in Win32 using the Windows precision timers but I'm looking for a portable solution that makes use only of Qt.

I don't think QTimer will cut it because it is event-based. Ditto for QThreads and signal/slots.

Ideally I'd have a loop that checks the number of milliseconds passed since the last iteration. If the number is less than the required framerate, the (main) thread will sleep for the remainder, giving time to any other threads (sleep(0) in Win32).

How can I do this in Qt?


Daniel Price
Software Engineer
FXhome Limited

daniel.price at fxhome.com<mailto:daniel.price at fxhome.com>
http://fxhome.com


________________________________
This email is confidential. It may also be privileged or otherwise protected by work product immunity or other legal rules. If you are not the intended recipient please notify the sender. Please delete the message from all places in your computer where it is stored. You should not copy the email or use it for any purpose or disclose its contents to any other person.To do so may be unlawful. Email is an informal means of communicating and may be subject to data corruption accidentally or deliberately. For this reason it is inappropriate to rely on advice contained in an email without obtaining written confirmation of it first.

FXhome Limited is a limited company registered in England and Wales. Registered number: 04172812. Registered office: The Henderson Business Centre, Ivy Road, Norwich, Norfolk, NR5 8BF, U.K.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100908/83d1d74a/attachment.html 


More information about the Qt-interest-old mailing list