Qt:Документация 4.3.2/qactiongroup

Материал из Wiki.crossplatform.ru

Перейти к: навигация, поиск
40px Внимание: Актуальная версия перевода документации находится здесь

__NOTOC__

Image:qt-logo.png

Главная · Все классы · Основные классы · Классы по группам · Модули · Функции

Image:trolltech-logo.png

Содержание

[править] QActionGroup Class Reference
[модуль QtGui ]

The QActionGroup class groups actions together. More...

 #include <QActionGroup>

Inherits QObject.

[править] Свойства

  • 1 свойство унаследованное от QObject

[править] Открытые функции

  • 29 открытых функций унаследованных от QObject

[править] Открытые слоты

  • 1 открытый слот унаследованный от QObject

[править] Сигналы

  • 1 сигнал унаследованный от QObject

[править] Дополнительные унаследованные члены

  • 5 статических открытых члена унаследованных от QObject
  • 7 защищенных функций унаследованных от QObject

[править] Подробное описание

The QActionGroup class groups actions together.

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

Here's a example (from the Menus example):

     alignmentGroup = new QActionGroup(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.

Файл:Qactiongroup-align.png

A QActionGroup emits an triggered() signal when one of its actions is chosen. Each action in an action group emits its triggered() signal as usual.

As stated above, an action group is exclusive 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 calling setExclusive(false).

Actions can be added to an action group using addAction(), 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 use QAction's setSeparator() function to make it considered a separator. Action groups are added to widgets with the QWidget::addActions() function.

See also QAction.


[править] Описание свойств

[править]
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.

Функции доступа:

  • bool isEnabled () const
  • void setEnabled ( bool )

See also QAction::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.

Функции доступа:

  • bool isExclusive () const
  • void setExclusive ( bool )

See also QAction::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.

Функции доступа:

  • bool isVisible () const
  • void setVisible ( bool )

See also QAction::setEnabled().


[править] Описание функций-членов

[править]
QActionGroup::QActionGroup ( 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.

[править]
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 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 QAction::setActionGroup().

[править]
QAction * QActionGroup::addAction ( const QString & text )

This is an overloaded member function, provided for convenience.

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

[править]
QAction * QActionGroup::addAction ( const QIcon & icon, const QString & text )

This is an overloaded member function, provided for convenience.

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

[править]
QAction * QActionGroup::checkedAction () const

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

[править]
void QActionGroup::hovered ( QAction * action ) [signal]

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, toolbar button, or presses an action's shortcut key combination.

See also QAction::activate().

[править]
void QActionGroup::removeAction ( QAction * action )

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

See also QAction::setActionGroup().

[править]
void QActionGroup::setDisabled ( bool b ) [slot]

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.

[править]
void QActionGroup::triggered ( QAction * action ) [signal]

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, toolbar button, or presses an action's shortcut key combination.

Connect to this signal for command actions.

See also QAction::activate().


Copyright © 2007 Trolltech Trademarks
Qt 4.3.2