PDA

View Full Version : Setting a scaled background image on a QGraphicsView (or QGraphicsScene)



truefusion
6th April 2009, 01:20
Looking at many methods and a lot of searching hasn't provided me with what i want. All my attempts include either a tiled image or no image with either a QPainter error or no error. Here's the code that produces no error, but also no image, that i currently have implemented:


QString file("/usr/share/wallpapers/default_blue.jpg");
int w = QApplication::desktop()->width();
int h = QApplication::desktop()->height();

desk *desktop = new desk(this); // QGraphicsView
desktop->setFrameStyle(QFrame::NoFrame);
desktop->setScene(new winManager(this));

QPixmap pic(file);
pic = pic.scaled(w, h);
QPainter painter(&pic);
desktop->render(&painter);

I'm not sure what i'm doing wrong, but the solution is most likely simple--assuming there is one.