is there any why to add item to QDeclarativeListProperty from qml file at run time? in a loop, for example:
var i;
for(i = 0 ; i < 100 ; ++i)
{
listOfItems.append(MyItem {text:"list"+i})
}
and listOfItems is the QDeclarativeListProperty list... i don't want to do that:
listOfItems:
[
MyItem{text:"list val1"},
MyItem{text:"list val2"},
......
]
i display this list in qml and the data for the list comes from qt object....
You can't, QDeclarativeListProperty
(or QQmlListProperty
in Qt5) is affected only once, at instanciation time, you can't append/remove any element in it after that.
More, in JavaScript code, you can't use the Class { }
syntax form, it's QML specific.
If I get your problem right you are looking for the Component.onCompleted signal
http://doc.qt.nokia.com/main-snapshot/qml-component.html#onCompleted-signal
精彩评论