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  · 

QRadioButton Class Reference

The QRadioButton widget provides a radio button with a text or pixmap label. More...

#include <qradiobutton.h>

Inherits QButton.

List of all member functions.

Public Members

  • QRadioButton ( QWidget * parent, const char * name = 0 )
  • QRadioButton ( const QString & text, QWidget * parent, const char * name = 0 )
  • bool isChecked () const

Public Slots

Important Inherited Members

Properties

  • bool autoMask - whether the radio button is automatically masked  (read only)
  • bool checked - whether the radio button is checked

Detailed Description

The QRadioButton widget provides a radio button with a text or pixmap label.

QRadioButton and QCheckBox are both option buttons. That is, they can be switched on (checked) or off (unchecked). The classes differ in how the choices for the user are restricted. Check boxes define "many of many" choices, whereas radio buttons provide a "one of many" choice. In a group of radio buttons only one radio button at a time can be checked; if the user selects another button, the previously selected button is switched off.

The easiest way to implement a "one of many" choice is simply to put the radio buttons into QButtonGroup.

Whenever a button is switched on or off it emits the signal toggled(). Connect to this signal if you want to trigger an action each time the button changes state. Otherwise, use isChecked() to see if a particular button is selected.

Just like QPushButton, a radio button can display text or a pixmap. The text can be set in the constructor or with setText(); the pixmap is set with setPixmap().

See also QPushButton, QToolButton, GUI Design Handbook: Radio Button, and Basic Widgets.


Member Function Documentation

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

Constructs a radio button with no text.

The parent and name arguments are sent on to the QWidget constructor.

QRadioButton::QRadioButton ( const QString & text, QWidget * parent, const char * name = 0 )

Constructs a radio button with the text text.

The parent and name arguments are sent on to the QWidget constructor.

QKeySequence QButton::accel () const

Returns the accelerator associated with the button. See the "accel" property for details.

bool QButton::autoRepeat () const

Returns TRUE if autoRepeat is enabled; otherwise returns FALSE. See the "autoRepeat" property for details.

void QButton::clicked () [signal]

This signal is emitted when the button is activated (i.e. first pressed down and then released when the mouse cursor is inside the button), when the accelerator key is typed or when animateClick() is called. This signal is not emitted if you call setDown().

The QButtonGroup::clicked() signal does the same job, if you want to connect several buttons to the same slot.

See also pressed(), released(), toggled(), autoRepeat, and down.

Examples: chart/setdataform.cpp, listbox/listbox.cpp, network/clientserver/client/client.cpp, progressbar/progressbar.cpp, richtext/richtext.cpp, t2/main.cpp, and t4/main.cpp.

QButtonGroup * QButton::group () const

Returns the group that this button belongs to.

If the button is not a member of any QButtonGroup, this function returns 0.

See also QButtonGroup.

bool QRadioButton::isChecked () const

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

bool QButton::isDown () const

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

bool QButton::isExclusiveToggle () const

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

bool QButton::isOn () const

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

bool QButton::isToggleButton () const

Returns TRUE if the button is a toggle button; otherwise returns FALSE. See the "toggleButton" property for details.

const QPixmap * QButton::pixmap () const

Returns the pixmap shown on the button. See the "pixmap" property for details.

void QButton::pressed () [signal]

This signal is emitted when the button is pressed down.

See also released() and clicked().

Examples: network/httpd/httpd.cpp and popup/popup.cpp.

void QButton::released () [signal]

This signal is emitted when the button is released.

See also pressed(), clicked(), and toggled().

void QButton::setAccel ( const QKeySequence & ) [virtual]

Sets the accelerator associated with the button. See the "accel" property for details.

void QButton::setAutoRepeat ( bool ) [virtual]

Sets whether autoRepeat is enabled. See the "autoRepeat" property for details.

void QRadioButton::setChecked ( bool check ) [virtual slot]

Sets whether the radio button is checked to check. See the "checked" property for details.

void QButton::setDown ( bool ) [virtual]

Sets whether the button is pressed. See the "down" property for details.

void QButton::setPixmap ( const QPixmap & ) [virtual]

Sets the pixmap shown on the button. See the "pixmap" property for details.

void QButton::setText ( const QString & ) [virtual]

Sets the text shown on the button. See the "text" property for details.

ToggleState QButton::state () const

Returns the state of the toggle button. See the "toggleState" property for details.

void QButton::stateChanged ( int state ) [signal]

This signal is emitted whenever a toggle button changes state. state is On if the button is on, NoChange if it is in the "no change" state or Off if the button is off.

This may be the result of a user action, toggle() slot activation, setState(), or because setOn() was called.

See also clicked() and QButton::ToggleState.

QString QButton::text () const

Returns the text shown on the button. See the "text" property for details.

void QButton::toggle () [slot]

Toggles the state of a toggle button.

See also on, setOn(), toggled(), and toggleButton.

void QButton::toggled ( bool on ) [signal]

This signal is emitted whenever a toggle button changes status. on is TRUE if the button is on, or FALSE if the button is off.

This may be the result of a user action, toggle() slot activation, or because setOn() was called.

See also clicked().

Example: listbox/listbox.cpp.


Property Documentation

QKeySequence accel

This property holds the accelerator associated with the button.

This property is 0 if there is no accelerator set. If you set this property to 0 then any current accelerator is removed.

Set this property's value with setAccel() and get this property's value with accel().

bool autoMask

This property holds whether the radio button is automatically masked.

See also QWidget::autoMask.

bool autoRepeat

This property holds whether autoRepeat is enabled.

If autoRepeat is enabled then the clicked() signal is emitted at regular intervals if the button is down. This property has no effect on toggle buttons. autoRepeat is off by default.

Set this property's value with setAutoRepeat() and get this property's value with autoRepeat().

bool checked

This property holds whether the radio button is checked.

This property will not effect any other radio buttons unless they have been placed in the same QButtonGroup. The default value is FALSE (unchecked).

Set this property's value with setChecked() and get this property's value with isChecked().

QPixmap pixmap

This property holds the pixmap shown on the button.

If the pixmap is monochrome (i.e. it is a QBitmap or its depth is 1) and it does not have a mask, this property will set the pixmap to be its own mask. The purpose of this is to draw transparent bitmaps which are important for toggle buttons, for example.

pixmap() returns 0 if no pixmap was set.

Set this property's value with setPixmap() and get this property's value with pixmap().

QString text

This property holds the text shown on the button.

This property will return a QString::null if the button has no text. If the text has an ampersand (&) in it, then an accelerator is automatically created for it using the character that follows the '&' as the accelerator key.

There is no default text.

Set this property's value with setText() and get this property's value with text().


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. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 94
  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. Pourquoi les programmeurs sont-ils moins payés que les gestionnaires de programmes ? Manquent-ils de pouvoir de négociation ? 42
  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 7
Page suivante

Le blog Digia au hasard

Logo

Créer des applications avec un style Metro avec Qt, exemples en QML et C++, un article de Digia Qt traduit par Thibaut Cuvelier

Le blog Digia est l'endroit privilégié pour la communication sur l'édition commerciale de Qt, où des réponses publiques sont apportées aux questions les plus posées au support. 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