Thanks, that won’t also work, because I want that the height is really 0, so that other dependent elements move accordingly. Example where visibility and opacity doesn’t work:
Item {
width: 400
height: 400
Component {
id: dynamicRec
Rectangle {
border.color: "red"
width: parent.width
height: 20
}
}
Column {
id: subOptionList
property bool expanded: false
// opacity: expanded ? 1 : 0
// visible: expanded ? true : false
height: expanded ? childrenRect.height : 0
clip: true
width: parent.width
Component.onCompleted: {
dynamicRec.createObject(subOptionList,{});
dynamicRec.createObject(subOptionList,{});
dynamicRec.createObject(subOptionList,{});
}
}
MouseArea {
anchors.fill: parent
onClicked: {
subOptionList.expanded = !subOptionList.expanded
}
}
Rectangle {
anchors.top: subOptionList.bottom
width: parent.width
height: 40
color: "blue"
}
}
↧