QPixmap and SVG

青春壹個敷衍的年華 提交于 2019-12-04 18:27:39

You should use SVGRenderer to render it onto a QImage. From there you can convert to a QPixmap with QPixmap::convertFromImage.

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.

Something like that:

QSvgRenderer renderer(svg_file_name);
QPixmap pm(width, height);
pm.fill(fill_color);
QPainter painter(&pm);
renderer.render(&painter, pm.rect());
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!