1
我知道如何綁定到根表TableView信號,如onClicked
,但由於onSelectionChanged
是它的selection
屬性的信號,我不知道如何綁定到它。QML TableView:如何綁定到selection.onSelectionChanged()
我想我肯定可以使用Connections
綁定到它,但下面的代碼沒有工作:
編輯:Connections
實際上不工作,問題是無關的錯誤(見我自己的答案)
TextArea {
id: messageDetailTextArea
readOnly: true
font: messageListDialog.font
function update() {
var selectionText = ''
messagesTable.selection.forEach(function(rowIndex) {
var row = model.get(rowIndex)
if (row && row.message) selectionText += row.message
})
text = selectionText
}
Connections {
target: messagesTable.selection
onSelectionChanged: update()
}
}
但不幸的是,當我點擊表格中的一排TextArea
不更新。我如何迴應選擇更改?