Is QTimer smart enough to resynchronize itself

喜你入骨 提交于 2019-12-11 12:35:24

问题


Let's say we start a QTimer with a 100ms interval at t0.

Let's say first timeout occurs at t0+100ms. Fine.

Let's say that, due to huge CPU load and/or lots of events having to be handled by the event loop, second timeout occurs at t0+230ms.

Let's say CPU is back to normal load. Is their any chance that third timeout could occur at t0+300ms (QTimer object realising it was late and trying to correct that by resynchronizing itself), or will it most likely timeout at t0+330ms?


回答1:


Per QTimer documentation :

All timer types may time out later than expected if the system is busy or unable to provide the requested accuracy. In such a case of timeout overrun, Qt will emit activated() only once, even if multiple timeouts have expired, and then will resume the original interval.

I'm not sure I understand this correctly but, apparently, it won't resynchronize itself and third timeout will occur at t0+330ms.



来源:https://stackoverflow.com/questions/34543745/is-qtimer-smart-enough-to-resynchronize-itself

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!