title: Implementing zoom slider QGraphicsView
body: <p>I have a need to integrate a zoom slider for a <code>QGraphicsView</code> in Qt 4.x, I have a working implementation that goes something like this:</p>
  
  <pre><code>connect(slider, SIGNAL(valueChanged(int)), customGraphicsView, SLOT(setZoomLevel(int));
  </code></pre>
  
  <p>In the slot for <code>setZoomLevel</code> I have the following</p>
  
  <pre><code>void CustomView::setZoomLevel(int level)
  {
      if(zoomLevel - level &lt; -1){
          setZoomLevel(level - 1);
      }else if(level - zoomLevel &lt; -1){
          setZoomLevel(level + 1);
      }
      if(level &lt; zoomLevel){
          scale(1 - (scaleFactor * (zoomLevel - level)), 1 - (scaleFactor * (zoomLevel - level)));
      }else if (level &gt; zoomLevel){
          scale(1 + (scaleFactor * (level -  zoomLevel)), 1 + (scaleFactor * (level -  zoomLevel)));
      }
  
      zoomLevel = level;
  }
  </code></pre>
  
  <p>So my issue is stemming from mating a slider which has a value of n to m to represent a zoom level to the <code>scale()</code> function of <code>QGraphicsView</code>, which takes two floating point values to multiply the scene by to get a new size.</p>
  
  <p>So the problem I'm having is, if you take 1 * .9 * 1.1 you do not still get 1 but instead .99, its off slightly because it isn't a correct formula. So my max zoom gets smaller and smaller over time.</p>
  
  <p>The recursive calls are because the slider would sometimes skip values on fast slides, which increased the "error", so I smoothed it out to bandage it a little.</p>
  
  <p>Is there a correct way of handling zooms?</p>