Version: 9.12.0
QtxActionGroup Class Reference

The QtxActionGroup class groups actions together. More...

#include <QtxActionGroup.h>

Inheritance diagram for QtxActionGroup:
Inheritance graph

Public Slots

void setExclusive (const bool)
 Set/clear the action group exclusiveness. More...
 
void setUsesDropDown (const bool)
 Defines a way how the group's actions should be displayed in parent widget action group is added to - as a group of actions or in a subwidget (e.g. in the combo box). More...
 

Signals

void selected (QAction *)
 Emitted when some child action is toggled by the user. More...
 
- Signals inherited from QtxActionSet
void triggered (int)
 Emitted when some child action is activated by the user. More...
 
void triggered (QAction *)
 Emitted when some child action is activated by the user. More...
 

Public Member Functions

 QtxActionGroup (QObject *=0)
 Constructor. More...
 
 QtxActionGroup (QObject *, const bool)
 Constructor. More...
 
virtual ~QtxActionGroup ()
 Destructor. More...
 
bool isExclusive () const
 Check if the action group is exclusive. More...
 
bool usesDropDown () const
 Check if action group should appear in a subwidget of parent widget. More...
 
void add (QAction *)
 Append the specified action into group. action action to be added to the action group. More...
 
void setEnabled (bool)
 Enable/disable action group. More...
 
- Public Member Functions inherited from QtxActionSet
 QtxActionSet (QObject *=0)
 Constructor. More...
 
virtual ~QtxActionSet ()
 Destructor. More...
 
QList< QAction * > actions () const
 Get list of child actions. More...
 
void setActions (const QList< QAction * > &)
 Assign child actions. More...
 
void insertActions (const QList< QAction * > &, const int=-1)
 Insert actions at the specified position. More...
 
int insertAction (QAction *, const int id=-1, const int=-1)
 Insert action at the specified position. More...
 
int insertAction (const QString &, const int id=-1, const int=-1)
 Insert action at the specified position. More...
 
int insertAction (const QString &, const QIcon &, const int id=-1, const int=-1)
 Insert action at the specified position. More...
 
void removeAction (QAction *)
 Remove specified action. More...
 
void removeAction (const int)
 Remove specified action. More...
 
void clear ()
 Remove all actions. More...
 
- Public Member Functions inherited from QtxAction
 QtxAction (QObject *=0, bool=false, const QString &=QString())
 Constructor. More...
 
 QtxAction (const QString &, const QString &, int, QObject *, bool=false, const QString &=QString())
 Constructor. More...
 
 QtxAction (const QString &, const QString &, const QKeySequence &, QObject *, bool=false, const QString &=QString())
 Constructor. More...
 
 QtxAction (const QString &, const QIcon &, const QString &, int, QObject *, bool=false, const QString &=QString())
 Constructor. More...
 
 QtxAction (const QString &, const QIcon &, const QString &, const QKeySequence &, QObject *, bool=false, const QString &=QString())
 Constructor. More...
 
virtual ~QtxAction ()
 Destructor. More...
 
virtual bool eventFilter (QObject *, QEvent *)
 Customize action events. More...
 
QString shortcutActionName () const
 Return shortcut action name for the action. More...
 
void setShortcutActionName (const QString &)
 Set shortcut action name to the action. More...
 

Protected Member Functions

virtual void updateAction (QWidget *)
 Update action group for the specified widget. More...
 
virtual void updateAction (QtxComboBox *)
 Update action group for the specified combo box. More...
 
virtual QWidgetcreateWidget (QWidget *)
 Create widget representing action group in the widget this action group is added to. More...
 
virtual bool isEmptyAction () const
 Check if the action itself should be invisible (only child action are shown) More...
 
virtual void actionAdded (QAction *)
 Called when action is added to the action group. More...
 
virtual void actionRemoved (QAction *)
 Called when action is removed from the action group. More...
 
- Protected Member Functions inherited from QtxActionSet
virtual void addedTo (QWidget *)
 Called when this action set is added to the menu bar (or toolbar). More...
 
virtual void removedFrom (QWidget *)
 Called when this action set is removed from the menu bar (or toolbar). More...
 
QActionaction (int) const
 Get action by specified identifier. More...
 
int actionId (QAction *) const
 Get action identifier for the action. More...
 
void setActionId (QAction *, const int)
 Set action identifier for the action. More...
 
virtual void updateAction ()
 Update action set. More...
 
- Protected Member Functions inherited from QtxAction
virtual void customEvent (QEvent *)
 Process notification events. More...
 

Private Slots

void onActivated (int)
 Called when some subwidget item is activated by the user. More...
 
void onTriggered (QAction *)
 Called when some action owned by this action group is activated by the user. More...
 

Private Member Functions

void updateType ()
 Internal update. More...
 
QtxComboBoxcreatedWidget (QWidget *)
 Get combo box created by this action group for the specified widget. More...
 

Private Attributes

bool myDropDown
 
QActionGroup * myActionGroup
 

Detailed Description

The QtxActionGroup class groups actions together.

QtxActionGroup class operates with a list of actions in the similar way as it does QActionGroup class. But in contrast to the Qt 4's class, QtxActrionGroup behaves rather like it was in Qt series 3x. For example, it automatically shows exclusive combo box widget when action group is added to the toolbar and if usesDropDown and exclusive flags are both set to true.

The setExclusive() function is used to ensure that only one action is active at any moment: it should be used with actions which have their checkable state set to true.

