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

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.
  • WysciguvvkaW Offline
    WysciguvvkaW Offline
    Wysciguvvka
    wrote on 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

    jsulmJ 1 Reply Last reply
    0
    • WysciguvvkaW Wysciguvvka

      @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

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on 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
      • WysciguvvkaW Wysciguvvka

        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

        jsulmJ Online
        jsulmJ Online
        jsulm
        Lifetime Qt Champion
        wrote on 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
        • WysciguvvkaW Offline
          WysciguvvkaW Offline
          Wysciguvvka
          wrote on 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

          JonBJ 1 Reply Last reply
          0
          • WysciguvvkaW Wysciguvvka

            @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

            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on 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

            • Login

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