I want to have a dynamically resizable window with the layout of the columns so that any remaining space is filled with the last element in the column. I could do this by dynamically calculating the height of the last element in javascript. I could also move the last element from the column and snap the top to the bottom of the column and the bottom of the container, however I would also need to calculate the new size of the column from its contents.
import QtQuick 2.0 import QtQuick.Controls 1.1 Rectangle { id: rect anchors.fill: parent Column { id: myColumn anchors.fill: parent Rectangle { id: container signal clicked width: label.width + 20; height: label.height + 6 anchors { right: parent.right } border.width: 1 MouseArea { id: mouseArea anchors.fill: parent onClicked: { if (myColumn.state == 'hidden') { myColumn.state = '' } else { myColumn.state = 'hidden'; } } } Text { id: label text: { if (myColumn.state == '') {"Hide"} else {"Show"} } anchors.centerIn: parent } } Text { id: textualBox text: "A Big Box" verticalAlignment: Text.AlignVCenter horizontalAlignment: Text.AlignHCenter anchors { left: parent.left; right: parent.right } height: 200 } TableView { id: table width: parent.width height: { myColumn.height - container.height - textualBox.height } model: myData TableViewColumn { role: "name"; title: "name"; width: 60 } TableViewColumn { role: "stuff"; title: "stuff"; width: 60 } } states: State { name: 'hidden' PropertyChanges { target: textualBox height: 20 text: "a little box" } } } ListModel { id: myData ListElement{ name: "content" ; stuff: "4.5" } ListElement{ name: "content" ; stuff: "4.5" } ListElement{ name: "content" ; stuff: "4.5" } } }
Is there a more elegant way to do this?
source share