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?
3 replies
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?
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);
- }
You must log in to post a reply. Not a member yet? Register here!


