Your QGraphicsView
and QGraphicsScene
instance are local variable, they will be destroyed when out of the MainWindow
constructor scope.
please try it like this.
QGraphicsScene *scene = new QGraphicsScene(this);
QGraphicsView *view = new QGraphicsView(scene);
If it still does't work, please check your QPixmap
file is null or not just like what @Wagmare say.