QRadioButton Class
The QRadioButton class provides a radio button with a text label. More…
| Header | #include <QRadioButton> |
|---|---|
| CMake | target_link_libraries(app PRIVATE Nt::Widgets) |
| Module | Nt Widgets C++ Classes |
| Inherits | QAbstractButton |
List of all members, including inherited members
Public Functions
| QRadioButton(QWidget *parent = nullptr) | |
| QRadioButton(const QString &text, QWidget *parent = nullptr) | |
| ~QRadioButton() |
Reimplemented Public Functions
Reimplemented Protected Functions
| void | paintEvent(QPaintEvent *event) |
| bool | hitButton(const QPoint &pos) const |
| void | keyPressEvent(QKeyEvent *event) |
Detailed Description
Radio buttons that have the same parent widget form a group in which only one is checked: checking one unchecks the others. Put the buttons of a group in a QGroupBox, or in a widget of their own, to have several groups in a window. The arrow keys move the choice from one button of the group to the next.
QGroupBox *size = new QGroupBox("Size", window);
QRadioButton *small = new QRadioButton("Small", size);
QRadioButton *large = new QRadioButton("Large", size);
small->setChecked(true);
Radio buttons: not chosen, chosen, with the keyboard focus, and disabled.

See also QAbstractButton, QCheckBox and QGroupBox.
Differences from Qt
Groups are made by the parent widget only; there is no QButtonGroup.
Member Function Documentation
QRadioButton::QRadioButton(QWidget *parent = nullptr)
Constructs a radio button with no text and the given parent.
QRadioButton::QRadioButton(const QString &text, QWidget *parent = nullptr)
Constructs a radio button that shows text, with the given parent.
QRadioButton::~QRadioButton()
Destroys the radio button.
bool QRadioButton::hitButton(const QPoint &pos) const
Reimplements QAbstractButton::hitButton().
void QRadioButton::keyPressEvent(QKeyEvent *event)
Reimplements QAbstractButton::keyPressEvent().
void QRadioButton::paintEvent(QPaintEvent *event)
Reimplements QAbstractButton::paintEvent().
QSize QRadioButton::sizeHint() const
Reimplements QAbstractButton::sizeHint().