Activating window when mouse hovers over it
Hello everyone. I have a question regarding activating a window when the mouse hovers over it.
I am new to QT5, and I have currently created an application using QT5 which opens multiple windows upon double clicking on an item.
I have a main window which contains list of items, and double clicking each item opens another window, like a file viewer.
Now, I am trying to figure out a way to activate the window which the mouse is hovering over.
For example, after opening multiple items on another window by double clicking the item on the main window, I would like to have the main window activated on my mouse hovering over it so that pressing shortkeys will correspond to main window's shortkeys, not any other window opened.
I have found QHoverEvent class on the website. Is this the right class to use?
I can't seem to find a code example for this. Can someone point me to one?
Thank you very much for your help!
Hi and welcome to devnet,
You would need to set the
Qt::WA_Hoverattribute on your widget in order to receive the hover events. Then you can use an event filter using installEventFilter to set the focus on the widget currently hovered.
Hope it helps
On a side note, it's Qt, QT stands for Apple QuickTime which you might also be using.
Oops sorry about that. I'll write Qt from now on haha. Thanks for correcting me.
Also, thank you for the info. I am looking into it right now!