I have a Qt (4.7) Windows 7 application in which certain components react to QEvent::HoverEnter, QEvent::HoverLeave, QEvent::HoverMove, QEvent::MouseMove events. When the main application window is displayed but does not have focus, I want to ignore these events.
For example, suppose that I have two windows side by side: my main application window, and a web browser window. If I click with the left mouse button on the browser window, the browser has the focus. If I now move the mouse pointer over my main application window without clicking on it, I do not want the application to react. The current behaviour is that my application receives mouse events and reacts to them (opens menus, and so on).
Since my main class MyApplication is derived from QtSingleApplication, I want to override the method
virtual bool MyApplication::notify(QObject* receiver, QEvent* event)
and add a test so that I can ignore specific events if my application does not have any window with focus. Is there a way to verify this condition in Qt?