QRadioButton Class
The QRadioButton widget provides a radio button with a text label. More...
Header: | #include <QRadioButton> |
qmake: | QT += widgets |
Inherits: | QAbstractButton |
Public Functions
QRadioButton(const QString &text, QWidget *parent = nullptr) | |
QRadioButton(QWidget *parent = nullptr) | |
virtual | ~QRadioButton() |
Reimplemented Public Functions
virtual QSize | minimumSizeHint() const override |
virtual QSize | sizeHint() const override |
- 21 public functions inherited from QAbstractButton
- 214 public functions inherited from QWidget
- 30 public functions inherited from QObject
- 14 public functions inherited from QPaintDevice
Protected Functions
void | initStyleOption(QStyleOptionButton *option) const |
Reimplemented Protected Functions
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 |
- 14 protected functions inherited from QAbstractButton
- 35 protected functions inherited from QWidget
- 9 protected functions inherited from QObject
- 1 protected function inherited from QPaintDevice
Related Non-Members
typedef | QObjectList |
QList<T> | qFindChildren(const QObject *obj, const QRegExp ®Exp) |
T | qobject_cast(QObject *object) |
T | qobject_cast(const QObject *object) |
Macros
QT_NO_NARROWING_CONVERSIONS_IN_CONNECT | |
QWIDGETSIZE_MAX | |
Q_CLASSINFO(Name, Value) | |
Q_DISABLE_COPY(Class) | |
Q_DISABLE_COPY_MOVE(Class) | |
Q_DISABLE_MOVE(Class) | |
Q_EMIT | |
Q_ENUM(...) | |
Q_ENUM_NS(...) | |
Q_FLAG(...) | |
Q_FLAG_NS(...) | |
Q_GADGET | |
Q_INTERFACES(...) | |
Q_INVOKABLE | |
Q_NAMESPACE | |
Q_OBJECT | |
Q_PROPERTY(...) | |
Q_REVISION | |
Q_SET_OBJECT_NAME(Object) | |
Q_SIGNAL | |
Q_SIGNALS | |
Q_SLOT | |
Q_SLOTS |
Additional Inherited Members
- 11 properties inherited from QAbstractButton
- 59 properties inherited from QWidget
- 1 property inherited from QObject
- 5 public slots inherited from QAbstractButton
- 19 public slots inherited from QWidget
- 1 public slot inherited from QObject
- 4 signals inherited from QAbstractButton
- 3 signals inherited from QWidget
- 2 signals inherited from QObject
- 5 static public members inherited from QWidget
- 9 static public members inherited from QObject
- 1 protected slot inherited from QWidget
Detailed Description
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, GUI Design Handbook: Radio Button, and Group Box Example.
Member Function Documentation
QRadioButton::QRadioButton(const QString &text, QWidget *parent = nullptr)
Constructs a radio button with the given parent and text string.
The parent argument is passed on to the QAbstractButton constructor.
QRadioButton::QRadioButton(QWidget *parent = nullptr)
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) const
Reimplements: QAbstractButton::hitButton(const QPoint &pos) const.
[protected]
void QRadioButton::initStyleOption(QStyleOptionButton *option) const
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().
[override virtual]
QSize QRadioButton::minimumSizeHint() const
Reimplements: QWidget::minimumSizeHint() const.
[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() const
Reimplements: QWidget::sizeHint() const.