I have this simple SVG:
<svg id="smaller" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 120 120" width="120" height="120">
<defs>
<style>
.color-1 {
stroke: #000000;
fill: none;
}
</style>
</defs>
<rect class="color-1" x="25" y="10" width="70" height="100" stroke-width="6" />
<line class="color-1" x1="35" y1="100" x2="85" y2="20" stroke-width="5" />
<path class="color-1" d="M 35 85 v 15 l 13 -6.4" stroke-width="5" />
<path class="color-1" d="M 85 35 v -15 l -13 6.4" stroke-width="5" />
</svg>
It renders properly in any browser I tested. However, when I try to render it with QSvgRenderer, I get an empty image:
QFile file(path);
file.open(QIODevice::ReadOnly | QIODevice::Text);
QByteArray svgSource = file.readAll();
file.close();
QImage buffer({120, 120}, QImage::Format_ARGB32);
buffer.fill(Qt::transparent);
QSvgRenderer renderer(svgSource);
QPainter svgPainter(&image);
renderer.render(&svgPainter);
I noted that if I set stroke="#000000" on each element instead of the CSS, it works. Does QSvgRenderer not support the CSS stroke attribute? It does seem to support fill:.
I'm on Qt 5.15.10.