I have a custom Footer
Component
which I would like to reuse in different place in my QML App:
Rectangle {
color: "gold"
height: 50
anchors {
bottom: parent.bottom
left: parent.left
right: parent.right
}
RowLayout {
anchors.fill: parent
anchors.margins: 10
Button {
text: "quit"
}
}
}
The use of this is easy:
Window {
visible: true
Footer {
}
}
But now I would like to add a "ButtonA" to the RowLayout
of my Footer
in one view and a "ButtonB" in another view.
How can I achieve that?
See this answer.
You have to declare a
default
property inFooter.qml
:This ensures that any items declared as children of
Footer
instances will be added to itsRowLayout
.main.qml
:I used
StackView
as a convenient way of navigating between the views.