How do you suggest handling svg with QPixmap?
QPixmap(":/myfile.svg"); construct QPixmap(":/myfile.svg"); , then the call to scaled() does not work. QPixmap gets pixels.
QPixmap(":/myfile.svg");
scaled()
thank.
You must use SVGRenderer to display it on a QImage . From there you can convert to QPixmap using QPixmap::convertFromImage .
QImage
QPixmap
QPixmap::convertFromImage
Now there is a much simpler way without using the SVG module
QIcon("filepath.svg").pixmap(QSize())
It just works so well. At least in my case it worked.
Something like that:
QSvgRenderer renderer(svg_file_name); QPixmap pm(width, height); pm.fill(fill_color); QPainter painter(&pm); renderer.render(&painter, pm.rect());