RadioButton QML Type
可切换开启或关闭的单选按钮。更多...
| Import Statement: | import QtQuick.Controls |
| Inherits: |
详细说明
RadioButton 提供了一个单选按钮,可切换为开启(选中)或关闭(未选中)状态。单选按钮通常用于从一组选项中选择一个选项。
RadioButton 继承自AbstractButton 的 API。例如,您可以设置text ,并使用AbstractButton API 响应clicks 事件。可通过checked 属性设置单选按钮的状态。
单选按钮默认auto-exclusive 。在属于同一父项的单选按钮中,任何时候只能选中一个按钮;选中另一个按钮会自动取消先前选中的按钮。对于没有共同父项的单选按钮,可以使用ButtonGroup 来管理互斥性。
RadioDelegate 与 RadioButton 类似,区别在于它通常用于视图中。
ColumnLayout {
RadioButton {
checked: true
text: qsTr("First")
}
RadioButton {
text: qsTr("Second")
}
RadioButton {
text: qsTr("Third")
}
}另请参阅《 ButtonGroup》 、《自定义 RadioButton》、《Button 控件》以及《RadioDelegate 》。
© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.