How to use var properties for lists of elements?
-
Can you help me to figure out correct way to use lists in custom QML properties?
Here is example:--- Elem.qml
@import QtQuick 2.0QtObject {
property string name
}@--- Cont.qml
@import QtQuick 2.0QtObject {
property var elements
}
@--- main.qml
@import QtQuick 2.2Rectangle {
Cont {
elements: [
Elem { name: "1" },
Elem { name: "2" }
]
}
}@Running this using qmlscene from Qt-5.2 produces following error:
@Starting /opt/qt-5.2.1/5.2.1/gcc_64/bin/qmlscene...
file:///home/usov/build/qml/main.qml:6 Cannot assign multiple values to a singular property/opt/qt-5.2.1/5.2.1/gcc_64/bin/qmlscene exited with code 255@
As far as I understand, this means that last paragraph of "this QML manual page":http://qt-project.org/doc/qt-5/qml-list.html is wrong.