-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Ok, answering my own question: the call init() must be in the Component.onCompleted of the ListModel component itself, not in the GridView.
Thansk, Franck Le 28/12/2013 15:03, Franck Routier (perso) a écrit : > Hi, > > I want to dynamically create a ListModel to be used in my page. I > have tried adding a init() method on my ListModel, and to call > init() on Component.onCompleted in my view, but this does not seem > to work... Here are some code snippets: > > CardSetModel.qml: > > import QtQuick 2.0 ListModel { id: cardSetModel > > function init() { var values = ["0","1","2"] for (i=0; i < > values.length; i++) { append({"val":values[i]}) } } } > > And the page where I try to use it: > > import QtQuick 2.0 import Sailfish.Silica 1.0 > > Page { id: page property CardSetModel myModel: CardSetModel{} > > SilicaGridView { id: gridView model: myModel delegate: Rectagle {} > > Component.onCompleted: { model.init() } } } > > But init() is never called... How can I dynamically initialize my > model (possibly with some parameters) and use it in my page ? > > Thanks in advance for your tips, > > Reagrds, Franck _______________________________________________ > SailfishOS.org Devel mailing list > -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.14 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBAgAGBQJSvt0AAAoJEGEvoAir78RoBB4H/2PbFU5pZI4ZHx9zf6GzYp1G Ynmcz4n+uOy/MlkePhyPc3IJuMQ3YivrZkxr1RJuCnSWBlN5g+Ug6FvVBJ9Ew/LP fwgoTqGNgbakMhNv5x/DN4iOG+a2/rCL4rFCuWwVW5dL2QScRIBA7cn36UXwb2WS SCkAbUyVeL1yjGzlJoEodJIiTLgFFsWlNsVEhSGRmf3ss4hKgeiujxFM3vqixQbV Q24kJkKVMsIPOnhnCb79lUaj/eSPDjmesj5hUypMxe4l5eYmAVpckN83Cn+N7lOn FC0PladOr7B+2VlKlwyKzS2YjWazD7Fkc5p2xdGi+dvfHzA1tjv9cK8RjvIY6P8= =UPsn -----END PGP SIGNATURE----- _______________________________________________ SailfishOS.org Devel mailing list