Qt event flow using QGraphicsScene and embedded widgets

Hi all,
I’ve encountered unintuitive behaviour when trying to route events through widgets embedded in a QGraphicsScene, via QGraphicsProxyWidget. See a simple demonstration of the effect here: Showing unintuitive event flow when embedding widgets in QGraphicsScene · GitHub

In short, when you click anywhere on a QGraphicsView (including on an embedded widget), the View and the Scene always receive the event first, before passing it to the desired widget. The event types seem the same, and I can’t find an event equivalent of sender() .

This means that in the View method, there is no way to know which mouse events are desired for the view itself (selection, dragging etc), and which are desired for widgets within it.

How on earth should this be solved?

Can you get the widget under the cursor when clicked: qt - Get all widgets under cursor - Stack Overflow

Hey, it turns out you can - but in the process of testing I realised I had forgotten the call to scene.addItem() on the proxy widget, and to parent the embedded widget properly. I updated the snippet, and now the event chain makes more sense. Thanks

Yeah embedding widgets in a graphics scene is quite long winded and arguably over complex.
Glad you got it sorted :slight_smile: