我想用 QML 播放动画 SVG 文件。我已经试过了 AnimatedImage
,但 SVG 保持静态并且没有动画。
AnimatedImage {
id: loader
source: "qrc:/Assets/Images/loader"
height: 30
width: 30
}
任何建议将不胜感激,谢谢。
最佳答案
检查支持的动画格式列表:
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
希望有帮助。
关于qt - 使用 QML 播放动画 SVG,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44286899/