RadioButton QML Type

可打开或关闭的专用单选按钮。更多

Import Statement: import QtQuick.Controls
Inherits:

AbstractButton

详细说明

RadioButton 显示一个可打开(选中)或关闭(取消选中)的选项按钮。单选按钮通常用于从一组选项中选择一个选项。

RadioButton 从AbstractButton 继承了其 API。例如,您可以使用AbstractButton API 设置text 并对clicks 做出反应。单选按钮的状态可通过checked 属性设置。

单选按钮默认为auto-exclusive 。在属于同一父项的单选按钮中,任何时候都只能选中一个按钮;选中另一个按钮会自动取消选中之前选中的按钮。对于没有共同父项的单选按钮,ButtonGroup 可用于管理排他性。

RadioDelegate 除了通常在视图中使用外,RadioButton 与 RadioButton 相似。

ColumnLayout {
    RadioButton {
        checked: true
        text: qsTr("First")
    }
    RadioButton {
        text: qsTr("Second")
    }
    RadioButton {
        text: qsTr("Third")
    }
}

另请参阅 ButtonGroup自定义 RadioButton按钮控件RadioDelegate

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