How would you suggest to handle svg with QPixmap?
The construct QPixmap(":/myfile.svg");
then call of scaled()
does not work. The QPixmap gets pixelised.
Thx.
Now there is much simpler way without needing of SVG module
QIcon("filepath.svg").pixmap(QSize())
So simple and works fine. Atleast in my case it worked.
You should use SVGRenderer to render it onto a QImage
. From there you can convert to a QPixmap
with QPixmap::convertFromImage
.
Something like that:
QSvgRenderer renderer(svg_file_name);
QPixmap pm(width, height);
pm.fill(fill_color);
QPainter painter(&pm);
renderer.render(&painter, pm.rect());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With