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

6th April 2009, 02: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->setScene(new winManager(this));

QPixmap pic(file);
pic = pic.scaled(w, h);
QPainter painter(&pic);

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