小编a_m*_*_67的帖子

为什么QtSvg中的动画元素需要为animateTransform类型才能工作?

为了在我的应用程序中显示SVG绘图,我使用GtGui.QgraphicsView,QtGui.QgraphicsScene,QtSvg.QgraphicsSvgItem。因为QsvgRenderer支持动画SVG绘图,所以我在SVG文件中集成了一些动画元素,例如:

<circle cx="x" cy="x" r="z" class="style">
<animate attributeName="r" attributeType="XML" 
from="0"  
to="z"
begin="0s" 
dur="2s"
fill="remove" 
restart="always" 
repeatCount="indefinite"
end="indefinite"
/>
</circle>
Run Code Online (Sandbox Code Playgroud)

在Firefox中,圆圈按预期方式运行,在QgraphicsView中,他未设置动画。

所以我尝试了“ animateTransform”:

<circle cx="x" cy="x" r="z" class="style">
<animateTransform attributeName="transform" type="translate"
begin="0" 
dur="2s" 
from="x y" to="0 0" 
... 
additive="sum"
/>
<animateTransform attributeName="transform" type="scale" 
begin="0" 
dur="2s" 
from="0" to="1" 
…
additive="sum"
/>
</circle> 
Run Code Online (Sandbox Code Playgroud)

它可以在QgraphicsView和Firefox中使用。我的问题已解决,但我想了解它。谁能解释这种行为?

补充:QSvgRenderer.animated()在第一种情况下返回FALSE,在第二种情况下返回TRUE。

2014年1月5日编辑:首先,我在Linux(Ubuntu 13.10)上使用了Python 3.3,Qt 4.8和PyQt 4.10.4,升级到Ubuntu 14.04后,我尝试了Python 3.4,Qt 5.2.1和PyQt 5.2.1(因为从Qt 4.8到5.2是应用程序代码中必要的一些修改,但不是svg-files中的xml代码),QgraphicsView的行为在两个版本中都是相同的。

animation qt svg qtsvg

5
推荐指数
0
解决办法
1497
查看次数

标签 统计

animation ×1

qt ×1

qtsvg ×1

svg ×1