title: Display image on whole QGraphicsScene in Qt
body: <p>I want the graphics scene to show image that covers it whole. I create the scene with same size as an image, but get this result:</p>
  
  <p><a href="https://i.stack.imgur.com/PIptW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PIptW.png" alt="enter image description here"></a></p>
  
  <p>Could you please suggest what is wrong with the code? Thanks</p>
  
  <pre><code>MainWindow::MainWindow(QWidget *parent) :
      QMainWindow(parent),
      ui(new Ui::MainWindow)
  {
      ui-&gt;setupUi(this);
  
      QGraphicsPixmapItem * image = new QGraphicsPixmapItem(QPixmap("C:\\data\\99.png"));
      int imageWidth = image-&gt;pixmap().width();
      int imageHeight = image-&gt;pixmap().height();
      image-&gt;setOffset(- imageWidth / 2, -imageHeight / 2);
      image-&gt;setPos(0, 0);
  
      QGraphicsScene *scene = new QGraphicsScene();
      scene-&gt;setSceneRect(-imageWidth / 2, -imageHeight / 2, imageWidth, imageHeight);
      QGraphicsView * gv = new QGraphicsView();
      ui-&gt;gridLayout-&gt;addWidget(gv);
      gv-&gt;setScene(scene);
  
      qInfo()&lt;&lt;"width image " &lt;&lt;imageWidth; // 640
      qInfo()&lt;&lt;"height image " &lt;&lt;imageHeight; // 400
      qInfo()&lt;&lt;"width scene " &lt;&lt;scene-&gt;width(); // 640
      qInfo()&lt;&lt;"height scene " &lt;&lt;scene-&gt;width(); // 400
      gv-&gt;scene()-&gt;addItem(image);
      gv-&gt;show();
  
  }
  </code></pre>