QGuiActionGroup Class

The QGuiActionGroup class groups actions together. More...

Header: #include <QGuiActionGroup>
qmake: QT += gui
Since: Qt 6.0
Inherits: QObject
Inherited By:


This class was introduced in Qt 6.0.

Public Types

enum class ExclusionPolicy { None, Exclusive, ExclusiveOptional }


Public Functions

QGuiActionGroup(QObject *parent)
virtual ~QGuiActionGroup()
QGuiAction *addAction(QGuiAction *action)
QGuiAction *checkedGuiAction() const
QGuiActionGroup::ExclusionPolicy exclusionPolicy() const
QList<QGuiAction *> guiActions() const
bool isEnabled() const
bool isExclusive() const
bool isVisible() const
void removeAction(QGuiAction *action)

Public Slots

void setDisabled(bool b)
void setEnabled(bool)
void setExclusionPolicy(QGuiActionGroup::ExclusionPolicy policy)
void setExclusive(bool b)
void setVisible(bool)

Detailed Description

QGuiActionGroup is a base class for classes grouping classes inhheriting QGuiAction objects together.

In some situations it is useful to group QGuiAction 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 QGuiActionGroup.

See also QGuiAction.

Member Type Documentation

enum class QGuiActionGroup::ExclusionPolicy

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

QGuiActionGroup::ExclusionPolicy::None0The actions in the group can be checked independently of each other.
QGuiActionGroup::ExclusionPolicy::Exclusive1Exactly one action can be checked at any one time. This is the default policy.
QGuiActionGroup::ExclusionPolicy::ExclusiveOptional2At most one action can be checked at any one time. The actions can also be all unchecked.

See also exclusionPolicy.

Property Documentation

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.

Access functions:

bool isEnabled() const
void setEnabled(bool)

See also QGuiAction::setEnabled().

exclusionPolicy : QGuiActionGroup::ExclusionPolicy

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.

Access functions:

QGuiActionGroup::ExclusionPolicy exclusionPolicy() const
void setExclusionPolicy(QGuiActionGroup::ExclusionPolicy policy)

See also QGuiAction::checkable.

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.

Access functions:

bool isVisible() const
void setVisible(bool)

See also QGuiAction::setEnabled().

Member Function Documentation

QGuiActionGroup::QGuiActionGroup(QObject *parent)

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(QGuiActionGroup::ExclusionPolicy::ExclusiveOptional)

[slot] void QGuiActionGroup::setDisabled(bool b)

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.

[slot] void QGuiActionGroup::setExclusive(bool b)

Enable or disable the group exclusion checking

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

See also isExclusive() and QGuiActionGroup::exclusionPolicy.

[virtual] QGuiActionGroup::~QGuiActionGroup()

Destroys the action group.

QGuiAction *QGuiActionGroup::addAction(QGuiAction *action)

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 QGuiAction::setActionGroup().

QGuiAction *QGuiActionGroup::checkedGuiAction() const

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

QList<QGuiAction *> QGuiActionGroup::guiActions() const

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

bool QGuiActionGroup::isExclusive() const

Returns true if the group is exclusive

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

void QGuiActionGroup::removeAction(QGuiAction *action)

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

See also QGuiAction::setActionGroup().

© 2020 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.