I've noticed a strange behavior with inheriting Flickable
.
I have two files, Comp.qml
and main.qml
. The idea is that any children of a Comp
object will be children of the Flickable
under Comp
. I've defaulted the contents using
default property alias contents: flickable.children
but the results turn out to be strange.
Comp.qml
Rectangle {
id: comp;
anchors.fill: parent
default property alias contents: flickable.children; // alias a default property
property int contentHeight: comp.height;
Flickable {
id: flickable;
anchors.fill: parent;
contentHeight: comp.contentHeight;
}
}
main.qml
Rectangle {
id: root;
width: 400;
height: 400;
Comp {
contentHeight: 800;
Rectangle { // <-- this rectangle should be a child of Flickable
width: 800;
height: 800;
border.color: "black";
border.width: 5;
Component.onCompleted: console.debug(parent)
}
}
}
The flickable doesn't work.
If I try to put it all in one file, it work as expected :
main.qml
Rectangle {
id: root;
width: 400;
height: 400;
Rectangle {
id: comp;
anchors.fill: parent
Flickable {
id: flickable;
anchors.fill: parent;
contentHeight: 800;
Rectangle { // <-- the child component
width: 800;
height: 800;
border.color: "black";
border.width: 5;
}
}
}
}
Am I missing something? How do I add an external component into a Flickable
?