Movatterモバイル変換


[0]ホーム

URL:


We bake cookies in your browser for a better experience. Using this site means that you consent.Read More

Menu

Qt Documentation

QActionGroup Class

TheQActionGroup class groups actions together.More...

Header:#include <QActionGroup>
Inherits:QObject

Properties

Public Functions

QActionGroup(QObject * parent)
~QActionGroup()
QList<QAction *>actions() const
QAction *addAction(QAction * action)
QAction *addAction(const QString & text)
QAction *addAction(const QIcon & icon, const QString & text)
QAction *checkedAction() const
boolisEnabled() const
boolisExclusive() const
boolisVisible() const
voidremoveAction(QAction * action)
  • 29 public functions inherited fromQObject

Public Slots

voidsetDisabled(bool b)
voidsetEnabled(bool)
voidsetExclusive(bool)
voidsetVisible(bool)
  • 1 public slot inherited fromQObject

Signals

voidhovered(QAction * action)
voidtriggered(QAction * action)

Additional Inherited Members

  • 7 static public members inherited fromQObject
  • 8 protected functions inherited fromQObject

Detailed Description

TheQActionGroup class groups actions together.

In some situations it is useful to groupQAction objects together. For example, if you have aLeft Align action, aRight Align action, aJustify action, and aCenter 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.

Here's a example (from theMenus example):

    alignmentGroup=newQActionGroup(this);    alignmentGroup->addAction(leftAlignAct);    alignmentGroup->addAction(rightAlignAct);    alignmentGroup->addAction(justifyAct);    alignmentGroup->addAction(centerAct);    leftAlignAct->setChecked(true);

Here we create a new action group. Since the action group is exclusive by default, only one of the actions in the group is checked at any one time.

Alignment options in a QMenu

AQActionGroup emits antriggered() signal when one of its actions is chosen. Each action in an action group emits itstriggered() signal as usual.

As stated above, an action group isexclusive by default; it ensures that only one checkable action is active at any one time. If you want to group checkable actions without making them exclusive, you can turn of exclusiveness by callingsetExclusive(false).

Actions can be added to an action group usingaddAction(), but it is usually more convenient to specify a group when creating actions; this ensures that actions are automatically created with a parent. Actions can be visually separated from each other by adding a separator action to the group; create an action and useQAction'ssetSeparator() function to make it considered a separator. Action groups are added to widgets with theQWidget::addActions() function.

See alsoQAction.

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:

boolisEnabled() const
voidsetEnabled(bool)

See alsoQAction::setEnabled().

exclusive :bool

This property holds whether the action group does exclusive checking.

If exclusive is true, 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.

Access functions:

boolisExclusive() const
voidsetExclusive(bool)

See alsoQAction::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:

boolisVisible() const
voidsetVisible(bool)

See alsoQAction::setEnabled().

Member Function Documentation

QActionGroup::QActionGroup(QObject * parent)

Constructs an action group for theparent object.

The action group is exclusive by default. CallsetExclusive(false) to make the action group non-exclusive.

QActionGroup::~QActionGroup()

Destroys the action group.

QList<QAction *> QActionGroup::actions() const

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

QAction * QActionGroup::addAction(QAction * action)

Adds theaction 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 alsoQAction::setActionGroup().

QAction * QActionGroup::addAction(constQString & text)

Creates and returns an action withtext. 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 alsoQAction::setActionGroup().

QAction * QActionGroup::addAction(constQIcon & icon, constQString & text)

Creates and returns an action withtext and anicon. 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 alsoQAction::setActionGroup().

QAction * QActionGroup::checkedAction() const

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

[signal]void QActionGroup::hovered(QAction * action)

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

See alsoQAction::activate().

void QActionGroup::removeAction(QAction * action)

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

See alsoQAction::setActionGroup().

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

This is a convenience function for theenabled property, that is useful for signals--slots connections. Ifb is true the action group is disabled; otherwise it is enabled.

[signal]void QActionGroup::triggered(QAction * action)

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

Connect to this signal for command actions.

See alsoQAction::activate().

© 2016 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 theGNU 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.


[8]ページ先頭

©2009-2025 Movatter.jp