GraphicView scaling (zoom in/out) limit using WheelEvent

86 Views Asked by At

I'm using wheelEvent in order to control the scale(in/out zoom) of an image in my python made application.

The zoom control works! and the self.scale(delta, delta) is controlling the scaling(if the image is getting smaller or bigger) and I want to understand how could I limit the scaling so the image will not be smaller then a specific range.

Some of the code is added below.

Thank you

from PyQt4 import QtGui
from PyQt4 import QtCore

class MyAppGraphicView(QtGui.QGraphicsView):

  def wheelEvent(self, event):

      delta = 0.99 if event.delta() < 0 else 1.01
      self.scale(delta, delta)
0

There are 0 best solutions below