The QRadioButton widget provides a radio button with a text label. More...
Header: | #include <QRadioButton> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS Widgets) target_link_libraries(mytarget PRIVATE Qt6::Widgets) |
qmake: | QT += widgets |
Inherits: | QAbstractButton |
QRadioButton(const QString &text, QWidget *parent = nullptr) | |
QRadioButton(QWidget *parent = nullptr) | |
virtual | ~QRadioButton() |
virtual QSize | minimumSizeHint() const override |
virtual QSize | sizeHint() const override |
virtual void | initStyleOption(QStyleOptionButton *option) const |
virtual bool | event(QEvent *e) override |
virtual bool | hitButton(const QPoint &pos) const override |
virtual void | mouseMoveEvent(QMouseEvent *e) override |
virtual void | paintEvent(QPaintEvent *) override |
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().
See also QPushButton, QToolButton, QCheckBox, and Group Box Example.
Constructs a radio button with the given parent and text string.
The parent argument is passed on to the QAbstractButton constructor.
Constructs a radio button with the given parent, but with no text or pixmap.
The parent argument is passed on to the QAbstractButton constructor.
[virtual]
QRadioButton::~QRadioButton()Destructor.
[override virtual protected]
bool QRadioButton::event(QEvent *e)Reimplements: QAbstractButton::event(QEvent *e).
[override virtual protected]
bool QRadioButton::hitButton(const QPoint
&pos) constReimplements: QAbstractButton::hitButton(const QPoint &pos) const.
[virtual protected]
void QRadioButton::initStyleOption(QStyleOptionButton *option) constInitialize 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().
[override virtual]
QSize QRadioButton::minimumSizeHint() constReimplements an access function for property: QWidget::minimumSizeHint.
[override virtual protected]
void QRadioButton::mouseMoveEvent(QMouseEvent *e)Reimplements: QAbstractButton::mouseMoveEvent(QMouseEvent *e).
[override virtual protected]
void QRadioButton::paintEvent(QPaintEvent
*)Reimplements: QAbstractButton::paintEvent(QPaintEvent *e).
[override virtual]
QSize QRadioButton::sizeHint() constReimplements an access function for property: QWidget::sizeHint.