PDA

View Full Version : Loading SVG icons



user_mail07
30th May 2007, 18:13
I need to load .svg icons to application. Do I have to use QSvgWidget class? Something similar to the following that I was using to load PNG files. I am using qt ver 4.2.3.

QPixmap pixmap;

QMap<QString, QPixmap> mapPix;


pixmap.load("PNG");
mapPix.insert("PNG",pixmap);


Thanks a Lot!!

marcel
30th May 2007, 19:18
You could use QSvgRenderer and render a svg to a pixmap.
Something like:


QSvgRenderer svgRenderer( somesvgfile );
QPixmap pix( svgRenderer.defaultSize() );
QPainter pixPainter( &pix );
svgRenderer.render( &pixPainter );


Not sure how you would handle an animated svg. Maybe extract some frames from it.

Regards

matheww
28th June 2007, 04:12
I have used svg for icons,, i have the svg files in my resouce and use..

QIcon icon(":/path/to/svgfile.svg");

then the icon can be returned for the models, the designer allows the icons to be added from the resource to actions..

:)