PDA

View Full Version : How use svg to set QWidget background



sanjayshelke
29th June 2009, 11:41
Hi,

I want to change widget background to a svg.
I know how to set images to background of the widget.

Any help on this.

Regards,
~Sanjay

SABROG
29th June 2009, 11:55
Something like this:



QSvgRenderer svg("myfile.svg");
QImage img(100, 100, QImage::Format_ARGB32);
img.fill(0);
QPainter painter(&img);
svg.render(&painter);


and after paint QImage to widget. Or use QSvgWidget

I think you can also use QPixmap("file.svg") for use svg icon plugin.

sanjayshelke
29th June 2009, 12:47
Ok.
That can be possible.

Can i do something like this.

MyWindow: piblic QMainWIndow, public QSvgWidget


i.e inherting mywindow from both the QMainWindow and QSvgWidget.

I know this is possible, but compiler gives the warning as QMainWIndow and QSvgWidget are derived from QWidget.

Regards,
~Sanjay