I stumbled across this way of doing things at the completion of construction of components – for example doing stuff programmatically at the completion of constructing a level:
LevelBase {
levelName: "Level1"
function addPlatform() {
// ...
}
// background
Image {
anchors.fill: parent
source: "../../assets/img/bamboo.png";
}
Component.onCompleted: {
addPlatform('startPlatform')
}
}
Could someone explain what this “means”. I know what it _does_, I just don’t know how it does it. Is it saying “My LevelBase object has Component in its hierarchy, and Component has onCompleted, so I am setting my inherited onCompleted method to be this function”?
Why is it necessary to specify the “path” to “onCompleted”? If I am inheriting from Component, then why can’t I just refer to my inherited method?
And if I’m not inheriting from Component, then … what is the meaning of this declaration?