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. mouse handling change in qt5 possibly broke my code
Forum Update on Monday, May 27th 2025

mouse handling change in qt5 possibly broke my code

Scheduled Pinned Locked Moved Unsolved General and Desktop
grabmouse
3 Posts 2 Posters 566 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.
  • M Offline
    M Offline
    Meyer Sound
    wrote on last edited by
    #1

    I've inherited a large codebase built off of Qt4.8, which has a framework built on top of the Qt framework. Due to Qt5 changes in the mouse handling, different functions are now being called in a particular context. The specific case is the left-mouse has been pressed, and is being used to rotate a 'knob'. The user moves off of the knob component, still holding the left mouse button, and then, at the same time, presses the right mouse button. Previously the knob component contextMenuEvent was getting called, but with Qt5 that isn't the case. As I didn't write this underlying framework, it is a bit daunting to go mess with it's innards.

    otoh, if I use grabMouse/releaseMouse, I get the previous, and expected, behavior. But, I am concerned based on the warnings in the documentation for grabMouse. My quick tests using grabMouse/releaseMouse work, but obviously I don't knowhow to test for the dangers warned against.

    Any advice? Is grabMouse really that dangerous? Are there some known conditions I can test against?

    Thank in advance.

    -Chris Roberts
    Meyer Sound
    Senior Software Engineer

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Well, the best testing is intensive testing. Let your co-worker toy with the software to see if anything bad happens. You can also write unit tests to automate that part.

      If you don't do anything funky you should not get bitten by grabMouse.

      In any case, I'd rather take a look at that underlying framework. If you are inheriting its maintenance, then it's better to know it.

      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
      0
      • M Offline
        M Offline
        Meyer Sound
        wrote on last edited by
        #3

        @SGaist said:

        If you don't do anything funky you should not get bitten by grabMouse.

        Thank you oh mighty Qt Champ! ;)

        I fully agree that rectifying the framework with the new mouse handling is the proper fix, but, as usual, I am balancing this against a schedule that lines up with shipping hardware.

        Your input allows me to speak more intelligently about our options, and help our group decide the best way to spend our time.

        Thank you.

        1 Reply Last reply
        0

        • Login

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