How to do something while a QAction in the toolbar is kept pressed?
Unsolved
General and Desktop
-
I want to show the user a custom menu that I made while the user presses a QAction button in the toolbar. As soon as the user releases this button, I want the menu to disappear. I am able to handle the menu part, but I am confused about how to manage the pressed and released aspect of the QAction, since QAction does not have these attributes.
Just to be clear, I want to do some action when the mouse click is down, and as soon as the mouse click is up, I want to stop that action.
Thanks.
-
@BigBen You can get the QToolButton associated with the QAction using
widgetForAction
from yourQToolBar
widgetPython
toolbar.widgetForAction(your_action)
Otherwise, you could try intercepting
mousePressEvent
andmouseReleaseEvent
. -
@BigBen Also check out
eventFilter
. Here's a link to the documentation.