You have not set the sceneRect for QGraphicsScene....
image
= new QImage(data.
absoluteFilePath());
// variable data is defined when calling this method and object image is defined as QImage in header // scn->setSceneRect(ui->graphicsView->Rect()); // SOMETHING LIHE THIS
ui->graphicsView->setScene(scn);
scn
->addPixmap
(QPixmap::fromImage(*image
));
ui->graphicsView->fitInView(scn->itemsBoundingRect(),Qt::KeepAspectRatio);
image = new QImage(data.absoluteFilePath()); // variable data is defined when calling this method and object image is defined as QImage in header
scn = new QGraphicsScene(this); // object defined in header
// scn->setSceneRect(ui->graphicsView->Rect()); // SOMETHING LIHE THIS
ui->graphicsView->setScene(scn);
scn->addPixmap(QPixmap::fromImage(*image));
ui->graphicsView->fitInView(scn->itemsBoundingRect(),Qt::KeepAspectRatio);
To copy to clipboard, switch view to plain text mode
Bookmarks