如果itemSwitch1为“ ON”,我想将itemSwitch2设为不可选。如何取消对itemSwitch2的访问
function setSelectable(item, state)
{
item.editable = state
}
StyledComboBox {
id: itemSwitch1
Layout.row: 0
Layout.column: 1
model: ["ON", "OFF"]
currentIndex: (root.systemInfo.itemEn) ? 0 : 1
onUpDownPressed:
{
currentIndex = !currentIndex;
}
onEditFinished: {
dashboard.setSelectibale(itemSwitch2, false)
optionProvider.upDate(currentIndexItem.text)
itemLabel1.focus = true;
updateTimer.running = true;
}
}
这只是一个示例,但它可以正常工作:
import QtQuick 2.9
import QtQuick.Window 2.2
import QtQuick.Controls 1.4
Window {
visible: true
width: 640
height: 480
Row {
spacing: 2
ComboBox {
id: one
width: 200
model: [ "ON", "OFF" ]
onCurrentIndexChanged: {
if (currentIndex === find("ON")) {
two.enabled = false
} else
{
two.enabled = true
}
}
}
ComboBox {
id: two
width: 200
model: [ "HELLO", "BYE" ]
}
}
}
@ Y.Hacene,不客气!:)编码愉快!:)