开发者

How to identify QEvent sender

开发者 https://www.devze.com 2023-04-05 07:28 出处:网络
I have reimplemented QWidget::event() handler, where I am handling windowStateChange event. I was w开发者_StackOverflow中文版ondering if there is any way to identify which widget sends this event.No,

I have reimplemented QWidget::event() handler, where I am handling windowStateChange event. I was w开发者_StackOverflow中文版ondering if there is any way to identify which widget sends this event.


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.


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

精彩评论

暂无评论...
验证码 换一张
取 消