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  ·  Modules  ·  Fonctions  · 

QRadioButton Class

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

 #include <QRadioButton>

Inherits: QAbstractButton.

Public Types

enum PaintDeviceMetric { PdmWidth, PdmHeight, PdmWidthMM, PdmHeightMM, ..., PdmPhysicalDpiY }

Properties

  • 58 properties inherited from QWidget
  • 1 property inherited from QObject

Public Functions

QAbstractButton(QWidget * parent = 0)
QRadioButton(QWidget * parent = 0)
QRadioButton(const QString & text, QWidget * parent = 0)
~QAbstractButton()
virtual ~QPaintDevice()
bool autoExclusive() const
bool autoRepeat() const
int autoRepeatDelay() const
int autoRepeatInterval() const
int colorCount() const
int depth() const
QButtonGroup * group() const
int height() const
int heightMM() const
QIcon icon() const
QSize iconSize() const
bool isCheckable() const
bool isChecked() const
bool isDown() const
int logicalDpiX() const
int logicalDpiY() const
virtual QPaintEngine * paintEngine() const = 0
bool paintingActive() const
int physicalDpiX() const
int physicalDpiY() const
void setAutoExclusive(bool)
void setAutoRepeat(bool)
void setAutoRepeatDelay(int)
void setAutoRepeatInterval(int)
void setCheckable(bool)
void setDown(bool)
void setIcon(const QIcon & icon)
void setShortcut(const QKeySequence & key)
void setText(const QString & text)
QKeySequence shortcut() const
QString text() const
int width() const
int widthMM() const

Reimplemented Public Functions

virtual QSize minimumSizeHint() const
virtual QSize sizeHint() const
  • 215 public functions inherited from QWidget
  • 31 public functions inherited from QObject

Public Slots

void animateClick(int msec = 100)
void click()
void setChecked(bool)
void setIconSize(const QSize & size)
void toggle()
  • 19 public slots inherited from QWidget
  • 1 public slot inherited from QObject

Signals

void clicked(bool checked = false)
void pressed()
void released()
void toggled(bool checked)

Protected Functions

QPaintDevice()
virtual void changeEvent(QEvent * e)
virtual void checkStateSet()
virtual bool event(QEvent * e)
virtual void focusInEvent(QFocusEvent * e)
virtual void focusOutEvent(QFocusEvent * e)
virtual bool hitButton(const QPoint & pos) const
virtual void init(QPainter * painter) const
void initStyleOption(QStyleOptionButton * option) const
virtual void keyPressEvent(QKeyEvent * e)
virtual void keyReleaseEvent(QKeyEvent * e)
virtual int metric(PaintDeviceMetric metric) const
virtual void mouseMoveEvent(QMouseEvent * e)
virtual void mousePressEvent(QMouseEvent * e)
virtual void mouseReleaseEvent(QMouseEvent * e)
virtual void nextCheckState()
virtual void paintEvent(QPaintEvent * e) = 0
virtual QPaintDevice * redirected(QPoint * offset) const
virtual QPainter * sharedPainter() const
virtual void timerEvent(QTimerEvent * e)

Reimplemented Protected Functions

virtual bool event(QEvent * e)
virtual bool hitButton(const QPoint & pos) const
virtual void mouseMoveEvent(QMouseEvent * e)
virtual void paintEvent(QPaintEvent *)
  • 37 protected functions inherited from QWidget
  • 9 protected functions inherited from QObject

Additional Inherited Members

  • 4 static public members inherited from QWidget
  • 11 static public members inherited from QObject
  • 1 protected slot inherited from QWidget

Detailed Description

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

A QRadioButton is an option button that can be switched on (checked) or off (unchecked). Radio buttons typically present the user with 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.

Radio buttons are autoExclusive by default. If auto-exclusive is enabled, radio buttons that belong to the same parent widget behave as if they were part of the same exclusive button group. If you need multiple exclusive button groups for radio buttons that belong to the same parent widget, put them into a QButtonGroup.

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

Just like QPushButton, a radio button displays text, and optionally a small icon. The icon is set with setIcon(). The text can be set in the constructor or with setText(). A shortcut key can be specified by preceding the preferred character with an ampersand in the text. For example:

 QRadioButton *button = new QRadioButton("Search from the &cursor", this);

In this example the shortcut is Alt+c. See the QShortcut documentation for details (to display an actual ampersand, use '&&').

Important inherited members: text(), setText(), text(), setDown(), isDown(), autoRepeat(), group(), setAutoRepeat(), toggle(), pressed(), released(), clicked(), and toggled().

Screenshot of a Plastique radio buttonA radio button shown in the Plastique widget style.
Screenshot of a Windows XP radio buttonA radio button shown in the Windows XP widget style.
Screenshot of a Macintosh radio buttonA radio button shown in the Macintosh widget style.

See also QPushButton, QToolButton, QCheckBox, GUI Design Handbook: Radio Button, and Group Box Example.

Member Function Documentation

QRadioButton::QRadioButton(QWidget * parent = 0)

Constructs a radio button with the given parent, but with no text or pixmap.

The parent argument is passed on to the QAbstractButton constructor.

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

Constructs a radio button with the given parent and a text string.

The parent argument is passed on to the QAbstractButton constructor.

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

Reimplemented from QObject::event().

bool QRadioButton::hitButton(const QPoint & pos) const [virtual protected]

Reimplemented from QAbstractButton::hitButton().

void QRadioButton::initStyleOption(QStyleOptionButton * option) const [protected]

Initialize option with the values from this QRadioButton. This method is useful for subclasses when they need a QStyleOptionButton, but don't want to fill in all the information themselves.

See also QStyleOption::initFrom().

QSize QRadioButton::minimumSizeHint() const [virtual]

Reimplemented from QWidget::minimumSizeHint().

void QRadioButton::mouseMoveEvent(QMouseEvent * e) [virtual protected]

Reimplemented from QWidget::mouseMoveEvent().

void QRadioButton::paintEvent(QPaintEvent *) [virtual protected]

Reimplemented from QWidget::paintEvent().

QSize QRadioButton::sizeHint() const [virtual]

Reimplemented from QWidget::sizeHint().

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 5.0-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