Всем привет
Есть код
C++ (Qt)
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
svg = new QSvgRenderer(QString("alarm.svg"),this);
if (svg->animated())
qDebug() <<"svg->animated: true";
else
qDebug() << "svg->animated: false";
qDebug() << svg->framesPerSecond();
}
MainWindow::~MainWindow()
{
svg->~QSvgRenderer();
delete ui;
}
void MainWindow::paintEvent(QPaintEvent * paintEvent)
{
QPainter painter(this);
painter.save();
svg->render(&painter,this->rect());
painter.restore();
// painter.end();
}
И файл alarm.svg
с кодом
XML
<?xml version="1.0" standalone="no"?>
<svg width="12cm" height="4cm" viewBox="0 0 1200 400" xmlns="http://www.w3.org/2000/svg" version="1.1">
<rect x="400" y="100" width="400" height="200" fill="yellow">
<animate attributeName="opacity" attributeType="CSS" from="0" to="1" begin="0s" dur="10s" repeatCount="1" />
<animate attributeName="x" attributeType="XML" from="400" to="500" begin="0s" dur="10s" repeatCount="1" />
<animate attributeName="fill" attributeType="XML" from="yellow" to="red" begin="10s" dur="10s" repeatCount="1" />
<animate attributeName="x" attributeType="XML" from="500" to="400" begin="10s" dur="10s" repeatCount="1" />
<animate attributeName="opacity" attributeType="CSS" from="1" to="0" begin="10s" dur="10s" repeatCount="1" />
</rect>
</svg>
Как видите тут указанна анимация, но она не происходит