Passing all mouse events from child to parent
-
I have a QWidget with a layout where I add QWindow subwidgets created by
QWidget::createWindowContainer.
I want all mouse events to be processed by the parent.
Currently I have to override the methods in the QWindow derived class and explicitly send them to the parent, bus is there a simpler method to cover all events?Regards
-
you can use eventFilters for such a task:
https://doc.qt.io/qt-5/qobject.html#installEventFilter -
Thanks, I'll have a look at that.
For some reason it seemed to work out of the box for regular QWidget types, is this normal?
-
Ok, I now tried calling childWidget->installEventFilter(this) in the constructor of the parent widget. Also on the wrapped window directly. The parent does not receive events.
-
QWidget doesn't really implement eventFilter method, right? Is implementing it on the parent and then just calling event() the right way?
-
Apparently the QWindowContainer that createWindowContainer creates does receive the events the wrapped QWindow receives out of the box. Does anyone know how this class does it?