title: Qt Graphics View , show image ! , Widget
body: <p>Here is my code :</p>
  
  <pre><code>void MainWindow::on_actionOpen_Image_triggered()
  {
      QString fileName = QFileDialog::getOpenFileName(this,"Open Image File",QDir::currentPath());
  
      if(!fileName.isEmpty())
      {
          QImage image(fileName);
  
          if(image.isNull())
          {
              QMessageBox::information(this,"Image Viewer","Error Displaying image");
              return;
          }
  
          QGraphicsScene scene;
          QGraphicsView view(&amp;scene);
          QGraphicsPixmapItem item(QPixmap::fromImage(image));
          scene.addItem(&amp;item);
          view.show();   
      }
  </code></pre>
  
  <p>}</p>
  
  <p>I want to display image from file, code works fine but image disappiars very fast.</p>
  
  <p>How can I pause image screen?</p>
  
  <p>And how can I load image in "graphicsView"  widget?</p>
  
  <p>My code:</p>
  
  <pre><code>void MainWindow::on_actionOpen_Image_triggered()
  {
      QString fileName = QFileDialog::getOpenFileName(this,"Open Image File",QDir::currentPath());
  
      if(!fileName.isEmpty())
      {
          QImage image(fileName);
  
          if(image.isNull())
          {
              QMessageBox::information(this,"Image Viewer","Error Displaying image");
              return;
          }
  
          QGraphicsScene scene;
          QGraphicsPixmapItem item(QPixmap::fromImage(image));
          scene.addItem(&amp;item);
  
          ui-&gt;graphicsView-&gt;setScene(&amp;scene);
          ui-&gt;graphicsView-&gt;show();    
      }
  }
  </code></pre>
  
  <p>It does not work.</p>
  
  <p>How to fix this?</p>