List property and dynamic objects
Hi! I've got a question about dynamic object creation. So, my goal is to create some dynamic objects and store them in a property like @property list<Item> items@
but when i try to assign something to it, it has no effect! @items=myComponent.createObject(someObject)@
is there a way do it (to append something to the list)?
Are you using QtQuick 1.x or QtQuick 2.0? With QtQuick 2 you can use a "var" property to store an array of items which can be dynamically added to etc. ListReference properties are generally intended to be lightweight and "static", I believe.
/edit: turns out that you can do:
property list<Item> il
// define array
var someItemArray = ;
// push c1 for (var i = 0; i < il.length; ++i) someItemArray.push(il[i]); someItemArray.push(c1); il = someItemArray; // push c2 for (var i = 0; i < il.length; ++i) someItemArray.push(il[i]); someItemArray.push(c2); il = someItemArray; for (var i = 0; i < il.length; ++i) console.log("il[i] = " + il[i]);
[Edit: Used proper @ code formatting. -mlong]