1
請考慮以下示例。將焦點強制爲ListView中的文本編輯
Rectangle {
height: 200
width: 200
ListView {
id: lv
anchors.fill: parent
model: ListModel {
ListElement {
name: "aaa"
}
ListElement {
name: "bbb"
}
ListElement {
name: "ccc"
}
}
delegate: TextEdit {
id: delegate
text: name
width: 200
height: 100
activeFocusOnPress: false
onActiveFocusChanged: {
if(activeFocus) {
font.italic = true;
} else {
font.italic = false;
}
}
MouseArea {
anchors.fill: parent
onDoubleClicked : {
delegate.focus = true;
lv.currentIndex = index;
}
}
}
}
}
我希望能夠通過雙擊激活TextEdit。如果它在列表視圖之外,它按預期工作,但在列表視圖中它不起作用。 我想問題是列表視圖是焦點範圍,但我不知道如何解決它。
在此先感謝。
謝謝,它的工作 – 2015-04-01 15:28:20