class QActionGroup

The QActionGroup class groups actions together. More

Inheritance diagram of PySide6.QtGui.QActionGroup

Synopsis

Properties

Methods

Slots

Signals

Note

This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE

Detailed Description

QActionGroup is a base class for classes grouping classes inhheriting QAction objects together.

In some situations it is useful to group QAction objects together. For example, if you have a Left Align action, a Right Align action, a Justify action, and a Center action, only one of these actions should be active at any one time. One simple way of achieving this is to group the actions together in an action group, inheriting QActionGroup .

See also

QAction

class ExclusionPolicy

This enum specifies the different policies that can be used to control how the group performs exclusive checking on checkable actions.

Constant

Description

QActionGroup.ExclusionPolicy.None

The actions in the group can be checked independently of each other.

QActionGroup.ExclusionPolicy.Exclusive

Exactly one action can be checked at any one time. This is the default policy.

QActionGroup.ExclusionPolicy.ExclusiveOptional

At most one action can be checked at any one time. The actions can also be all unchecked.

See also

exclusionPolicy

Note

Properties can be used directly when from __feature__ import true_property is used or via accessor functions otherwise.

property enabledᅟ: bool

This property holds whether the action group is enabled.

Each action in the group will be enabled or disabled unless it has been explicitly disabled.

See also

setEnabled()

Access functions:
property exclusionPolicyᅟ: QActionGroup.ExclusionPolicy

This property holds This property holds the group exclusive checking policy.

If exclusionPolicy is set to Exclusive, only one checkable action in the action group can ever be active at any time. If the user chooses another checkable action in the group, the one they chose becomes active and the one that was active becomes inactive. If exclusionPolicy is set to ExclusionOptional the group is exclusive but the active checkable action in the group can be unchecked leaving the group with no actions checked.

See also

checkable

Access functions:
property visibleᅟ: bool

This property holds whether the action group is visible.

Each action in the action group will match the visible state of this group unless it has been explicitly hidden.

See also

setEnabled()

Access functions:
__init__(parent)
Parameters:

parentQObject

Constructs an action group for the parent object.

The action group is exclusive by default. Call setExclusive (false) to make the action group non-exclusive. To make the group exclusive but allow unchecking the active action call instead setExclusionPolicy ( ExclusiveOptional )

actions()
Return type:

.list of QAction

Returns the list of this groups’s actions. This may be empty.

addAction(a)
Parameters:

aQAction

Return type:

QAction

Adds the action to this group, and returns it.

Normally an action is added to a group by creating it with the group as its parent, so this function is not usually used.

See also

setActionGroup()

addAction(text)
Parameters:

text – str

Return type:

QAction

Creates and returns an action with text. The newly created action is a child of this action group.

Normally an action is added to a group by creating it with the group as parent, so this function is not usually used.

See also

setActionGroup()

addAction(icon, text)
Parameters:
  • iconQIcon

  • text – str

Return type:

QAction

Creates and returns an action with text and an icon. The newly created action is a child of this action group.

Normally an action is added to a group by creating it with the group as its parent, so this function is not usually used.

See also

setActionGroup()

checkedAction()
Return type:

QAction

Returns the currently checked action in the group, or None if none are checked.

exclusionPolicy()
Return type:

ExclusionPolicy

Getter of property exclusionPolicyᅟ .

hovered(arg__1)
Parameters:

arg__1QAction

This signal is emitted when the given action in the action group is highlighted by the user; for example, when the user pauses with the cursor over a menu option or a toolbar button, or presses an action’s shortcut key combination.

See also

activate()

isEnabled()
Return type:

bool

Getter of property enabledᅟ .

isExclusive()
Return type:

bool

Returns true if the group is exclusive

The group is exclusive if the ExclusionPolicy is either Exclusive or ExclusionOptional.

isVisible()
Return type:

bool

Getter of property visibleᅟ .

removeAction(a)
Parameters:

aQAction

Removes the action from this group. The action will have no parent as a result.

See also

setActionGroup()

setDisabled(b)
Parameters:

b – bool

This is a convenience function for the enabled property, that is useful for signals–slots connections. If b is true the action group is disabled; otherwise it is enabled.

setEnabled(arg__1)
Parameters:

arg__1 – bool

See also

isEnabled()

Setter of property enabledᅟ .

setExclusionPolicy(policy)
Parameters:

policyExclusionPolicy

Setter of property exclusionPolicyᅟ .

setExclusive(arg__1)
Parameters:

arg__1 – bool

Enable or disable the group exclusion checking

This is a convenience method that calls setExclusionPolicy ( Exclusive ) when b is true, else setExclusionPolicy ( None ).

setVisible(arg__1)
Parameters:

arg__1 – bool

See also

isVisible()

Setter of property visibleᅟ .

triggered(arg__1)
Parameters:

arg__1QAction

This signal is emitted when the given action in the action group is activated by the user; for example, when the user clicks a menu option or a toolbar button, or presses an action’s shortcut key combination.

Connect to this signal for command actions.

See also

activate()