Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
4.7.3, 5.5.1
-
None
Description
As per bug https://bugreports.qt.io/browse/QTBUG-19563
The following code will cause the QGraphicsSvgItem to be rendered as binary.
#include <QApplication> #include <QGraphicsScene> #include <QSvgGenerator> #include <QGraphicsSvgItem> #include <QGraphicsScene> #include <QBuffer> #include <QDebug> #include <QPainter> int main(int argc, char *argv[]) { QApplication app(argc, argv); QBuffer b; QSvgGenerator p; p.setOutputDevice(&b); QPainter painter; painter.begin(&p); QGraphicsScene scene; auto item = new QGraphicsSvgItem("test.svg"); scene.addItem(new QGraphicsSvgItem(item); scene.render(&painter); painter.end(); qDebug() << QString(b.buffer()); return 0; }
For instance for the image given in attachment the resulting (bogus) svg output is :
<image x=\"-2\" y=\"-2\" width=\"3\" height=\"3\" preserveAspectRatio=\"none\" xlink:href=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAADCAYAAABWKLW/AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAHklEQVQImV3BsQ0AAAQAsMbmP/8v/sCuBdsSAozyHVpTA0DEkSTtAAAAAElFTkSuQmCC\" />
The output is correct if we add :
item->setCacheMode(QGraphicsItem::NoCache);
prior to rendering