QRadioButton Class
QRadioButton 提供一个带有文本标签的单选按钮. 更多...
头文件: | #include <QRadioButton> |
qmake: | QT += widgets |
基类: | QAbstractButton |
公有函数
QRadioButton(QWidget *parent = Q_NULLPTR) | |
QRadioButton(const QString &text, QWidget *parent = Q_NULLPTR) | |
~QRadioButton() |
重新实现的公有函数
virtual QSize | minimumSizeHint() const |
virtual QSize | sizeHint() const |
- 21 个公有函数继承自 QAbstractButton
- 214 个公有函数继承自 QWidget
- 32 个公有函数继承自 QObject
- 14 个公有函数继承自 QPaintDevice
受保护的函数
void | initStyleOption(QStyleOptionButton *option) const |
重新实现的受保护函数
virtual bool | event(QEvent *e) |
virtual bool | hitButton(const QPoint &pos) const |
virtual void | mouseMoveEvent(QMouseEvent *e) |
virtual void | paintEvent(QPaintEvent *) |
- 14 个受保护的函数继承自 QAbstractButton
- 35 个受保护的函数继承自 QWidget
- 9 个受保护的函数继承自 QObject
- 1 个受保护的函数继承自 QPaintDevice
其他继承的成员
- 11 个属性继承自 QAbstractButton
- 59 个属性继承自 QWidget
- 1 个属性继承自 QObject
- 5 个公有槽函数继承自 QAbstractButton
- 19 个公有槽函数继承自 QWidget
- 1 个公有槽函数继承自 QObject
- 4 个信号继承自 QAbstractButton
- 3 个信号继承自 QWidget
- 2 个信号继承自 QObject
- 1 个公有变量继承自 QObject
- 5 个静态公有成员继承自 QWidget
- 10 个静态公有成员继承自 QObject
- 1 个受保护的槽函数继承自 QWidget
- 2 个受保护的变量继承自 QObject
- 1 protected type inherited from QPaintDevice
详细描述
QRadioButton 提供一个带有文本标签的单选按钮.
QRadioButton 是一个可以打开(选中)或关闭(未选中)的选择按钮. 单选按钮表示 "多种选项中选中一个选项" . 一组单选按钮仅能一次选中一个; 如果用户选择一个单选按钮, 自动清除之前选中的按钮.
单选按钮默认 自动互斥 . 如果开启自动互斥, 具有相同父对象的单选按钮自动互斥. 如果你需要为具有相同父对象的按钮创建多个互斥分组, 你可以使用 QButtonGroup.
一个按钮被打开或者关闭时会发送信号 toggled() . 如果你想在单选按钮每次状态更改时触发一个动作, 你可以连接这个信号. 使用 isChecked() 查询单选按钮是否被选中.
J类似 QPushButton, 单选按钮可以显示文本及可选的小图标. 调用 setIcon()设置图标. 采用构造函数传值或调用 setText()设置文本. 快捷键也是通过前缀&设置. 例如::
QRadioButton *button = new QRadioButton("Search from the &cursor", this);
上述示例中, 快捷键是 Alt+A. 详见 QShortcut 文档. 使用'&&'显示&.
重要的继承函数: text(), setText(), text(), setDown(), isDown(), autoRepeat(), group(), setAutoRepeat(), toggle(), pressed(), released(), clicked(), and toggled().
![]() | A radio button shown in the Fusion widget style. |
![]() | A radio button shown in the Windows Vista widget style. |
![]() | A radio button shown in the Macintosh widget style. |
参见 QPushButton, QToolButton, QCheckBox, GUI Design Handbook: Radio Button, and Group Box Example.
成员函数
QRadioButton::QRadioButton(QWidget *parent = Q_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.
QRadioButton::QRadioButton(const QString &text, QWidget *parent = Q_NULLPTR)
Constructs a radio button with the given parent and text string.
The parent argument is passed on to the QAbstractButton constructor.
QRadioButton::~QRadioButton()
Destructor.
[virtual protected]
bool QRadioButton::event(QEvent *e)
重新实现 QObject::event().
[virtual protected]
bool QRadioButton::hitButton(const QPoint &pos) const
重新实现 QAbstractButton::hitButton().
[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.
参见 QStyleOption::initFrom().
[virtual]
QSize QRadioButton::minimumSizeHint() const
重新实现 QWidget::minimumSizeHint().
[virtual protected]
void QRadioButton::mouseMoveEvent(QMouseEvent *e)
重新实现 QWidget::mouseMoveEvent().
[virtual protected]
void QRadioButton::paintEvent(QPaintEvent *)
重新实现 QWidget::paintEvent().
[virtual]
QSize QRadioButton::sizeHint() const
重新实现 QWidget::sizeHint().