Class: QgsToolButtonAction

QWidgetAction for adding toolbuttons/actions to the toolbars which are not children of QMainWindow.

QgsToolButtonAction should be used to add buttons with dropdown menus to make them available in the toolbar extension popup.

Added in version 4.4.

List of all members, including inherited members

Class Hierarchy

Inheritance diagram of qgis.gui.QgsToolButtonAction

Base classes

QWidgetAction

QAction

QObject

Constructor

__init__

Methods

addActions

Appends actions to the button's list of actions.

defaultAction

Returns the default action.

setAutoRaise

Sets whether auto-raise is enabled.

setDefaultAction

Sets the default action to action

setMenu

Associates a menu with this tool button.

setPopupMode

Sets the popup mode to use for button's popup menu.

setToolButtonStyle

Sets the toolbutton style, e.g. icon only, text only, or text beside/below the icon.

class qgis.gui.QgsToolButtonAction[source]

Bases: QWidgetAction

__init__(parent: QObject | None = None)

Constructor for QgsToolButtonAction

Parameters:

parent (QObject|None = None) – parent widget

addActions(self, actions: Iterable[QAction])[source]

Appends actions to the button’s list of actions. This is an alternative to setMenu(), the buttons build their popup menu from these actions. If a menu was set with setMenu() it takes precedence.

See also

setMenu()

Parameters:

actions (Iterable[QAction])

defaultAction(self) → QAction | None[source]

Returns the default action.

Return type:

QAction|None

setAutoRaise(self, autoRaise: bool)[source]

Sets whether auto-raise is enabled.

Parameters:

autoRaise (bool)

setDefaultAction(self, action: QAction | None)[source]

Sets the default action to action

The buttons mirror the default action’s icon, text, tooltip and state, and clicking a button triggers it.

Ownership of the action is not transferred.

See also

defaultAction()

Parameters:

action (QAction|None)

setMenu(self, menu: QMenu | None)[source]

Associates a menu with this tool button. The menu will be shown according to the button’s popup mode. Ownership of the menu is not transferred.

See also

setPopupMode()

See also

addActions()

Parameters:

menu (QMenu|None)

setPopupMode(self, mode: QToolButton.ToolButtonPopupMode)[source]

Sets the popup mode to use for button’s popup menu.

See also

setMenu()

See also

addActions()

Parameters:

mode (QToolButton.ToolButtonPopupMode)

setToolButtonStyle(self, style: Qt.ToolButtonStyle)[source]

Sets the toolbutton style, e.g. icon only, text only, or text beside/below the icon.

Parameters:

style (Qt.ToolButtonStyle)