用QML播放动画SVG
问题描述:
我想用QML播放动画SVG文件。我已经尝试过AnimatedImage
,但SVG保持静态并且不是动画。用QML播放动画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
希望有所帮助。
感谢您的回答。 “AnimatedImage”和“QMovie”似乎并不支持(据我所知,支持动画SVG)。 'QMovie :: supportedFormats()'只返回GIF格式。我会看看'QSvgRenderer'。 – Sierra