Let's say I have a TestComponent.qml that uses alias for child items. The component file looks like this:
TestComponent.qml
import QtQuick 2.5
Column {
default property alias children: cont.children;
Text {
text: "header"
}
Column {
id: cont
}
Text {
text: "footer"
}
}
Then I have a main file, where I instantiate the component. If add a child component Text via static component instantiation, it appears between header and footer as expected. However, if I add a child component dynamically, it ignores the children alias and adds the child after the footer. The file looks like this:
main.qml
import QtQuick 2.5
import QtQuick.Controls 1.4
ApplicationWindow {
visible: true
width: 200
height: 200
TestComponent {
id: t1
Text {
text: "body"
}
}
Component {
id: txt
Text {
text: "body1"
}
}
Component.onCompleted: {
txt.createObject(t1)
}
}
The output is:
header
body
footer
body1
Is there any way of doing it in such a way that the alias is also transparent for the dynamic component creation? Ideally without using C++.