[Interest] About event filter on QApplication

Bo Thorsen bthorsen at ics.com
Mon Nov 4 07:28:08 CET 2013

You miss Thiagos point. It doesn't make any sense to try and document 
behaviour for something you shouldn't do. Imagine the size of the docs, 
if they should say "if you write this broken code, here's what will 
happen. If you write this...". Your code is broken so there is no 
interest in finding the difference between Qt 4 and 5 behaviour with it.

And BTW, you should install the event filter on the label instead of on 
QApplication and check if the object is the label.


Den 04-11-2013 02:04, 程梁 skrev:
> Thank you, Thiago!
> Yeah, I know return true is not clever. This is a demo code in my Qt
> text. Someone commented me the differences between Qt4 and Qt5 if return
> true. I guess the same reason as  you mentioned in last mail. This might
> because the different processes between the two versions which the
> documents didn't point out. I just wonder if this is right or I missed
> some docs.
> Thank you anyway!
> Cheng Liang
> Nanjing, China
> http://www.devbean.net
> From: thiago.macieira at intel.com
> To: interest at qt-project.org
> Date: Sun, 3 Nov 2013 08:28:16 -0800
> Subject: Re: [Interest] About event filter on QApplication
> On domingo, 3 de novembro de 2013 15:21:09, 程梁 wrote:
>> As you could see, I installed a global event filter on QApplication. Note
>> that I have returned true in the filter which means all events should stop
>> processing. In Qt4, the output ("QApplication::eventFilter") will still
>> there but with Qt5 nothing outputs. This might because watched and
>> m_watched is not the same (QWidgetWindow). But when I changed to return
>> false as default code, the output is there again. Maybe in Qt5 the return
>> value also changes watched objects? I cannot find any documents about this.
>> Could you help me? Thank you!
> Returning true for all events is a stupid idea. You're blocking ALL events,
> including those that Qt needs working in order to make your functionality
> work.
> So my conclusion is that you blocked some event that was a precursor to the
> event sent to the label.
> --
> Thiago Macieira - thiago.macieira (AT) intel.com
>    Software Architect - Intel Open Source Technology Center
> _______________________________________________ Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest

Bo Thorsen, European Engineering Manager, ICS
Integrated Computer Solutions. Delivering World-Class Applications

More information about the Interest mailing list