You can't assign a QAction
to a QPushButton
the way you want. QPushButton
doesn't redefine addAction
so the behavior comes from QWidget.addAction
which adds the action to the context menu of the button.
You can however assign the action to a QToolButton
with setDefaultAction
which will change the button caption and trigger the action when clicked.
Or you could do it manually anyway by subclassing QPushButton
and adding a setDefaultAction
method that would change everything in the button according to the action (caption, tooltip...) and connects the relevant button's signals to the action's slots.