Action group actions appear as individual menu options and toolbar buttons. For exclusive action groups use setUsesDropDown() to display the actions in a subwidget of the toolbar or menu the action group is added on.

Actions can be added to the action group using add() function. Add the action group to the menu or toolbar in the same way as for single action - using addAction() method of QMenu or QToolbar class.

Constructor & Destructor Documentation

◆ QtxActionGroup() [1/2]

QtxActionGroup::QtxActionGroup ( QObject parent = 0)

Constructor.

The created action group is exclusive by default.

Parameters
parentowner object
See also
setExclusive()

References myActionGroup, onTriggered(), and QtxActionSet::triggered().

◆ QtxActionGroup() [2/2]

QtxActionGroup::QtxActionGroup ( QObject parent,
const bool  exclusive 
)

Constructor.

Parameters
parentowner object
exclusiveif true only one action in the group will ever be active
See also
setExclusive()

References myActionGroup, selected(), and QtxActionSet::triggered().

◆ ~QtxActionGroup()

QtxActionGroup::~QtxActionGroup ( )
virtual

Destructor.

Member Function Documentation

◆ actionAdded()

void QtxActionGroup::actionAdded ( QAction a)
protectedvirtual

Called when action is added to the action group.

Parameters
aaction being added to the action group

Reimplemented from QtxActionSet.

References myActionGroup.

◆ actionRemoved()

void QtxActionGroup::actionRemoved ( QAction a)
protectedvirtual

Called when action is removed from the action group.

Parameters
aaction being removed from the action group

Reimplemented from QtxActionSet.

References myActionGroup.

◆ add()

void QtxActionGroup::add ( QAction a)

Append the specified action into group. action action to be added to the action group.

References QtxActionSet::insertAction().

◆ createdWidget()

QtxComboBox * QtxActionGroup::createdWidget ( QWidget p)
private

Get combo box created by this action group for the specified widget.

Parameters
pwidget this action group is added to
Returns
combo box if it was created for the specified widget or 0 otherwise

◆ createWidget()

QWidget * QtxActionGroup::createWidget ( QWidget p)
protectedvirtual

Create widget representing action group in the widget this action group is added to.

Parameters
pwidget this action group is being added to
Returns
new widget representing this action group

References isEmptyAction(), and onActivated().

◆ isEmptyAction()

bool QtxActionGroup::isEmptyAction ( ) const
protectedvirtual

Check if the action itself should be invisible (only child action are shown)

Returns
true if the action itself should be visible

Reimplemented from QtxActionSet.

References isExclusive(), and usesDropDown().

◆ isExclusive()

bool QtxActionGroup::isExclusive ( ) const

Check if the action group is exclusive.

Returns
true if the action group is exclusive and false otherwise
See also
setExclusive(), setUsesDropDown()

References myActionGroup.

◆ onActivated

void QtxActionGroup::onActivated ( int  id)
privateslot

Called when some subwidget item is activated by the user.

Parameters
iditem identifier

References QtxActionSet::action(), and QtxComboBox::setCurrentId().

◆ onTriggered

void QtxActionGroup::onTriggered ( QAction a)
privateslot

Called when some action owned by this action group is activated by the user.

Parameters
aaction being activated

References QtxActionSet::actionId(), selected(), and QtxComboBox::setCurrentId().

◆ selected

void QtxActionGroup::selected ( QAction a)
signal

Emitted when some child action is toggled by the user.

Parameters
aaction being toggled

◆ setEnabled()

void QtxActionGroup::setEnabled ( bool  on)

Enable/disable action group.

References myActionGroup.

◆ setExclusive

void QtxActionGroup::setExclusive ( const bool  on)
slot

Set/clear the action group exclusiveness.

Parameters
onif true the action group will be exclusive
See also
isExclusive(), setUsesDropDown()

References isEmptyAction(), myActionGroup, and updateType().

◆ setUsesDropDown

void QtxActionGroup::setUsesDropDown ( const bool  on)
slot

Defines a way how the group's actions should be displayed in parent widget action group is added to - as a group of actions or in a subwidget (e.g. in the combo box).

Parameters
onif true, action group will be shown in the subwidget
See also
usesDropDown(), setExclusive()

References isEmptyAction(), myDropDown, and updateType().

◆ updateAction() [1/2]

void QtxActionGroup::updateAction ( QtxComboBox cb)
protectedvirtual

Update action group for the specified combo box.

Parameters
cba combo box this action group is added to

References QtxActionSet::actionId(), QtxActionSet::actions(), QtxComboBox::setCleared(), QtxComboBox::setCurrentId(), and QtxComboBox::setId().

◆ updateAction() [2/2]

void QtxActionGroup::updateAction ( QWidget w)
protectedvirtual

Update action group for the specified widget.

Parameters
wa widget this action group is added to

Reimplemented from QtxActionSet.

References QtxActionSet::actions(), createdWidget(), QtxActionSet::updateAction(), and usesDropDown().

◆ updateType()

void QtxActionGroup::updateType ( )
private

Internal update.

References isEmptyAction().

◆ usesDropDown()

bool QtxActionGroup::usesDropDown ( ) const

Check if action group should appear in a subwidget of parent widget.

Note: for this option to take into effect, the exclusive flag should be also set to true

Returns
true if the action group is shown in subwidget
See also
setUsesDropDown(), setExclusive()

References myDropDown.

Member Data Documentation

◆ myActionGroup

QActionGroup* QtxActionGroup::myActionGroup
private

◆ myDropDown

bool QtxActionGroup::myDropDown
private

The documentation for this class was generated from the following files: