In a subclass of QGraphicsView, I implemented the wheelEvent(event) event-handler as follow:
def wheelEvent(self, event):
print "Wheel event received"
event.ignore()
From what I understand, this should actually do little more than printing the above string. The QWheelEvent.ignore() should pass the event to the parent and go about its usual business (namely scrolling). The documentation is explicit about this:
If you reimplement this handler, it is very important that you ignore() the event if you do not handle it, so that the widget’s parent can interpret it.
In this case, the QGraphicsView is the main widget, so it has no parent (unless by parent one means the parent class from which it is derived).
In practice however, the string is printed as expected but the view does not scroll its content.
So how do I implement this method and get the QGraphicsView to scroll?
Well if you are never calling the main class, it will be pretty hard for the parent (and yes that’s the object you are inheriting from) to do anything, when would the code run?
Adding
super(type(self), self)should help (thanks to @mata for the correct python2 syntax)