[SailfishDevel] Dynamically initialisation of a ListModel
Franck Routier (perso)
alci at mecadu.org
Sat Dec 28 14:03:04 UTC 2013
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
More information about the Devel
mailing list