PDA

View Full Version : Forwarding mouse events to another widget.



yogeshm02
26th February 2006, 11:48
Hi

I have two widgets A & B, A is shown above B. I want that widget B forward all mouse events to widget B. Can this be done? Hints please.

Oops, looks like I have presented to you a very simplified version of my problem. Actually, I have a stack of widgets and the top most widget which receives mouse events must forward this event to the top-most widget (at a given mouse position) under this widget. Got it?

With regards

jacek
26th February 2006, 13:50
Try event filters.

yogeshm02
26th February 2006, 14:11
Try event filters.
The problem is how to find the top-most widget under the current widget. (That too quickly, as even mouse move events will be forwarded with mouse tracking on)

wysota
26th February 2006, 14:52
Does "under" represent a geometry or parent-child relation?

yogeshm02
27th February 2006, 13:42
Does "under" represent a geometry or parent-child relation?
I need to manipulate it in geometry, but they must be a part of single top-level window.

I am working on a skinnable interface in which I have an widget named GLayer which displays any image with alpha content so that the contents of widgets below it are seen through i.e. GLayer does not do anything and needs to forward events meant for the widgets below to the respective widget.

Two screenshots attached, one with and other without GLayer, will help you understand.

wysota
27th February 2006, 13:58
Ok... so keep a list of all widgets (QObjectList for example) and iterate through that list checking each ones coordinates until you find the one that fits you most.

yogeshm02
27th February 2006, 14:05
Ok... so keep a list of all widgets (QObjectList for example) and iterate through that list checking each ones coordinates until you find the one that fits you most.
I load all data from a xml file so I already have a list of all top level widgets as well as all widgets. It can easily be found which widget lies in the area, but seems that finding one which is one-step down from the top is tricky.

EDIT: -
QApplication has following method:

QWidget * widgetAt ( const QPoint & point )

Even this seems to return top most widget having the given point.

jacek
27th February 2006, 17:00
Maybe you could just draw that pixmap without using the GLayer widget?

yogeshm02
28th February 2006, 13:25
Maybe you could just draw that pixmap without using the GLayer widget?
Now, that would be extremely difficult to manage as the interface is being designed to be skinnable as well as scriptable.
I've two rough ideas in my mind which ill try out.

Two important points to notice are:-
1. Widget which is initialised last is always at the top (Could not found any proof for this, just observation)
2. As i've a scriptable interface, i am providing wrappers to all the custom widgets, so I can use them to monitor any changes in the z-order.