Ok, so I am going to ask the question in a different way in a bit, but first I would like to point out why I think there is a model.children node. Using a prototype dumper found here http://refactormycode.com/codes/226-...dump-an-object, and using the following code:
port QtQuick 1.0
Rectangle {
width: 100
height: 100
VisualItemModel {
id: itemModel
Rectangle { height: 30; width: 80; color: "red" }
Rectangle { height: 30; width: 80; color: "green" }
Rectangle { height: 30; width: 80; color: "blue" }
}
ListView {
id: view
anchors.fill: parent
model: itemModel
focus: true
Keys.onPressed: {
console.log(odump(view.model));
}
}
}
port QtQuick 1.0
Rectangle {
width: 100
height: 100
VisualItemModel {
id: itemModel
Rectangle { height: 30; width: 80; color: "red" }
Rectangle { height: 30; width: 80; color: "green" }
Rectangle { height: 30; width: 80; color: "blue" }
}
ListView {
id: view
anchors.fill: parent
model: itemModel
focus: true
Keys.onPressed: {
console.log(odump(view.model));
}
}
}
To copy to clipboard, switch view to plain text mode
I get the following output:
objectName:
itemsRemoved: function
itemsInserted: function
count: 3
modelReset: function
countChanged: function
childrenChanged: function
createdItem: function
itemsMoved: function
destroyingItem: function
children:
objectName:
itemsRemoved: function
itemsInserted: function
count: 3
modelReset: function
countChanged: function
childrenChanged: function
createdItem: function
itemsMoved: function
destroyingItem: function
children:
To copy to clipboard, switch view to plain text mode
So as you can see, there clearly is a node called children in the prototype of model. Tracking through the source code for the declarative module as I have outlined above I can see where this node is created and what its prototype should be, however I am confused that when I try and access any member of children, its returned value is null.
So, to the reworded question. How do I alter the contents of a VisualItemModel after it has been created. My initial thought was that it should be through the children.append(item) function, but I cannot seem to get this to work.
Regards
Matt
Bookmarks