passing properties into Components
-
Hi all -
I'm trying to pass information into a component:
import QtQuick import QtQuick.Controls import QtQuick.Layouts Window { width: 640 height: 480 visible: true title: qsTr("Hello World") RowLayout { id: rowLayout anchors.fill: parent Loader { sourceComponent: component property string order: "first" } Loader { sourceComponent: component property string order: "second" } } Component { id: component Pane { id: innerPane height: 100; width: 100 property string order Label { text: innerPane.order } } } }
It builds and runs without error, but no text displays.
Is there a way to do this?Thanks...
-
I think the issue is that you expect to be using the
order
property you have defined in yourLoader
but you have also declared an uninitialisedorder
property in yourComponent
which will hide theorder
defined in theLoader
. If you didn't have theorder
property in yourComponent
, you would simply be able to refer toorder
(notinnerPane.order
) as it would be inherited from the context provided byLoader
. -
M mzimmers has marked this topic as solved on