如何訪問TableViewColumn
中的當前項目?如何訪問QML TableViewColumn委託中的數據?
TableView {
id: atcTableView
model: myatclist
...
TableViewColumn {
...
}
TableViewColumn {
id: atcTableViewColFreq
role: "frequency"
title: "Frequency"
width: 120
delegate: Component {
Text {
text: "Freq is " + currentItem/model/model.frequency
}
}
}
由於這種類似的問題的 「How do you access the roles of the currentItem from a listview in QML?」 我已經嘗試了所有類型的組合model
,modelData
,currentItem
的,讓人覺得model.role
。
如果我完全刪除代表,頻率顯示正確。型號基於QAbstractListModel
。任何提示?
順便說一句,我可以在QML中看到調試代理中可用的屬性嗎?
- 基於卡卡杜的評論編輯 -
delegate {
Text {
text: "freq is " + frequency
}
}
給我:ReferenceError: frequency is not defined
我還沒有TableView中列,但直覺工作,說,你應該嘗試'frequency'你文本元素。對不起,如果我的猜測不起作用 – Kakadu
上面更新的細節 –