Qt Jambi Home

com.trolltech.qt.gui
Class QActionGroup

java.lang.Object
  extended by com.trolltech.qt.QSignalEmitter
      extended by com.trolltech.qt.QtJambiObject
          extended by com.trolltech.qt.core.QObject
              extended by com.trolltech.qt.gui.QActionGroup
All Implemented Interfaces:
QtJambiInterface

public class QActionGroup
extends 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.

Alignment options in a QMenu

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

Nested Class Summary
 
Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter
QSignalEmitter.AbstractSignal, QSignalEmitter.Signal0, QSignalEmitter.Signal1<A>, QSignalEmitter.Signal2<A,B>, QSignalEmitter.Signal3<A,B,C>, QSignalEmitter.Signal4<A,B,C,D>, QSignalEmitter.Signal5<A,B,C,D,E>, QSignalEmitter.Signal6<A,B,C,D,E,F>, QSignalEmitter.Signal7<A,B,C,D,E,F,G>, QSignalEmitter.Signal8<A,B,C,D,E,F,G,H>, QSignalEmitter.Signal9<A,B,C,D,E,F,G,H,I>
 
Field Summary
 QSignalEmitter.Signal1<QAction> hovered
          This signal is emitted when the given arg__1 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.
 QSignalEmitter.Signal1<QAction> triggered
          This signal is emitted when the given arg__1 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.
 
Constructor Summary
QActionGroup(QObject parent)
          Constructs an action group for the parent object.
 
Method Summary
 java.util.List<QAction> actions()
          Returns the list of this groups's actions.
 QAction addAction(QAction a)
          Adds the a to this group, and returns it.
 QAction addAction(QIcon icon, java.lang.String text)
          Creates and returns an action with text and an icon.
 QAction addAction(java.lang.String text)
          Creates and returns an action with text.
 QAction checkedAction()
          Returns the currently checked action in the group, or 0 if none are checked.
static QActionGroup fromNativePointer(QNativePointer nativePointer)
          This function returns the QActionGroup instance pointed to by nativePointer
 boolean isEnabled()
          Returns whether the action group is enabled.
 boolean isExclusive()
          Returns whether the action group does exclusive checking.
 boolean isVisible()
          Returns whether the action group is visible.
 void removeAction(QAction a)
          Removes the a from this group.
 void setDisabled(boolean b)
          This is a convenience function for the enabled property, that is useful for signals--slots connections.
 void setEnabled(boolean arg__1)
          Sets whether the action group is enabled to arg__1.
 void setExclusive(boolean arg__1)
          Sets whether the action group does exclusive checking to arg__1.
 void setVisible(boolean arg__1)
          Sets whether the action group is visible to arg__1.
 
Methods inherited from class com.trolltech.qt.core.QObject
blockSignals, childEvent, children, connectSlotsByName, customEvent, disposeLater, dumpObjectInfo, dumpObjectTree, dynamicPropertyNames, event, eventFilter, findChild, findChild, findChild, findChildren, findChildren, findChildren, findChildren, installEventFilter, isWidgetType, killTimer, moveToThread, objectName, parent, property, removeEventFilter, setObjectName, setParent, setProperty, signalsBlocked, startTimer, thread, timerEvent
 
Methods inherited from class com.trolltech.qt.QtJambiObject
dispose, disposed, finalize, reassignNativeResources, tr, tr, tr
 
Methods inherited from class com.trolltech.qt.QSignalEmitter
disconnect, disconnect, signalSender
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.trolltech.qt.QtJambiInterface
disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership
 

Field Detail

hovered

public final QSignalEmitter.Signal1<QAction> hovered

This signal is emitted when the given arg__1 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.

Compatible Slot Signatures:
void mySlot(com.trolltech.qt.gui.QAction arg__1)
void mySlot()
See Also:
QAction::activate


triggered

public final QSignalEmitter.Signal1<QAction> triggered

This signal is emitted when the given arg__1 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.

Compatible Slot Signatures:
void mySlot(com.trolltech.qt.gui.QAction arg__1)
void mySlot()
See Also:
QAction::activate

Constructor Detail

QActionGroup

public 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.

Method Detail

actions

public final java.util.List<QAction> actions()

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


addAction

public final QAction addAction(QAction a)

Adds the a 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

addAction

public final QAction addAction(java.lang.String text)

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

addAction

public final QAction addAction(QIcon icon,
                               java.lang.String text)

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

checkedAction

public final QAction checkedAction()

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


isEnabled

public final boolean isEnabled()

Returns whether the action group is enabled.

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

See Also:
QAction::setEnabled

isExclusive

public final boolean isExclusive()

Returns 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.

See Also:
QAction::checkable

isVisible

public final boolean isVisible()

Returns 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:
QAction::setEnabled

removeAction

public final void removeAction(QAction a)

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

See Also:
QAction::setActionGroup

setDisabled

public final void setDisabled(boolean 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.


setEnabled

public final void setEnabled(boolean arg__1)

Sets whether the action group is enabled to arg__1.

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

See Also:
isEnabled, QAction::setEnabled

setExclusive

public final void setExclusive(boolean arg__1)

Sets whether the action group does exclusive checking to arg__1.

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.

See Also:
isExclusive, QAction::checkable

setVisible

public final void setVisible(boolean arg__1)

Sets whether the action group is visible to arg__1.

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

See Also:
isVisible, QAction::setEnabled

fromNativePointer

public static QActionGroup fromNativePointer(QNativePointer nativePointer)
This function returns the QActionGroup instance pointed to by nativePointer

Parameters:
nativePointer - the QNativePointer of which object should be returned.

Qt Jambi Home