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  · 

Q3ButtonGroup Class Reference

The Q3ButtonGroup widget organizes QAbstractButton widgets in a group. More...

 #include <Q3ButtonGroup>

This class is part of the Qt 3 support library. It is provided to keep old source code working. We strongly advise against using it in new code. See Porting to Qt 4 for more information.

Inherits: Q3GroupBox.

Inherited by: Q3HButtonGroup and Q3VButtonGroup.

Properties

Public Functions

Q3ButtonGroup ( QWidget * parent = 0, const char * name = 0 )
Q3ButtonGroup ( const QString & title, QWidget * parent = 0, const char * name = 0 )
Q3ButtonGroup ( int strips, Qt::Orientation orientation, QWidget * parent = 0, const char * name = 0 )
Q3ButtonGroup ( int strips, Qt::Orientation orientation, const QString & title, QWidget * parent = 0, const char * name = 0 )
~Q3ButtonGroup ()
int count () const
QAbstractButton * find ( int id ) const
int id ( QAbstractButton * button ) const
int insert ( QAbstractButton * button, int id = -1 )
bool isExclusive () const
bool isRadioButtonExclusive () const
void remove ( QAbstractButton * button )
QAbstractButton * selected () const
int selectedId () const
void setButton ( int id )
void setExclusive ( bool )
void setRadioButtonExclusive ( bool )
  • 22 public functions inherited from Q3GroupBox
  • 10 public functions inherited from QGroupBox
  • 217 public functions inherited from QWidget
  • 29 public functions inherited from QObject
  • 13 public functions inherited from QPaintDevice

Signals

void clicked ( int id )
void pressed ( int id )
void released ( int id )

Reimplemented Protected Functions

virtual bool event ( QEvent * e )
  • 4 protected functions inherited from Q3GroupBox
  • 10 protected functions inherited from QGroupBox
  • 37 protected functions inherited from QWidget
  • 7 protected functions inherited from QObject
  • 1 protected function inherited from QPaintDevice

Additional Inherited Members

  • 1 public slot inherited from QGroupBox
  • 19 public slots inherited from QWidget
  • 1 public slot inherited from QObject
  • 4 static public members inherited from QWidget
  • 5 static public members inherited from QObject
  • 4 protected functions inherited from Q3GroupBox
  • 10 protected functions inherited from QGroupBox
  • 37 protected functions inherited from QWidget
  • 7 protected functions inherited from QObject
  • 1 protected function inherited from QPaintDevice
  • 1 protected slot inherited from QWidget

Detailed Description

The Q3ButtonGroup widget organizes QAbstractButton 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 Q3ButtonGroup can display a frame and a title because it inherits Q3GroupBox.
  • 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, and QRadioButton.

Property Documentation

exclusive : bool

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.

Access functions:

bool isExclusive () const
void setExclusive ( bool )

radioButtonExclusive : bool

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

If this property is true (the default), the radio buttons in the group are treated exclusively.

Access functions:

bool isRadioButtonExclusive () const
void setRadioButtonExclusive ( bool )

selectedId : int

This property holds the id of the selected toggle button.

If no toggle button is selected, id() returns -1.

If setButton() is called on an exclusive group, the button with the given id will be set to on and all the others will be set to off.

Access functions:

int selectedId () const
void setButton ( int id )

See also selected().

Member Function Documentation

Q3ButtonGroup::Q3ButtonGroup ( 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.

Q3ButtonGroup::Q3ButtonGroup ( 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.

Q3ButtonGroup::Q3ButtonGroup ( int strips, Qt::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.

Q3ButtonGroup::Q3ButtonGroup ( int strips, Qt::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.

Q3ButtonGroup::~Q3ButtonGroup ()

Destructor.

void Q3ButtonGroup::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().

int Q3ButtonGroup::count () const

Returns the number of buttons in the group.

bool Q3ButtonGroup::event ( QEvent * e ) [virtual protected]

Reimplemented from QObject::event().

QAbstractButton * Q3ButtonGroup::find ( int id ) const

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

int Q3ButtonGroup::id ( QAbstractButton * button ) const

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

See also selectedId().

int Q3ButtonGroup::insert ( QAbstractButton * 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 setExclusive().

void Q3ButtonGroup::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 Q3ButtonGroup::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 Q3ButtonGroup::remove ( QAbstractButton * button )

Removes the button from the button group.

See also insert().

QAbstractButton * Q3ButtonGroup::selected () const

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

See also selectedId().

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 102
  2. Pourquoi les programmeurs sont-ils moins payés que les gestionnaires de programmes ? Manquent-ils de pouvoir de négociation ? 53
  3. «Le projet de loi des droits du développeur» : quelles conditions doivent remplir les entreprises pour que le développeur puisse réussir ? 82
  4. Les développeurs détestent-ils les antivirus ? Un programmeur manifeste sa haine envers ces solutions de sécurité 28
  5. Qt Commercial : Digia organise un webinar gratuit le 27 mars sur la conception d'interfaces utilisateur et d'applications avec le framework 0
  6. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  7. 2017 : un quinquennat pour une nouvelle version du C++ ? Possible, selon Herb Sutter 11
Page suivante
  1. Linus Torvalds : le "C++ est un langage horrible", en justifiant le choix du C pour le système de gestion de version Git 100
  2. Comment prendre en compte l'utilisateur dans vos applications ? Pour un développeur, « 90 % des utilisateurs sont des idiots » 229
  3. Quel est LE livre que tout développeur doit lire absolument ? Celui qui vous a le plus marqué et inspiré 96
  4. Apple cède et s'engage à payer des droits à Nokia, le conflit des brevets entre les deux firmes s'achève 158
  5. Nokia porte à nouveau plainte contre Apple pour violation de sept nouveaux brevets 158
  6. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 102
  7. Quel est le code dont vous êtes le plus fier ? Pourquoi l'avez-vous écrit ? Et pourquoi vous a-t-il donné autant de satisfaction ? 83
Page suivante

Le Qt Labs au hasard

Logo

Améliorer les performances de Qt avec les chaînes de caractères avec SIMD... ou pas

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 4.7-snapshot
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