Unsolved How do I append an item to my ListModel that's been defined not in the main.qml file
-
Let's say I have a ListModel component in A.qml:
ListModel {
id: alphabetModel
}
I have a seperate JS file to append items into my ListModel:alphabetModel.append({"Letter": "A"});
If I run my code, I get a reference error:ReferenceError: alphabetModelis not defined
I know I wouldn't get the ReferenceError if my ListModel was in main.qml and I did import my JS file into my A.qml.Any way of resolving this reference error?
-
Object of A is not created. Unless you create the the object like
A{
id : jim
}Now you can all jim.append{}
-
@jimbolaya
Try passing the object into a js method.function append(lst) { lst.append({"Letter": "A"}) }