title: Get visible rectangle of QGraphicsView?
body: <p>I've been pulling my hair out with this one for hours. There's a thread <a href="http://www.qtcentre.org/forum/f-newbie-4/t-how-to-get-the-visible-rect-of-a-qgraphicsview--16541.html" rel="noreferrer">here</a> about it, but nothing seems to be working. QGraphicsView::rect() will return the width and height, but the <code>left</code> and <code>top</code> values aren't set properly (always 0 -- ignoring the scrolled amount). I want it in scene coordinates, but it should be easy enough to translate from any system. I have no idea what <code>horizontalScrollBar()-&gt;value()</code> and vert are returning...seems to be meaningless jibberish.</p>
  
  <hr>
  
  <p>@<a href="https://stackoverflow.com/users/121687/fabriziom">fabrizioM</a>:</p>
  
  <pre><code>// created here
  void EditorWindow::createScene() {
      m_scene = new EditorScene(this);
      m_view = new EditorView(m_scene);
      setCentralWidget(m_view);
      connect(m_scene, SIGNAL(mousePosChanged(QPointF)), this, SLOT(mousePosChanged(QPointF)));
  }
  
  /// with this constructor
  EditorView::EditorView(QGraphicsScene* scene, QWidget* parent) : QGraphicsView(scene, parent) {
      setRenderHint(QPainter::Antialiasing);
      setCacheMode(QGraphicsView::CacheBackground);
      setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
      setDragMode(QGraphicsView::NoDrag);
      scale(1.0, -1.0); // flip coordinate system so that y increases upwards
      fitInView(-5, -5, 10, 10, Qt::KeepAspectRatio);
      setInteractive(true);
      setBackgroundBrush(QBrush(QColor(232,232,232), Qt::DiagCrossPattern));
  }
  </code></pre>