I found a much nicer answer to this question, suggested in a presentation of the Qt Developer Days 2011 “Qt Quick Best Practices and Design Patterns”.
They use default property alias ...
to alias the child items to any property of any item. If you don’t want to alias the children but give the alias property a name, just remove default
. (Literal children are per QML definition the value of the default property.)
Item {
id: button
default property alias contents: placeholder.children
anchors.fill: parent
Rectangle {
anchors.fill: parent
radius: 10
color: "gray"
Item {
id: placeholder <-- where the placeholder should be inserted
}
}
}