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. Strange mouse behavior
Qt 6.11 is out! See what's new in the release blog

Strange mouse behavior

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 586 Views 1 Watching
  • 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.
  • T Offline
    T Offline
    thsprppr
    wrote on last edited by
    #1

    I have a class derived from QWidget which has mousePressEvent, mouseMoveEvent, and mouseReleaseEvent overridden. I have two instances of this derived class in my application.

    One works exactly how I'd expect, mousePressEvent when the mouse button is pressed, mouseMoveEvent whenever it moves (mouse button down or not), and mouseReleaseEvent when the mouse button is released.

    The other doesn't. mousePressEvent fires normally but then mouseMoveEvent won't fire at all. mouseMoveEvent will only start firing once the mouse button is released, which also does not fire a mouseReleaseEvent. At that point, my application thinks it's dragging even though the mouse button isn't being held down. Only with another click will another mousePressEvent and finally a mouseReleaseEvent get triggered.

    I have no idea what's causing this, and as far as I know both instances are completely identical so there's no reason it would be happening.

    This is Qt 5.10.1 on MSVC 2015. Any help would be greatly appreciated!

    raven-worxR 1 Reply Last reply
    0
    • T thsprppr

      I have a class derived from QWidget which has mousePressEvent, mouseMoveEvent, and mouseReleaseEvent overridden. I have two instances of this derived class in my application.

      One works exactly how I'd expect, mousePressEvent when the mouse button is pressed, mouseMoveEvent whenever it moves (mouse button down or not), and mouseReleaseEvent when the mouse button is released.

      The other doesn't. mousePressEvent fires normally but then mouseMoveEvent won't fire at all. mouseMoveEvent will only start firing once the mouse button is released, which also does not fire a mouseReleaseEvent. At that point, my application thinks it's dragging even though the mouse button isn't being held down. Only with another click will another mousePressEvent and finally a mouseReleaseEvent get triggered.

      I have no idea what's causing this, and as far as I know both instances are completely identical so there's no reason it would be happening.

      This is Qt 5.10.1 on MSVC 2015. Any help would be greatly appreciated!

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      @thsprppr
      my first guess: you didn't call the base class implementation when overriding the mouse event handlers?
      Also it would help if you show the code of your mouse event handlers.

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0
      • T Offline
        T Offline
        thsprppr
        wrote on last edited by
        #3

        Hi, thanks for your response. I managed to solve this after some closer inspection. I wasn't calling the base class implementations, but through a few functions happened to be calling resize and update functions on said QWidget which would eventually loop and cause a stack overflow. After adjusting the offending code, the mouse functions work as expected.

        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