Thank you for your input Chris,
the point about this post, as hinted in the title, is to pass information from the place where the Loader Element is used to instantiate an arbitrary object, to the created object. The information passed, serves no deeper purpose then to be passed.
It seems I’ve chosen a confusing example. Sorry about that.
Maybe this will clarify:
main.qml
import QtQuick 2.0
Rectangle {
width: 360; height: 360
color: "aliceblue"
Rectangle {
anchors.centerIn: parent
width: 300; height: 300
border {color: "black"; width: 1 }
Container {
anchors.margins: 1
aThing: Rectangle {
width: 200; height: 200;
border {color: "black"; width: 1 }
Text {
anchors.fill: parent; anchors.margins: 3;
text: passedInformation
wrapMode: Text.WordWrap
}
}
}
}
}
Container.qml:
import QtQuick 2.0
Rectangle {
id: root
property Component aThing: Item { }
anchors.fill: parent
color: "lightsteelblue"
Loader {
property string passedInformation: "some arbitrary information"
anchors.centerIn: parent
sourceComponent: aThing
}
}
↧