Reputation: 10996
I have a QML object defined as follows:
Item {
property alias source: a.internalImage.source
property alias text: a.internalText.text
Column {
id: a
Image {
id: internalImage
}
Text {
id: internalText
width: internalImage.width
}
}
}
This fails with: Invalid alias target location: internalImage
.
However, if I do:
Column {
property alias source: internalImage.source
property alias text: internalText.text
Image {
id: internalImage
}
Text {
id: internalText
width: internalImage.width
}
}
Why is that?
Upvotes: 5
Views: 2579
Reputation: 199
I did solve this issue by creating a simple property and a changeListener
Item {
property string source: a.internalImage.source
property string text: a.internalText.text
onSourceChanged: a.internalImage.source = source
onTextChanged: a.internalText.text
}
I hope this helps
Upvotes: 0
Reputation: 50540
As from the documentation, the scope of a Component
is:
the union of the object ids within the component and the component's root element's properties
So, the outer element is not allowed to access to the id
s contained in the inner element by means of a chain of id
s.
On the other side, if you explicitly export a bunch of parameters by means of a set of variables, those values/references are freely available to the outer component.
Upvotes: 4