我的页面中有3个单选按钮(QML桌面应用程序),一旦我选中了一个,我希望所有其他按钮都不被选中.我尝试使用CheckableGroup我在帮助中找到的代码
CheckableGroup { id: group }
Row {
id: row
spacing: platformStyle.paddingMedium
RadioButton {
id: button1
text: "1"
platformExclusiveGroup: group
}
RadioButton {
id: button2
text: "2"
platformExclusiveGroup: group
}
RadioButton {
id: button3
text: "3"
platformExclusiveGroup: group
checked: true
}
}
Run Code Online (Sandbox Code Playgroud)
但我得到一个错误"platformExclusiveGroup不是一个有效的属性名称"我尝试了另一种解决方案
RadioButton{
id:rbtnDecimal1;
width: 130;
onClicked:{
if(checked){
rbtnHexadecimal1.checked=false;
rbtnString1.checked=false;
}
}
text: "Decimal Data";
anchors.left:rbtnHexadecimal1.right
}
Run Code Online (Sandbox Code Playgroud)
当一个按钮被选中时,所有其他按钮都被取消选中,但是其他按钮会被检查,直到我将鼠标移到它们上面 - 它们变为未被检查.
任何想法如何实现它?