diff options
author | Martin Jones <martin.jones@nokia.com> | 2010-05-11 22:13:41 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2010-05-11 22:13:41 (GMT) |
commit | dae547d26f8c7d4c75b02045e23213c798a2fa3e (patch) | |
tree | ab15b30b3e95fdb846b6d5f9f139b8bf19219e78 | |
parent | cd70183a86f3586eb34c15f11af03746f28f4acc (diff) | |
download | Qt-dae547d26f8c7d4c75b02045e23213c798a2fa3e.zip Qt-dae547d26f8c7d4c75b02045e23213c798a2fa3e.tar.gz Qt-dae547d26f8c7d4c75b02045e23213c798a2fa3e.tar.bz2 |
Clarify ListModel population via JS.
Task-number: QTBUG-10457
-rw-r--r-- | doc/src/declarative/qdeclarativemodels.qdoc | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/doc/src/declarative/qdeclarativemodels.qdoc b/doc/src/declarative/qdeclarativemodels.qdoc index 9b706a1..788d417 100644 --- a/doc/src/declarative/qdeclarativemodels.qdoc +++ b/doc/src/declarative/qdeclarativemodels.qdoc @@ -143,6 +143,28 @@ ListView { } \endcode +It is also possible to manipulate the ListModel directly via JavaScript. +In this case, the first item inserted will determine the roles available +to any views using the model. For example, if an empty ListModel is +created and populated via JavaScript the roles provided by the first +insertion are the only roles that will be shown in the view: + +\code +Item { + ListModel { + id: fruitModel + } + MouseArea { + anchors.fill: parent + onClicked: fruitModel.append({"cost": 5.95, "name":"Pizza"}) + } +} +\endcode + +When the MouseArea is clicked fruitModel will have two roles, "cost" and "name". +Even if subsequent roles are added, only the first two will be handled by views +using the model. + \section2 XmlListModel |