Is there a way to get the count of a ListModel outside of the delegate? For instance, I have a ListModel below in a qml file, say SampleModel.qml:
ListModel {
id: sampleModel
ListElement {name: "1"}
ListElement {name: "2"}
ListElement {name: "3"}
ListElement {name: "4"}
}
How do I get the count property of the sampleModel from another qml file, main.qml, without using ListView or GridView etc.? I tried the main.qml like this (the SampleModel is in the same directory the main.qml), but it gives the error “ReferenceError: Can’t find variable: sampleModel”.
import QtQuick 1.0
Rectangle {
id: main_window
x: 0; y:0
Text {
text: sampleModel.count
}
}
Thanks.
↧