I'm trying to write my QML components in a modular fashion to be able to change the graphics on the fly but I'm struggling to nest them more than on a single level, here is an example:
import QtQuick 2.0
import QtGraphicalEffects 1.0
WindowFrame {
id: this_item
property Component body //this wont load the component
property alias footer: footer_loader.sourceComponent //this gives an error -> Invalid alias reference. Unable to find id "footer_loader"
property int footer_height: 70
body: Item {
id: body_component
Loader {
id: body_loader
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
height: parent.height-this_item.footer_height
sourceComponent: this_item.body
}
Item {
anchors.bottom: parent.bottom
anchors.left: parent.left
anchors.right: parent.right
height: this_item.footer_height
z: 2
Rectangle {
anchors.fill: parent
color: Qt.rgba(0, 0, 0.5, 1)
layer.enabled: true
layer.effect: DropShadow {
transparentBorder: true
horizontalOffset: 0
verticalOffset: -8
radius: 8.0
samples: 17
color: Qt.rgba(0, 0, 0, 0.5)
}
}
Loader {
id: footer_loader
anchors.fill: parent
}
}
}
}
The goal is to build components with pre-defined spaces (like cards for example) and then load other elements inside these and did not found anything else other than using a loader, how sould it be done? is there a better approach to this?