使用QML播放动画SVG

时间:2017-05-31 14:01:47

标签: qt svg qml

我想用QML播放动画SVG文件。我已经尝试了AnimatedImage,但SVG保持静态并且没有动画。

AnimatedImage {
      id: loader
      source: "qrc:/Assets/Images/loader"
      height: 30
      width: 30
}

任何建议都将受到高度赞赏,谢谢。

1 个答案:

答案 0 :(得分:1)

查看支持的动画格式列表:

http://doc.qt.io/qt-5/qml-qtquick-animatedimage.html#details

http://doc.qt.io/qt-5/qmovie.html#supportedFormats

所以在qDebug添加main.cpp行:

#include <QDebug>
#include <QMovie>
// ...
qDebug() << "Supported animated file formats:" << QMovie::supportedFormats();

如果QMovie不支持,您可能需要依赖QSvgRenderer

http://doc.qt.io/qt-5/qsvgrenderer.html#details

http://doc.qt.io/qt-5/qsvgrenderer.html#animated

希望有所帮助。