RadioDelegate QML Type
带单选指示器的专属项委托,该指示器可开启或关闭。更多...
| Import Statement: | import QtQuick.Controls |
| Inherits: |
详细说明
RadioDelegate 提供了一个可切换为开启(选中)或关闭(未选中)状态的项目委托。单选按钮委托通常用于从一组选项中选择一个选项。
RadioDelegate 的 API 继承自ItemDelegate ,而该类又继承自AbstractButton 。例如,您可以设置text ,并使用AbstractButton API 响应clicks 事件。单选按钮委托的状态可通过checked 属性进行设置。
单选按钮委托默认采用“auto-exclusive ”模式。在属于同一父项的单选按钮委托中,任何时候只能勾选一个委托;勾选另一个委托会自动取消先前勾选的那个。对于没有共同父项的单选按钮委托,可使用“ButtonGroup ”来管理排他性。
RadioButton 与 RadioDelegate 类似,不同之处在于它通常不在视图中使用,而是在选项较少且通常要求每个按钮都具有唯一标识的情况下使用。
ButtonGroup {
id: buttonGroup
}
ListView {
model: ["Option 1", "Option 2", "Option 3"]
delegate: RadioDelegate {
text: modelData
checked: index == 0
ButtonGroup.group: buttonGroup
}
}另请参阅 《自定义 RadioDelegate》、《委托控件》以及《RadioButton 》。
© 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.