Got problem with ListView using ListModel. Code seems to be straightforward and quite simple, but I missed something and cannot figure it out:
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
Page {
ListModel {
id: listModelA
ListElement { text2: "aaa" }
ListElement { text2: "bbb" }
ListElement { text2: "ccc" }
ListElement { text2: "ddd" }
}
...
Component {
id: comp2
Column {
ListView {
id: listA
width: parent.width
height: 100
model: listModelA
delegate:
Item {
id: aaa
Text {
width: 100
height: 20
text: text2 // problematic line
}
}
}
}
}
}
Seems that "text2" field from model data cannot be resolved. QtCreator gives me warning Unqalified access: Did you mean "text"? After running application, got runtime error in console: ReferenceError: text2 is not defined. Tried different solution, e.g, but nothing works:
// text: listA.model.text2
// text: listModelA.text2
// text: model.text2
text: text2
Can anyone see obvious problem with this?
required property string text2toItem, and usetext: parent.text2.