PDA

View Full Version : mouseMove Event



fruzzo
3rd March 2008, 11:22
Hi,
I've a problem with mouseMoveEvet reimplementation. I've a class called myMainWindow witch inherit from QWidget and I reimplement it's mouseMoveEvent to know every time the position of the mouse on the screen. I set for it's istance the setMouseTracking(true).
The myMainWindow mainWindow istance has 3 child ( each has several widget inside) in a grid layout so my mouseMoveEvet don't work. It works only in the space between two child. I think that the solution is to set setMouseTracking for all the widgets on the screen but it requires a lot of work.
Is there a way to say to all child of mainWindow to tracking the mouse move event?

wysota
3rd March 2008, 11:48
Your problem is that first an event is delivered to the "youngest" (in parent-child relationship) widget occupying a particular coordinates. Only if this widget ignores the event, it will propagate to the widget's parent eventually reaching your widget where you monitor for mouse moves. So you have basically two choices if any of your child widgets handle the events themselves - either reimplement their mouse event handlers and explicitely ignore events or install an event Filter (see QObject::eventFilter for details) on each child and handle the event in the filter (remember to return false if you want the event to reach the target it was originally meant for).