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  ·  Classes  ·  Annotées  ·  Hiérarchie  ·  Fonctions  ·  Structure  · 

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

  • QButtonGroup ( QWidget * parent=0, const char * name=0 ) 
  • QButtonGroup ( const QString & title, QWidget * parent=0, const char * name=0 ) 
  • QButtonGroup ( int columns, Orientation o, QWidget * parent=0, const char * name=0 ) 
  • QButtonGroup ( int columns, Orientation o, const QString & title, QWidget * parent=0, const char * name=0 ) 
  • bool isExclusive () const
  • bool isRadioButtonExclusive () const
  • virtual void setExclusive ( bool ) 
  • virtual void setRadioButtonExclusive ( bool ) 
  • int insert ( QButton *, int id=-1 ) 
  • void remove ( QButton * ) 
  • QButton* find ( int id ) const
  • int id ( QButton * ) const
  • int count () const
  • virtual void setButton ( int id ) 
  • virtual void moveFocus ( int ) 
  • QButton* selected () 

Signals

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

Protected Slots

  • void buttonPressed () (internal)
  • void buttonReleased () (internal)
  • void buttonClicked () (internal)
  • void buttonToggled ( bool on ) (internal)

Properties

TypeNameREADWRITEOptions
boolexclusiveisExclusivesetExclusive 
boolradioButtonExclusiveisRadioButtonExclusivesetRadioButtonExclusive 

Detailed Description

The QButtonGroup widget organizes QButton widgets in a group.

A button group widget makes it easier to deal with groups of buttons. A button in a button group is associated with a unique identifer. The button group emits a clicked() signal with this identifier when the button is clicked. Thus, a button group is an ideal solution when you have several similar buttons and want to connect all their clicked() signals, for example, to one slot.

An exclusive button group switches off all toggle buttons except the one that was clicked. A button group is by default non-exclusive. All radio buttons that are inserted, will be mutually exclusive even if the button group is non-exclusive.

There are two ways of using a button group:

  1. The button group is a 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.
  2. The button group is an invisible widget and the contained buttons have some other parent widget. A button must then be manually inserted using the insert() function with an identifer.

See also QButton, QPushButton, QCheckBox and QRadioButton.

Examples: xform/xform.cpp i18n/main.cpp drawdemo/drawdemo.cpp


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

Reimplemented for internal reasons; the API is not affected.

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.

int QButtonGroup::count () const

Returns the number of buttons in the group.

QButton * QButtonGroup::find ( int id ) const

Finds and returns a pointer to the button with the specified identifier id.

Returns null 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.

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

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

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.

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.

Inserting several buttons with id = -1 assigns the identifiers 0, 1, 2, etc.

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

Examples: xform/xform.cpp

bool QButtonGroup::isExclusive () const

Returns TRUE if the button group is exclusive, otherwise FALSE.

See also setExclusive().

bool QButtonGroup::isRadioButtonExclusive () const

Returns whether this button group will treat radio buttons as mutually exclusive. The default is TRUE.

See also setRadioButtonExclusive().

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.

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.

void QButtonGroup::remove ( QButton * button )

Removes a button from the button group.

See also insert().

QButton * QButtonGroup::selected ()

Returns a pointer to the selected radio button in this group, if one exists, or 0 if there is no selected radio button in this group.

Warning: In future versions of Qt, the selected toggle button will be returned.

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

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

void QButtonGroup::setExclusive ( bool enable ) [virtual]

Sets the button group to be exclusive if enable is TRUE, or to be non-exclusive if enable is FALSE.

An exclusive button group switches off all other toggle buttons when one is switched on. This is ideal for groups of radio buttons. A non-exclusive group allow many buttons to be switched on at the same time.

The default setting is FALSE.

See also isExclusive().

void QButtonGroup::setRadioButtonExclusive ( bool on ) [virtual]

If on is TRUE, this button group will treat radio buttons as mutually exclusive, and other buttons according to isExclusive().

void QButtonGroup::buttonClicked () [protected slot]

For internal use only.

void QButtonGroup::buttonPressed () [protected slot]

For internal use only.

void QButtonGroup::buttonReleased () [protected slot]

For internal use only.

void QButtonGroup::buttonToggled ( bool on ) [protected slot]

For internal use only.


Search the documentation, FAQ, qt-interest archive and more (uses www.trolltech.com):


This file is part of the Qt toolkit, copyright © 1995-2005 Trolltech, all rights reserved.

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 Labs au hasard

Logo

Utiliser OpenCL avec Qt

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