Unsolved How to apply the same background to all DelegateChioces in DelegateChooser?
-
Hi I have a
DelegateChooser
for aTableView
with 10-20 differentDelegateChoice
s. How can I apply the same background to all the choices? I want to avoid having to add the same background to all choices as that is a lot of repeater code and a maintenance headache:DelegateChoice: { Item { Rectangle { id: background; anchors.fill: parent; color: "blue" } Choice1 {} } ... Item { Rectangle { id: background; anchors.fill: parent; color: "blue" } Choice20 {} } }
-
@Puya said in How to apply the same background to all DelegateChioces in DelegateChooser?:
Item {
Rectangle { id: background; anchors.fill: parent; color: "blue" }
Choice20 {}
}DefaultChoiceItem.qml:
Item { Rectangle { id: background; anchors.fill: parent; color: "blue" } }
-
@fcarney Is there no way to avoid having to wrap every choice individually?
-
property var choices: ({ {role:"info", delegate:ItemDelegate}, {role:"switch", delegate:SwitchDelegate}, {role:"swipe", delegate:SwipeDelegate} }) ... DelegateChooser { id: chooser role: "type" Repeater { model: choices DelegateChoice { roleValue: modelData.role; delegate: modelData.delegate } } }
I don't know if this will work. But it might. Still requires to make a ton of choices as Components or QML files.
This is a modification of the example here.
-
@fcarney How would that work with the
delegate
(a QML component) coming from the model (C++ object)? -
@Puya said in How to apply the same background to all DelegateChioces in DelegateChooser?:
How would that work with the delegate (a QML component) coming from the model (C++ object)?
No idea. I don't know what that means.