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  ·  Classes principales  ·  Annotées  ·  Classes groupées  ·  Fonctions  · 

QButtonGroup Class Reference

The QButtonGroup widget organizes QButton widgets in a group. More...

#include <qbuttongroup.h>

Inherits QGroupBox.

Inherited by QHButtonGroup and QVButtonGroup.

List of all member functions.

Public Members

Signals

Properties


Detailed Description

The QButtonGroup widget organizes QButton widgets in a group.

A button group widget makes it easier to deal with groups of buttons. Each button in a button group has a unique identifier. The button group emits a clicked() signal with this identifier when a button in the group is clicked. This makes a button group particularly useful when you have several similar buttons and want to connect all their clicked() signals to a single slot.

An exclusive button group switches off all toggle buttons except the one that was clicked. A button group is, by default, non-exclusive. Note that all radio buttons that are inserted into a button group are mutually exclusive even if the button group is non-exclusive. (See setRadioButtonExclusive().)

There are two ways of using a button group:

  • The button group is the parent widget of a number of buttons, i.e. the button group is the parent argument in the button constructor. The buttons are assigned identifiers 0, 1, 2, etc., in the order they are created. A QButtonGroup can display a frame and a title because it inherits QGroupBox.
  • The button group is an invisible widget and the contained buttons have some other parent widget. In this usage, each button must be manually inserted, using insert(), into the button group and given an identifier.

A button can be removed from the group with remove(). A pointer to a button with a given id can be obtained using find(). The id of a button is available using id(). A button can be set on with setButton(). The number of buttons in the group is returned by count().

See also QPushButton, QCheckBox, QRadioButton, Widget Appearance and Style, Layout Management, and Organizers.


Member Function Documentation

QButtonGroup::QButtonGroup ( QWidget * parent = 0, const char * name = 0 )

Constructs a button group with no title.

The parent and name arguments are passed to the QWidget constructor.

QButtonGroup::QButtonGroup ( const QString & title, QWidget * parent = 0, const char * name = 0 )

Constructs a button group with the title title.

The parent and name arguments are passed to the QWidget constructor.

QButtonGroup::QButtonGroup ( int strips, Orientation orientation, QWidget * parent = 0, const char * name = 0 )

Constructs a button group with no title. Child widgets will be arranged in strips rows or columns (depending on orientation).

The parent and name arguments are passed to the QWidget constructor.

QButtonGroup::QButtonGroup ( int strips, Orientation orientation, const QString & title, QWidget * parent = 0, const char * name = 0 )

Constructs a button group with title title. Child widgets will be arranged in strips rows or columns (depending on orientation).

The parent and name arguments are passed to the QWidget constructor.

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

This signal is emitted when a button in the group is clicked. The id argument is the button's identifier.

See also insert().

Examples: drawdemo/drawdemo.cpp and xform/xform.cpp.

int QButtonGroup::count () const

Returns the number of buttons in the group.

QButton * QButtonGroup::find ( int id ) const

Returns the button with the specified identifier id, or 0 if the button was not found.

int QButtonGroup::id ( QButton * button ) const

Returns the id of button, or -1 if button is not a member of this group.

See also selectedId().

int QButtonGroup::insert ( QButton * button, int id = -1 )

Inserts the button with the identifier id into the button group. Returns the button identifier.

Buttons are normally inserted into a button group automatically by passing the button group as the parent when the button is constructed. So it is not necessary to manually insert buttons that have this button group as their parent widget. An exception is when you want custom identifiers instead of the default 0, 1, 2, etc., or if you want the buttons to have some other parent.

The button is assigned the identifier id or an automatically generated identifier. It works as follows: If id >= 0, this identifier is assigned. If id == -1 (default), the identifier is equal to the number of buttons in the group. If id is any other negative integer, for instance -2, a unique identifier (negative integer <= -2) is generated. No button has an id of -1.

See also find(), remove(), and exclusive.

Examples: listbox/listbox.cpp and xform/xform.cpp.

bool QButtonGroup::isExclusive () const

Returns TRUE if the button group is exclusive; otherwise returns FALSE. See the "exclusive" property for details.

bool QButtonGroup::isRadioButtonExclusive () const

Returns TRUE if the radio buttons in the group are exclusive; otherwise returns FALSE. See the "radioButtonExclusive" property for details.

void QButtonGroup::moveFocus ( int key ) [virtual]

Moves the keyboard focus according to key, and if appropriate checks the new focus item.

This function does nothing unless the keyboard focus points to one of the button group members and key is one of Key_Up, Key_Down, Key_Left and Key_Right.

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

This signal is emitted when a button in the group is pressed. The id argument is the button's identifier.

See also insert().

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

This signal is emitted when a button in the group is released. The id argument is the button's identifier.

See also insert().

void QButtonGroup::remove ( QButton * button )

Removes the button from the button group.

See also insert().

QButton * QButtonGroup::selected () const

Returns the selected toggle button if exactly one is selected; otherwise returns 0.

See also selectedId().

int QButtonGroup::selectedId () const

Returns the id of the selected toggle button if exactly one is selected; otherwise returns -1.

See also selected().

void QButtonGroup::setButton ( int id ) [virtual]

Sets the button with id id to be on; if this is an exclusive group, all the other buttons in the group will be set to off.

void QButtonGroup::setExclusive ( bool ) [virtual]

Sets whether the button group is exclusive. See the "exclusive" property for details.

void QButtonGroup::setRadioButtonExclusive ( bool ) [virtual]

Sets whether the radio buttons in the group are exclusive. See the "radioButtonExclusive" property for details.


Property Documentation

bool exclusive

This property holds whether the button group is exclusive.

If this property is TRUE, then the buttons in the group are toggled, and to untoggle a button you must click on another button in the group. The default value is FALSE.

Set this property's value with setExclusive() and get this property's value with isExclusive().

bool radioButtonExclusive

This property holds whether the radio buttons in the group are exclusive.

If this property is TRUE (the default), the radiobuttons in the group are treated exclusively.

Set this property's value with setRadioButtonExclusive() and get this property's value with isRadioButtonExclusive().


This file is part of the Qt toolkit. Copyright © 1995-2003 Trolltech. All Rights Reserved.

Publicité

Best Of

Actualités les plus lues

Semaine
Mois
Année
  1. Microsoft ouvre aux autres compilateurs C++ AMP, la spécification pour la conception d'applications parallèles C++ utilisant le GPU 22
  2. Les développeurs ignorent-ils trop les failles découvertes dans leur code ? Prenez-vous en compte les remarques des autres ? 17
  3. RIM : « 13 % des développeurs ont gagné plus de 100 000 $ sur l'AppWord », Qt et open-source au menu du BlackBerry DevCon Europe 0
  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. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 10
  6. Adieu qmake, bienvenue qbs : Qt Building Suite, un outil déclaratif et extensible pour la compilation de projets Qt 17
  7. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
Page suivante

Le Qt Labs au hasard

Logo

La folie est de mettre en forme le même texte

Les Qt Labs sont les laboratoires des développeurs de Qt, où ils peuvent partager des impressions sur le framework, son utilisation, ce que pourrait être son futur. 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 3.2
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