Passing all mouse events from child to parent
-
wrote on 11 May 2021, 08:30 last edited by
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
-
wrote on 11 May 2021, 08:37 last edited by
you can use eventFilters for such a task:
https://doc.qt.io/qt-5/qobject.html#installEventFilter -
wrote on 11 May 2021, 08:41 last edited by
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?
-
wrote on 11 May 2021, 09:29 last edited by
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.
-
wrote on 11 May 2021, 09:51 last edited by
QWidget doesn't really implement eventFilter method, right? Is implementing it on the parent and then just calling event() the right way?
-
wrote on 11 May 2021, 11:03 last edited by
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?
1/6