ListView Delegate loaded with Loader does not have modelData, index and ListView attached properties
-
Hi,
I'm trying to load a delegate in a Loader based on the type of its model:@import QtQuick 2.0
ListView {
model: [
{"type":"header", "title":"Header 1"},
{"type":"content", "itemContent":"List Item 1"}
]
delegate: Loader {
sourceComponent: modelData.type === "header" ? headerComponent : itemComponent
}Component {
id: headerComponent
Text {
// NOTE: modelData is undefined here!
text: modelData.title
}
}Component {
id: itemComponent
Text {
// NOTE: modelData is undefined here!
text: modelData.itemContent
// this also does not work
font.bold: ListView.isCurrentItem
// index is also not known...
}
}}
@
Any hints how to select a delegate based on the modelData content?
Cheers,
Chris