我想用QML播放动画SVG文件。我已经尝试了AnimatedImage
,但SVG保持静态并且没有动画。
AnimatedImage {
id: loader
source: "qrc:/Assets/Images/loader"
height: 30
width: 30
}
任何建议都将受到高度赞赏,谢谢。
答案 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
希望有所帮助。