Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. Detect mouse enter/leave QAbstractButton while a mouse button is pressed
QtWS25 Last Chance

Detect mouse enter/leave QAbstractButton while a mouse button is pressed

Scheduled Pinned Locked Moved Solved Qt for Python
4 Posts 3 Posters 1.1k 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.
  • W Offline
    W Offline
    Wysciguvvka
    wrote on 22 Feb 2022, 19:46 last edited by
    #1

    Hi,
    I want to trigger enterEvent/leaveEvent while a mouse button is pressed and mouse pointer enters/leaves the QAbstractButton.
    Is there any way to do that?
    I tried to use dragEnterEvent with setAcceptDrops(True) but it doesn't even trigger

    J 1 Reply Last reply 23 Feb 2022, 05:26
    0
    • W Wysciguvvka
      23 Feb 2022, 11:36

      @jsulm I've done it before. I already had QAbstractButton subclass (I should have clarified it in post, sorry). The thing is both enterEvent and leaveEvent don't trigger when moving mouse pointer while any of mouse buttons is down

      J Online
      J Online
      JonB
      wrote on 23 Feb 2022, 12:48 last edited by JonB
      #4

      @Wysciguvvka
      This is only a suggestion, but void QWidget::mouseMoveEvent(QMouseEvent *event) says:

      If mouse tracking is switched off, mouse move events only occur if a mouse button is pressed while the mouse is being moved. If mouse tracking is switched on, mouse move events occur even if no mouse button is pressed.

      Maybe that is worth looking into? Another possibility might be an appropriate eventFilter()? (https://stackoverflow.com/a/23836186 ??)

      Please don't ask me for further details, it's just a couple of thoughts for you to try!

      P.S.
      You could also look at https://forum.qt.io/topic/46453/qwidget-enterevent-is-not-being-triggered-when-mouse-button-is-pressed

      1 Reply Last reply
      3
      • W Wysciguvvka
        22 Feb 2022, 19:46

        Hi,
        I want to trigger enterEvent/leaveEvent while a mouse button is pressed and mouse pointer enters/leaves the QAbstractButton.
        Is there any way to do that?
        I tried to use dragEnterEvent with setAcceptDrops(True) but it doesn't even trigger

        J Offline
        J Offline
        jsulm
        Lifetime Qt Champion
        wrote on 23 Feb 2022, 05:26 last edited by
        #2

        @Wysciguvvka said in Detect mouse enter/leave QAbstractButton while a mouse button is pressed:

        QAbstractButton

        Subclass it and override https://doc.qt.io/qt-5/qwidget.html#enterEvent and https://doc.qt.io/qt-5/qwidget.html#leaveEvent

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        1
        • W Offline
          W Offline
          Wysciguvvka
          wrote on 23 Feb 2022, 11:36 last edited by Wysciguvvka
          #3

          @jsulm I've done it before. I already had QAbstractButton subclass (I should have clarified it in post, sorry). The thing is both enterEvent and leaveEvent don't trigger when moving mouse pointer while any of mouse buttons is down

          J 1 Reply Last reply 23 Feb 2022, 12:48
          0
          • W Wysciguvvka
            23 Feb 2022, 11:36

            @jsulm I've done it before. I already had QAbstractButton subclass (I should have clarified it in post, sorry). The thing is both enterEvent and leaveEvent don't trigger when moving mouse pointer while any of mouse buttons is down

            J Online
            J Online
            JonB
            wrote on 23 Feb 2022, 12:48 last edited by JonB
            #4

            @Wysciguvvka
            This is only a suggestion, but void QWidget::mouseMoveEvent(QMouseEvent *event) says:

            If mouse tracking is switched off, mouse move events only occur if a mouse button is pressed while the mouse is being moved. If mouse tracking is switched on, mouse move events occur even if no mouse button is pressed.

            Maybe that is worth looking into? Another possibility might be an appropriate eventFilter()? (https://stackoverflow.com/a/23836186 ??)

            Please don't ask me for further details, it's just a couple of thoughts for you to try!

            P.S.
            You could also look at https://forum.qt.io/topic/46453/qwidget-enterevent-is-not-being-triggered-when-mouse-button-is-pressed

            1 Reply Last reply
            3

            1/4

            22 Feb 2022, 19:46

            • Login

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