Is it possible to pass ListModel to ListView with some missing parameters?
-
wrote on 10 Jul 2011, 11:39 last edited by
Is it possible to pass ListModel to ListView with some missing parameters?
Is there a way to write a delegate that uses only the parameters that the model gave it and use default parameters for those who dont? -
wrote on 11 Jul 2011, 04:36 last edited by
Did you try this out ?? what is the problem you are facing...
-
wrote on 11 Jul 2011, 06:19 last edited by
You should be able to set default parameters in your delegate. So when parameters in your ListModel is not set the delegate shows what you deem to be the default value for them.
-
wrote on 11 Jul 2011, 09:53 last edited by
[quote author="aabc" date="1310297954"]Is it possible to pass ListModel to ListView with some missing parameters?
Is there a way to write a delegate that uses only the parameters that the model gave it and use default parameters for those who dont?[/quote]Yes, you totally can do that. Check the sample below:
@ListModel {
ListElement {
label: QT_TR_NOOP("Item 1")
value: "item1"
}
ListElement {
label: QT_TR_NOOP("Item 2")
value: "item2"
position: "left"
disabled: "true"
}
}@
Then in the delegate:@Item {
state: (typeof model.disabled != "undefined" && model.disabled == "true" ? "disabled" : "")
anchors.centerIn: (typeof model.position == "undefined" || model.position == "left" : leftContainer ? rightContainer);
}@
3/4