Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Capturing mouse events of container (bottom) widget?



  • What I'm trying to accomplish is always have the current mouse position relative to the window's top left corner. I could maybe poll for the cursor's position every n milliseconds, but I would rather react to the mouse move events as they're created/sent.

    For now, I have a frameless window (the container) that I want to catch the mouse move events of, the problem is that the top-level widgets in it's layout are the only things receiving the events. I tried setting mouse tracking on the container and filtering the application's events from the container, but it still only receives them when a mouse button is held down.


  • Lifetime Qt Champion

    Hi,

    You should then consider using an event filter that you set on all widgets contained in your container widget.



  • Thanks.

    I did wind up going with polling the cursor position, but I might look into implementing your solution in the future.


Log in to reply