使用Qt动画框架的QPixmap的波涛汹涌滚动 [英] Choppy scrolling of QPixmap using Qt Animation Framework
问题描述
我创建 QPropertyAnimation
,并将其连接到我的 SonogramWidget
,关于动画事件垂直滚动很长的画面。在'长期图片是由100 pre计算的QPixmap对象的放置1024x128陆续垂直。他们用的QPainter
显示在 SonogramWidget ::的paintEvent()
。绘图程序漆并不是所有的的QPixmap
一次,但只看到他们,考虑到小部件的高度和当前的垂直偏移。 CPU几乎是免费的,因为的QPixmap
是显示图片的最快方式。目前在滚动过程中没有什么大的计算,因为所有的100 QPixmaps
是pre计算和存储在内存中。
I created QPropertyAnimation
and connected it to my SonogramWidget
that scroll a long picture vertically on animation events. The 'long picture' is composed of 100 pre-calculated QPixmap objects 1024x128 placed one after another vertically. They displayed in SonogramWidget::paintEvent()
with QPainter
. Drawing procedure paint not all QPixmap
at once, but only visible of them, considering widget height and current vertical offset. CPU is almost free, because QPixmap
is a fastest way to display a picture. There is no big calculations during scrolling, because all the 100 QPixmaps
are pre-calculated and stored in memory.
我见奇效:脉动运动:2次第二,整个图像略有加快,并比平时快的运动像素1..2向上移动。同样的效果,当我与一个60 fps的QTimer取代Qt的动画框架,并在其SLOT滚动图像。
I see strange effect: pulsating movement: 2 times a second the entire image slightly speed-up and moves up by 1..2 pixels faster than usual motion. The same effect when i replace Qt Animation Framework with single 60 fps QTimer and scroll the image in its SLOT.
视频: http://www.youtube.com/watch?v= KRk_LNd7EBg#T = 8 (从00:08手表,我的Firefox增加了更多的砧板视频播放本身,谷歌Chrome播放视频要好得多)
Video: http://www.youtube.com/watch?v=KRk_LNd7EBg#t=8 (watch from 00:08; My firefox adds more chopping to video playing itself, google chrome plays the video much better).
我看到我的Linux和Windows版本相同的效果。
I see the same effect for my Linux and Windows build.
SOLUTION
我想通了这个问题了:斩是不是一个错误,是一个功能!它是整数数计算的特征,所以有时候我们不得不对动画不同的号码,如:16,16,16,16,16,16, 17
, 16,16,16,16,16, 17
....
SOLUTION
i figured out the issue: the "chopping" was not a bug, it was a feature! It is a feature of integer-number calculations, so sometimes we had to have different numbers for animations, like: 16,16,16,16,16,16,17
,16,16,16,16,16,17
,....
推荐答案
在的paintEvent
添加以下断言:
Q_ASSERT(m_animation->currentValue() == m_animatedPropertyValue);
如果它触发,那么你知道你必须使用的属性值,而不是 CurrentValue的()。这可能是这种情况。让我知道了。
If it triggers, then you know you must use currentValue()
instead of the property value. This might be the case. Let me know.
这篇关于使用Qt动画框架的QPixmap的波涛汹涌滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!