Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Toutes les classes  ·  Toutes les fonctions  ·  Vues d'ensemble  · 

QActionGroup Class Reference
[QtGui module]

The QActionGroup class groups actions together. More...

 #include <QActionGroup>

Inherits QObject.


Properties

  • 1 property inherited from QObject

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
bool isEnabled () const
bool isExclusive () const
bool isVisible () const
void removeAction ( QAction * action )
  • 29 public functions inherited from QObject

Public Slots

void setDisabled ( bool b )
void setEnabled ( bool )
void setExclusive ( bool )
void setVisible ( bool )
  • 1 public slot inherited from QObject

Signals

void hovered ( QAction * action )
void triggered ( QAction * action )

Additional Inherited Members

  • 5 static public members inherited from QObject
  • 7 protected functions inherited from QObject

Detailed Description

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.


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:

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.

Access functions:

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.

Access functions:

bool isVisible () const
void setVisible ( bool )

See also QAction::setEnabled().


Member Function Documentation

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 )

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 )

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

Publicité

Best Of

Actualités les plus lues

Semaine
Mois
Année
  1. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 64
  2. Apercevoir la troisième dimension ou l'utilisation multithreadée d'OpenGL dans Qt, un article des Qt Quarterly traduit par Guillaume Belz 0
  3. Les développeurs ignorent-ils trop les failles découvertes dans leur code ? Prenez-vous en compte les remarques des autres ? 17
  4. BlackBerry 10 : premières images du prochain OS de RIM qui devrait intégrer des widgets et des tuiles inspirées de Windows Phone 0
  5. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  6. Adieu qmake, bienvenue qbs : Qt Building Suite, un outil déclaratif et extensible pour la compilation de projets Qt 17
  7. La rubrique Qt a besoin de vous ! 1
Page suivante

Le Qt Quarterly au hasard

Logo

Un widget de correspondance de données avec Qt

Qt Quarterly est la revue trimestrielle proposée par Nokia et à destination des développeurs Qt. Ces articles d'une grande qualité technique sont rédigés par des experts Qt. Lire l'article.

Communauté

Ressources

Liens utiles

Contact

  • Vous souhaitez rejoindre la rédaction ou proposer un tutoriel, une traduction, une question... ? Postez dans le forum Contribuez ou contactez-nous par MP ou par email (voir en bas de page).

Qt dans le magazine

Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt 4.6
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web