Detect mouse enter/leave QAbstractButton while a mouse button is pressed
-
wrote on 22 Feb 2022, 19:46 last edited by
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 -
@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
wrote on 23 Feb 2022, 12:48 last edited by JonB@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 -
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@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
-
wrote on 23 Feb 2022, 11:36 last edited by 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
-
@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
wrote on 23 Feb 2022, 12:48 last edited by JonB@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/4