6.0.0-rc4Source

QRadioButton Class

The QRadioButton class provides a radio button with a text label. More…

Header#include <QRadioButton>
CMaketarget_link_libraries(app PRIVATE Nt::Widgets)
ModuleNt Widgets C++ Classes
InheritsQAbstractButton

List of all members, including inherited members

Public Functions

QRadioButton(QWidget *parent = nullptr)
QRadioButton(const QString &text, QWidget *parent = nullptr)
~QRadioButton()

Reimplemented Public Functions

QSizesizeHint() const

Reimplemented Protected Functions

voidpaintEvent(QPaintEvent *event)
boolhitButton(const QPoint &pos) const
voidkeyPressEvent(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.

QRadioButton in the light color scheme

See also QAbstractButton, QCheckBox and QGroupBox.

Differences from Qt

Groups are made by the parent widget only; there is no QButtonGroup.

Member Function Documentation

[explicit] QRadioButton::QRadioButton(QWidget *parent = nullptr)

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

[explicit] QRadioButton::QRadioButton(const QString &text, QWidget *parent = nullptr)

Constructs a radio button that shows text, with the given parent.

[override] QRadioButton::~QRadioButton()

Destroys the radio button.

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

Reimplements QAbstractButton::hitButton().

[override, protected] void QRadioButton::keyPressEvent(QKeyEvent *event)

Reimplements QAbstractButton::keyPressEvent().

[override, protected] void QRadioButton::paintEvent(QPaintEvent *event)

Reimplements QAbstractButton::paintEvent().

[override] QSize QRadioButton::sizeHint() const

Reimplements QAbstractButton::sizeHint().