Home | All Classes | Main Classes | Annotated | Grouped Classes | Functions |

# QRadioButton Class Reference

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

    #include <QRadioButton>

Inherits QAbstractButton.

- List of all members, including inherited members
- Compatibility members

### Writable Properties

- 8 writable properties inherited from QAbstractButton
- 33 writable properties inherited from QWidget
- 1 writable property inherited from QObject

### Read-Only Properties

- autoExclusive : bool
- autoMask : bool

- 24 read-only properties inherited from QWidget

### Public Functions

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

- 1 public function inherited from QAbstractButton
- 83 public functions inherited from QWidget
- 24 public functions inherited from QObject
- 2 public functions inherited from QPaintDevice

### Public Slots

- 4 public slots inherited from QAbstractButton
- 16 public slots inherited from QWidget
- 1 public slot inherited from QObject

### Signals

- 4 signals inherited from QAbstractButton
- 1 signal inherited from QObject

### Static Public Members

- 4 static public members inherited from QWidget
- 4 static public members inherited from QObject

### Protected Functions

- void drawBevel ( QPainter * p )
- void drawLabel ( QPainter * p )
- virtual void paintEvent ( QPaintEvent * event )

- 3 protected functions inherited from QAbstractButton
- 44 protected functions inherited from QWidget
- 9 protected functions inherited from QObject

## Detailed Description

The QRadioButton widget provides a radio button with a text or pixmap 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 autoExclusive 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. 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().

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

GUI Design Handbook: Radio Button

See also QPushButton, QToolButton, and QCheckBox.

## Property Documentation

### autoExclusive : bool

This property holds whether the radio button is automatically exclusive.

If the radio button is exclusive, it will be deselected if another in the same group is enabled. Similarly, if it is selected, other exclusive buttons in the same group will be deselected.

The default is true.

### autoMask : bool

This property holds whether the radio button is automatically masked.

See also QWidget::setAutoMask().

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

### void QRadioButton::drawBevel ( QPainter * p ) `[protected]`

Draws the radio button bevel on painter p. Called from paintEvent().

See also drawLabel().

### void QRadioButton::drawLabel ( QPainter * p ) `[protected]`

Draws the radio button label on painter p. Called from paintEvent().

See also drawBevel().

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

Paints the button in response to the paint event, by first calling drawBevel() and then drawLabel(). If you reimplement paintEvent() just to draw a different label, you can call drawBevel() from your own code. For example:

        QPainter p(this);
        drawBevel(&p);
        // ... your label drawing code

Reimplemented from QWidget.