RadioDelegate QML Type

带有可切换开关的无线电指示器的专属项目委托。更多

Import Statement: import QtQuick.Controls
Inherits:

ItemDelegate

详细说明

RadioDelegate 显示一个可打开(选中)或关闭(不选中)的项目委托。单选委托通常用于从一组选项中选择一个选项。

RadioDelegate 的 API 继承自ItemDelegate ,而 又继承自AbstractButton 。例如,您可以设置text ,并使用AbstractButton API 对clicks 做出反应。无线电委托的状态可通过checked 属性设置。

无线电委托默认为auto-exclusive 。在属于同一父项的无线电委托中,任何时候都只能选中一个委托;选中另一个委托会自动取消选中之前选中的委托。对于不共享共同父项的无线电代表,ButtonGroup 可用于管理排他性。

RadioButton RadioDelegate 类似于 RadioDelegate,但它通常不用于视图,而是用于只有几个选项的情况,而且通常要求每个按钮都是唯一可识别的。

ButtonGroup {
    id: buttonGroup
}

ListView {
    model: ["Option 1", "Option 2", "Option 3"]
    delegate: RadioDelegate {
        text: modelData
        checked: index == 0
        ButtonGroup.group: buttonGroup
    }
}

另请参阅 定制 RadioDelegate委托控件RadioButton

© 2025 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.