title: Zooming and panning an image in a QScrollArea
body: <p>I have created a preview that shows a rendered image. I used the <a href="http://doc.qt.io/qt-5/qtwidgets-widgets-imageviewer-example.html" rel="noreferrer">Image Viewer Example</a> for zooming functionality - so I have a class inheriting <code>QScrollArea</code>, capable of showing an image, in a <code>QLabel</code>, and zooming in/out/fit with specific limits. I was showing scrollbars "as needed".</p>
  
  <p>As a new requirement, I must be able to do <strong>panning</strong>, and <strong>not show scrollbars</strong>.</p>
  
  <p>I have been looking for ways to do it - and found <a href="http://www.qtcentre.org/archive/index.php/t-10462.html" rel="noreferrer">examples</a> of people using mouse press, move and release events to relate a point on the image to scrollbars.<br>
  The problems:<br>
  1) the direction of move, if scrollbars are invisible, is unexpected - in panning he object moves in the direction of the mouse (stays under mouse), while scrollbars move in the opposite direction<br>
  2) I think the move is limited to scrollbar size so... if I calculate a reverse move, I would hit a wall while still have room to move in one direction<br>
  3) This would not work with zooming, which is exactly when the panning is needed; more complex calculations would be needed.</p>
  
  <p>I could alternately use a <code>QGraphicsView</code>, and </p>
  
  <pre><code>setDragMode(ScrollHandDrag);
  </code></pre>
  
  <p>It would work nice with zooming as well, and I would not have to implement it myself.<br>
  The reason I have not done this yet is, I would need to add a <code>QGraphicsScene</code> as well, and a <code>QGraphicsPixmapItem</code> containing the image I want - then find how to disable all mouse events other than panning - and still use a <code>QScrollArea</code> to hold the <code>QGraphicsView</code>;<br>
  It seems it is too much overhead (and this is meant to be extremely light-weight, for an embedded device with little speed and memory).</p>
  
  <p>What is the best option ? is there some way I can pan a zoomed image in a viewer, as light weight as possible ?</p>