c++ - Qt定时器问题

标签 c++ qt4 timer

我有一个定时器,它的滴答时间是 100。但它滴答 125 毫秒。所以我将滴答时间从 100 减少到 80,但我仍然再次滴答大约 125 毫秒。这个计时器在主线程中。我怎么解决这个问题?我会打开任何建议。 任何帮助将不胜感激。

最佳答案

参见 http://doc.qt.nokia.com/4.2/qtimer.html

.... a timer cannot fire while your application is busy doing something else. In other words: the accuracy of timers depends on the granularity of your application.

Note that QTimer's accuracy depends on the underlying operating system and hardware. ... If Qt is unable to deliver the requested number of timer clicks, it will silently discard some.

注意:一些旧版本的 Qt 使用其他 api,精度为 20-50ms。

所有非实时操作系统都不能保证休眠时间,这取决于您的 CPU 功率和系统的性能,您永远不应该依赖它。

关于c++ - Qt定时器问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4666263/

相关文章:

C++14 函数式 logical_not 函数

css - 如何使用 Qt4 样式表激活 Alpha channel ?

c++ - 打开文件有问题

windows - Qt4 widget 在 windows 上的放置

java - 使用 ScheduledExecutorService 启动和停止计时器

javascript - RxJ 和 switchMap

c++ - 具有继承性的多线程 (C++)

c++ - Visual Studio 2012 支持哪个 XP 版本 [As Target OS]

c# - 在 C# Windows 窗体中使用计时器停止并重复过程

c++ - 异常没有被捕获