如何使组合框项在 qml 中不可选择?



如果 itemSwitch1 为 "ON",我想把 itemSwitch2 设置为不可选择 我怎样才能访问项目开关2

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" ]
}
}
}

最新更新