Federico
Federico

Reputation: 576

Qt: detect if mouse is over certain widget even if that widget has no focus

I want to detect if the mouse is over a certain widget in Qt4.7. The idea behind this is to take an action if a certain key is pressed and the mouse is over a certain widget. I've found that mouse tracking is not working for this (in particular because I'm using a third party widget that does not expose the mouse moved signal). Also, I need this to work even if the widget does not have the focus when the key is pressed.

I would really appreciate any idea.

Thanks in advance.

Upvotes: 2

Views: 2495

Answers (1)

user1092803
user1092803

Reputation: 3297

There are the enterEvent and leaveEvent virtual signals that you can/must override. These can be used to track which widget the mouse is positioned over, even if the widget does not have focus.

Upvotes: 3

Related Questions