CopperSpice API  1.9.2
QActionGroup Class Reference

The QActionGroup class groups actions together. More...

Inheritance diagram for QActionGroup:
QObject

Public Signals

void hovered (QAction *action)
 
void triggered (QAction *action)
 
- Public Signals inherited from QObject
void destroyed (QObject *obj=nullptr)
 
void objectNameChanged (const QString &objectName)
 

Public Slots

void setDisabled (bool b)
 
void setEnabled (bool b)
 
void setExclusive (bool b)
 
void setVisible (bool b)
 
- Public Slots inherited from QObject
void deleteLater ()
 

Public Methods

 QActionGroup (QObject *parent)
 
 ~QActionGroup ()
 
QList< QAction * > actions () const
 
QActionaddAction (const QIcon &icon, const QString &text)
 
QActionaddAction (const QString &text)
 
QActionaddAction (QAction *action)
 
QActioncheckedAction () const
 
bool isEnabled () const
 
bool isExclusive () const
 
bool isVisible () const
 
void removeAction (QAction *action)
 
- Public Methods inherited from QObject
 QObject (QObject *parent=nullptr)
 
 ~QObject ()
 
bool blockSignals (bool block)
 
const QList< QObject * > & children () const
 
bool connect (const QObject *sender, const QString &signalMethod, const QString &location, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
bool connect (const QObject *sender, const QString &signalMethod, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
bool disconnect (const QObject *receiver, const QString &slotMethod=QString ()) const
 
bool disconnect (const QString &signalMethod, const QString &location, const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const
 
bool disconnect (const QString &signalMethod=QString (), const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const
 
void dumpObjectInfo ()
 
void dumpObjectTree ()
 
QList< QStringdynamicPropertyNames () const
 
virtual bool event (QEvent *event)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
template<typename T >
findChild (const QString &childName=QString ()) const
 
template<class T >
QList< T > findChildren (const QRegularExpression &regExp, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
template<class T >
QList< T > findChildren (const QString &childName=QString (), Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
bool inherits (const QString &className) const
 
void installEventFilter (QObject *filterObj)
 
bool isWidgetType () const
 
bool isWindowType () const
 
void killTimer (int id)
 
const QMetaObjectmetaObject () const
 
void moveToThread (QThread *targetThread)
 
QString objectName () const
 
QObject * parent () const
 
template<class T = QVariant>
property (const QString &name) const
 
void removeEventFilter (QObject *obj)
 
void setObjectName (const QString &name)
 
void setParent (QObject *parent)
 
bool setProperty (const QString &name, const QVariant &value)
 
bool signalsBlocked () const
 
int startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer)
 
QThreadthread () const
 

Properties

 enabled
 
 exclusive
 
 visible
 
- Properties inherited from QObject
 objectName
 

Additional Inherited Members

- Static Public Methods inherited from QObject
static bool connect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool connect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection, const QString &location=QString ())
 
static bool connect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn >
static bool connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...), Qt::ConnectionType type=Qt::AutoConnection)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T >
static bool connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotLambda, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod)
 
static bool disconnect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod)
 
static bool disconnect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod)
 
static bool disconnect (const QObject *sender, std::nullptr_t, const QObject *receiver, std::nullptr_t)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...))
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, std::nullptr_t slotMethod=nullptr)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotMethod)
 
static QMetaObjectstaticMetaObject ()
 
static QString tr (const char *text, const char *comment=nullptr, std::optional< int > numArg=std::optional< int >())
 
- Protected Methods inherited from QObject
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const QMetaMethod &signalMethod) const
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const QMetaMethod &signalMethod) const
 
bool isSignalConnected (const QMetaMethod &signalMethod) const
 
int receivers (const QString &signal) const
 
QObject * sender () const
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *event)
 

Detailed Description

The QActionGroup class groups actions 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 way of doing this is to group the actions together in an action group. The following example creates 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.

alignmentGroup = new QActionGroup(this);
alignmentGroup->addAction(leftAlignAct);
alignmentGroup->addAction(rightAlignAct);
alignmentGroup->addAction(justifyAct);
alignmentGroup->addAction(centerAct);
leftAlignAct->setChecked(true);
Alignment options in a QMenu

A QActionGroup emits a 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(), however it is sometimes more convenient to specify a group when creating the action. This ensures 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() to mark it as a separator. Action groups are added to widgets with the QWidget::addActions() method.

See also
QAction

Constructor & Destructor Documentation

QActionGroup::QActionGroup ( QObject parent)
explicit

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.

Method Documentation

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

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

QAction * QActionGroup::addAction ( const QIcon icon,
const QString 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()
QAction * QActionGroup::addAction ( const QString 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()
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::checkedAction ( ) const

Returns the currently checked action in the group or a nullptr 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()
bool QActionGroup::isEnabled ( ) const

Returns the value of the property.

bool QActionGroup::isExclusive ( ) const

Returns the value of the property.

bool QActionGroup::isVisible ( ) const

Returns the value of the property.

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

If b is true the action group is disabled, otherwise it is enabled.

void QActionGroup::setEnabled ( bool  b)
slot

Sets the value of the property to b.

void QActionGroup::setExclusive ( bool  b)
slot

Sets the value of the property to b.

void QActionGroup::setVisible ( bool  b)
slot

Sets the value of the property to b.

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()

Property Documentation

QActionGroup::enabled

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
QAction::setEnabled()
PropertiesClass Methods
read isEnabled
write setEnabled
QActionGroup::exclusive

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.

See also
QAction::checkable
PropertiesClass Methods
read isExclusive
write setExclusive
QActionGroup::visible

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
QAction::setEnabled()
PropertiesClass Methods
read isVisible
write setVisible