PDA

View Full Version : Filtering Events on "black-box" objects



sebastian.f
11th June 2009, 16:01
Hello,

I have another mouse propagation question, this time with a twist! ;)

I have a set of Widgets enclosed in DLLs that are loaded by my application, and I want to monitor all mouse activity, i.e. when the user clicks one my main application intercepts it first to check it before passing it on.

However, the enclosed objects arn't necessarily QWidgets, and they may be made up of a number of QWidgets themselves.

Would an event filter work if I installed it just on the parent widget passed by the exported constructor? Or would this only intercept events to that widget and the child ones created by it (which my application has no knowledge of) continue to receieve events unhindered?

Thanks!

SABROG
11th June 2009, 19:10
You must recursively run installEventFilter on all childs of childs etc. Try use method QObject::children().

nish
12th June 2009, 04:13
use qApp->installEventFilter(this).

this way u can moniter everything

sebastian.f
12th June 2009, 08:35
Thanks for your replies!

I've tried to make the event filter process as simple as possible and so tried installing an event filter on the main application, and it works brilliantly.

Thank you very much, I thought I was going to have to end up redesigning the whole thing!