newbee here on QML. I am trying to do something very basic but I can't get it to work properly.
Basically I want to centralize a RowLayout inside a parent rectangle, but the anchors are only working vertically.
What I want is this:
but this is what I am getting:
the code:
Rectangle
{
height: implicitHeight
width: implicitWidth
color : "cornflowerblue"
Text {
text: "C"
font.family: "Helvetica"
font.pointSize: 12
color: "black"
}
RowLayout
{
anchors.fill: parent
Rectangle {
width: 60
height: 100
color: "red"
border.color: "black"
border.width: 5
radius: 10
}
Rectangle {
width: 60
height: 100
color: "red"
border.color: "black"
border.width: 5
radius: 10
}
Rectangle {
width: 60
height: 100
color: "red"
border.color: "black"
border.width: 5
radius: 10
}
Rectangle {
width: 100
height: 100
color: "red"
border.color: "black"
border.width: 5
radius: 10
}
}
}
I looked into this thread and somewhat helped, but I still don't get the proper horizontal alignment.
Following the suggestion of the comments, I used anchors.centerIn: parent
However now the spacing between rectangles was squashed. Is there an easy way to space the rectangles without adding extra items in between them?
How do I center text horizontally and vertically in a TextView?