[Solved]How to Create ListModel in runtime
-
To create a model at runtime use a component and instantiate it:
http://doc.qt.nokia.com/4.7-snapshot/qdeclarativedynamicobjects.htmlThis may also work :
http://cdumez.blogspot.com/2010/11/heterogeneous-list-model-in-qml.html
Next,
use model.append() to add dynamic data to your model....you can call this from a javascript function..something like this:
//this is just pseudo code...@
myFunction()
{
var data = ["1","2","3","4","5","6","7","8"];
var i = 0;
for (i=0; i<data.length; i++){
model.append({"digit": data[i]}); //here digit is a role
}
}
@in your delegate, your data can now be accessed through the digit role.
@delegate:
Text {
color: "red"
text: digit + "index=" + " " +index
}@