QPixmap and SVG

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.

thank.

+2
qt svg qpixmap
Apr 09 2018-12-12T00:
source share
3 answers

You must use SVGRenderer to display it on a QImage . From there you can convert to QPixmap using QPixmap::convertFromImage .

+5
Apr 09 '12 at 20:12
source share

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.

+9
Apr 29 '16 at 10:42 on
source share

Something like that:

 QSvgRenderer renderer(svg_file_name); QPixmap pm(width, height); pm.fill(fill_color); QPainter painter(&pm); renderer.render(&painter, pm.rect()); 
+3
Jul 30 '14 at 6:22
source share



All Articles