I'm using a RowLayout
with 2 children in it. If I hide one of them, I want the other child to fill up the complete area. And when unhide it, the area should be evenly divided.
Problem I'm having is when 1 child is hidden at startup, and visibility changes at runtime. The area stays filled with only 1 child (and small bar is shown for spacing). While I expected that both childs would be visible.
Example:
RowLayout {
anchors.fill: parent
Rectangle {
id: rect1
Layout.fillWidth: true
Layout.fillHeight: true
color: "red"
MouseArea
{
anchors.fill: parent
onClicked:
{
rect2.visible = !rect2.visible
}
}
}
Rectangle {
id: rect2
Layout.fillWidth: true
Layout.fillHeight: true
color: "blue"
visible: false
}
}
If I remove the visible: false
from rect2
, it works expected. Only I want rect2 to be hidden at startup.
Putting rect2.visible = false
in Component.onCompleted
only adds extra code which imho should not be needed.
Any solution for this issue?