可以为超平滑动画增加QPropertyAnimation更新间隔吗?

时间:2010-07-28 20:37:39

标签: qt animation qt4

Qt 4.6+中的新动画框架基于QTimeLine,它具有'void setUpdateInterval(int interval)'公共函数。基于QTimeLine,QGraphicsItemAnimation可以访问这个函数,但是新的动画框架类(例如QPropertyAnimation)不能!动画框架是否锁定为每秒约60次更新,这对应于每秒仅在屏幕上60像素的逐像素转换(对于QPropertyAnimation动画位置属性)或者有没有办法在不重新实现所有内容的情况下增加此值? / p>

2 个答案:

答案 0 :(得分:0)

我认为有一些硬件限制,以及OS / Qt如何处理部分绘画的一些限制。 Qt主循环也与它有关。

根据我的经验,双缓冲和重新绘制仅需要重新绘制的区域将为您提供所需的更流畅的动画。还要确保您的图形接近实际绘制它们的大小。增加刷新间隔对大多数监视器没有帮助,因为它们的刷新速度不会超过60 Hz。

这是link,可能会有所帮助。

Qt努力优化并使图形在许多平台上看起来不错,而且我知道在准备Qt 5时,光栅引擎的工作方式会有一些变化。

我还亲眼看到了类似于所讨论的here的演示,他们展示了在游戏中使用绘画瓷砖每秒刷新的帧数。这是一个video讨论它的链接。它会调整Qt对特定游戏实现的性能,以及有什么帮助,有什么不可用。

答案 1 :(得分:0)

这是我对Qt 4.8的解决方案:

// You need qt source code to access QUnifiedTimer for QAnimationDriver
// Alternatively, copy'n'paste only the declaration for QUnifiedTimer class.
#include <qt/src/corelib/animation/qabstractanimation_p.h>

...

// In the animation thread, set the update timing interval.
// The smaller the interval, the more updates and more CPU consumption.
int animationTimingInterval = update_interval_in_msecs_u_want;
QUnifiedTimer::instance()->setTimingInterval(animationTimingInterval);
相关问题