How to identify QEvent sender

2.1k Views Asked by At

I have reimplemented QWidget::event() handler, where I am handling windowStateChange event. I was wondering if there is any way to identify which widget sends this event.

2

There are 2 best solutions below

2
Arnold Spence On

That event is generated when a window is minimized, maximized or full-screened so you should only see it from within the widget to which it applies.

0
Kuba hasn't forgotten Monica On

No, there's no way to do that, because posting or sending a QEvent does not require a QObject instance. When you post an event, it's done via a static QCoreApplication method, and it doesn't ask who's sending the event. Heck, it'd be counterproductive, because a useful way of interoperation between Qt and other event-driven code is to do event translation and post the events to the Qt side of things. The posting code may be an extern "C" function.