PDA

View Full Version : Determining when mouse over widget without events



Kimmo
7th November 2007, 08:15
I have an application in which I have a settings dialog. The dialog is application modal. The dialog is composed of a tabbed widget.

In the dialog I have the usual stuff; QLabels, QComboBoxes, QPushButtons, QLineEdits. I also have an empty space in the dialog consisting of a QLabel. What I want to do is this: When the mouse cursor enters an object area (QLabel, QPushButton etc...), I would like the empty QLabel space to show the whatsThis of the object.

I wouldn't want to derive my own classes for all the objects in the dialog just to be able to implement enterEvent() and leaveEvent(). So is there another "easy" way to go about this? I guess I could probably somehow keep track of the mouse movements and constantly test whether the mouse is inside which widget, but that certainly doesn't seem like a simple solution.

marcel
7th November 2007, 08:21
See QWidget::underMouse(). You could reimplement the mouseMoveEvent for the dialog and test this in there for all the widgets.

Another solution is to install the tooltip label as event filter for all the other widgets and when the mouse enters one of them you display the label.

Kimmo
7th November 2007, 10:48
An event filter, yes. So simple. Thanks.