0
我想知道index
角色屬於誰。 ListModel
,ListView
或其他?如何測試它?Qml委託索引屬於誰?
ListModel{
id:testModel
ListElement{
// ....
}
// ....
}
ListView{
model:testModel
delegate:
Column {
Label{
text:index
}
}
}
爲什麼?你想達到什麼目的? – Mitch
請仔細閱讀[本頁]的「模型」部分(http://doc.qt.io/qt-5/qtquick-modelviewsdata-modelview.html),特別是第一部分。還要注意的是,在ListView的[附加屬性](http://doc.qt.io/qt-5/qml-qtquick-listview.html#properties)中沒有'index'角色。這些基本上是你正在尋找的答案。我第二@Mitch在這個問題上:你到底想做什麼? – BaCaRoZzo
他詢問代理中的'index'屬性,確實暴露了屬性:http://doc.qt.io/qt-5/qml-qtquick-listview.html#delegate-prop – skypjack