Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Activating window when mouse hovers over it
QtWS25 Last Chance

Activating window when mouse hovers over it

Scheduled Pinned Locked Moved Unsolved General and Desktop
hoverwindowmousemouseeventqt5
3 Posts 2 Posters 2.7k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    js0823
    wrote on 4 Jan 2016, 22:28 last edited by
    #1

    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!

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 4 Jan 2016, 23:06 last edited by SGaist 1 Apr 2016, 23:07
      #2

      Hi and welcome to devnet,

      You would need to set the Qt::WA_Hover attribute 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.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • J Offline
        J Offline
        js0823
        wrote on 5 Jan 2016, 16:30 last edited by
        #3

        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!

        1 Reply Last reply
        0

        3/3

        5 Jan 2016, 16:30

        • Login

        • Login or register to search.
        3 out of 3
        • First post
          3/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved