Solved Widgets stealing mouse wheel focus from one another.
-
Here's a video of my app in action and you can see what happens when I mouse wheel:
I have a FlowLayout:
https://gist.github.com/Cysu/7461066
Containing a dynamic list of QGraphicsView widgets essentially. I have zoom capability on the customized QGraphicsViews using the mouseWheelEvent.
However, as you can see midway through the video, when you mouse wheel and your focused on an editor (view), then the FlowLayout also scrolls.
So essentially the event is being captured by two handlers. Whereas the desired behavior is that it should only zoom the editor.
Thanks.
If it helps, here is the complete source code which is rather clean and easy to navigate:
-
Solved it with this code added to my FlowLayout:
widget.removeEventFilter(self) def addWidget(self, widget): widget.installEventFilter(self) super().addWidget(widget) def eventFilter(self, watched, event): if event.type() == QEvent.Wheel: event.accept() return True return super().eventFilter(watched, event)