Details
-
Suggestion
-
Resolution: Done
-
P3: Somewhat important
-
None
-
None
-
ef60ed1c9dbc87d9f8401036cc254a9c45cd8ca8
Description
In an application which shows a clock with seconds, or a second hand, it would be nice if that time was visually the same as the system time. It's not so nice if you run several clocks at the same time and they are all "ticking" at different times, up to 1 second apart. But if you start a QTimer with an interval of 1000, there is no alignment: the timeout() signal occurs approximately 1 second after the timer was started.
Maybe we could somehow add a Qt::AlignedTimer as a possible timerType? But I don't know how achievable that is.
Existing ways for an application to deal with this: run a delay loop to wait for a suitable moment before starting the QTimer; use some different source of time outside of Qt; or run the QTimer at a high frequency, and check whether the milliseconds component of the system time is close enough to zero before updating the display. All of those are inconvenient, and two of them have performance cost.
Even if we had an alignedTimer, the caveat would remain that it's still inexact due to various reasons. But maybe it's worth a try to get closer by one means or another?
QML Timers are supposed to be updated in the render thread, so maybe a good alternative would be to provide alignment only in that type of timer, by checking the milliseconds.
Alignment to other intervals would of course be useful as well.