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  ·  Tous les espaces de nom  ·  Toutes les classes  ·  Classes principales  ·  Annotées  ·  Classes groupées  ·  Modules  ·  Fonctions  · 

QButtonGroup Class Reference
[QtGui module]

The QButtonGroup class provides a container to organize groups of button widgets. More...

 #include <QButtonGroup>

Inherits QObject.

Properties

  • 1 property inherited from QObject

Public Functions

  • 29 public functions inherited from QObject

Signals

Additional Inherited Members

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

Detailed Description

The QButtonGroup class provides a container to organize groups of button widgets.

QButtonGroup provides an abstract container into which button widgets can be placed. It does not provide a visual representation of this container (see QGroupBox for a container widget), but instead manages the states of each of the buttons in the group.

An exclusive button group switches off all checkable (toggle) buttons except the one that was clicked. By default, a button group is exclusive. The buttons in a button group are usually checkable QPushButton's, QCheckBoxes (normally for non-exclusive button groups), or QRadioButtons. If you create an exclusive button group, you should ensure that one of the buttons in the group is initially checked; otherwise, the group will initially be in a state where no buttons are checked.

A button is added to the group with addButton(). It can be removed from the group with removeButton(). If the group is exclusive, the currently checked button is available as checkedButton(). If a button is clicked the buttonClicked() signal is emitted. For a checkable button in an exclusive group this means that the button was checked. The list of buttons in the group is returned by buttons().

In addition, QButtonGroup can map between integers and buttons. You can assign an integer id to a button with setId(), and retrieve it with id(). The id of the currently checked button is available with checkedId(), and there is an overloaded signal buttonClicked() which emits the id of the button. The purpose of the mapping mechanism is to simplify the representation of enum values in a user interface.

See also QGroupBox, QPushButton, QCheckBox, and QRadioButton.


Property Documentation

exclusive : bool

This property holds whether the button group is exclusive.

If this property is true then only one button in the group can be checked at any given time. The user can click on any button to check it, and that button will replace the existing one as the checked button in the group.

In an exclusive group, the user cannot uncheck the currently checked button by clicking on it; instead, another button in the group must be clicked to set the new checked button for that group.

By default, this property is true.

Access functions:

  • bool exclusive () const
  • void setExclusive ( bool )

Member Function Documentation

QButtonGroup::QButtonGroup ( QObject * parent = 0 )

Constructs a new, empty button group with the given parent.

See also addButton() and setExclusive().

QButtonGroup::~QButtonGroup ()

Destroys the button group.

void QButtonGroup::addButton ( QAbstractButton * button )

Adds the given button to the end of the group's internal list of buttons.

See also removeButton().

void QButtonGroup::addButton ( QAbstractButton * button, int id )

This is an overloaded member function, provided for convenience.

Adds the given button to the button group, with the given id.

See also removeButton() and buttons().

QAbstractButton * QButtonGroup::button ( int id ) const

Returns the button with the specified id, or 0 if no such button exists.

This function was introduced in Qt 4.1.

void QButtonGroup::buttonClicked ( QAbstractButton * button )   [signal]

This signal is emitted when the given button is clicked. A button is clicked when it is first pressed and then released, when its shortcut key is typed, or programmatically when QAbstractButton::click() or QAbstractButton::animateClick() is called.

See also checkedButton() and QAbstractButton::clicked().

void QButtonGroup::buttonClicked ( int id )   [signal]

This is an overloaded member function, provided for convenience.

This signal is emitted when a button with the given id is clicked.

See also checkedButton() and QAbstractButton::clicked().

void QButtonGroup::buttonPressed ( QAbstractButton * button )   [signal]

This signal is emitted when the given button is pressed down.

This function was introduced in Qt 4.2.

See also QAbstractButton::pressed().

void QButtonGroup::buttonPressed ( int id )   [signal]

This is an overloaded member function, provided for convenience.

This signal is emitted when a button with the given id is pressed down.

This function was introduced in Qt 4.2.

See also QAbstractButton::pressed().

void QButtonGroup::buttonReleased ( QAbstractButton * button )   [signal]

This signal is emitted when the given button is released.

This function was introduced in Qt 4.2.

See also QAbstractButton::released().

void QButtonGroup::buttonReleased ( int id )   [signal]

This is an overloaded member function, provided for convenience.

This signal is emitted when a button with the given id is released.

This function was introduced in Qt 4.2.

See also QAbstractButton::released().

QList<QAbstractButton *> QButtonGroup::buttons () const

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

See also addButton() and removeButton().

QAbstractButton * QButtonGroup::checkedButton () const

Returns the button group's checked button, or 0 if no buttons are checked.

See also buttonClicked().

int QButtonGroup::checkedId () const

Returns the id of the checkedButton(), or -1 if no button is checked.

This function was introduced in Qt 4.1.

See also setId().

int QButtonGroup::id ( QAbstractButton * button ) const

Returns the id for the specified button, or -1 if no such button exists.

This function was introduced in Qt 4.1.

See also setId().

void QButtonGroup::removeButton ( QAbstractButton * button )

Removes the given button from the button group.

See also addButton() and buttons().

void QButtonGroup::setId ( QAbstractButton * button, int id )

Sets the id for the specified button.

This function was introduced in Qt 4.1.

See also id().

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 82
  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. 2017 : un quinquennat pour une nouvelle version du C++ ? Possible, selon Herb Sutter 6
Page suivante

Le Qt Quarterly au hasard

Logo

Qt Quick sort de la quiétude

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