Propagate mouse event from Widget over QGraphicsView to QGraphicsView
-
I'm working on a project that has a QWidget (containing a stacked layout with widgets in each stacked Widget) over a QGraphicsView and want mouse events to pass to the QGraphicsView when the event is not over an interactive widget (combobox, button, etc.). For the overlying widgets, I reimplemented the mousePress/Move/Release events with just
event->ignore()
which I thought was supposed to pass the event to its parent. What seems to be happening (observed via GammaRay) is the event goes to the Stacked Widget then to the Widget containing the Stacked Layout (which is a child of the QGraphicsView) but stops there. How do I get it to continue to the QGraphicsView? AddingQt::WA_TransparentForMouseEvents
attribute to the overlying widget prevents any interaction with its child widgets, so that is not a solution for me. -
Hi,
Is the widget part of the Graphics View ?
-
Probably not the cleanest solution, but a workaround would be to use an eventFilter. The QGraphicsView could call
widgetName->installEventFilter(this)Then in the QGraphicsView, you override the method "eventFilter". That should receive the event originally destined to your widget. Be careful, handling event coordinates can be a bit messy.