Is it possible to pass ListModel to ListView with some missing parameters?
-
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? -
Did you try this out ?? what is the problem you are facing...
-
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.
-
[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);
}@