文章介绍
demo.qml
效果
代码
import QtQuick 2.15
import QtQuick.Controls 2.15
ApplicationWindow {
visible: true
width: 300
height: 200
title: "切换开关控制示例"
Switch {
id: mainSwitch
text: "启用/禁用其他开关"
anchors.top: parent.top
anchors.horizontalCenter: parent.horizontalCenter
checked: true
}
Switch {
id: switch1
text: "开关 1"
anchors.top: mainSwitch.bottom
anchors.topMargin: 20
anchors.horizontalCenter: parent.horizontalCenter
enabled: mainSwitch.checked
}
Switch {
id: switch2
text: "开关 2"
anchors.top: switch1.bottom
anchors.topMargin: 20
anchors.horizontalCenter: parent.horizontalCenter
enabled: mainSwitch.checked
}
}
实际项目需求
面临问题
解决办法