Unable to get height of ColumnLayout
Solved
QML and Qt Quick
-
Hi,
As shown below I try to set the bounds of Flickable depending on ColumnLayout height but unfortunately I always get wrong height every time I resize the window.
How can I get the real height of ColumnLayout to be able to set the right bounds of Flickable?
import QtQuick 2.0 import QtQuick.Controls 2.2 import QtQuick.Layouts 1.3 Item { id: item1 Flickable { id: flickable boundsBehavior: Flickable.StopAtBounds anchors.fill: parent flickableDirection: Flickable.VerticalFlick contentHeight: columnLayout.height ColumnLayout { id: columnLayout x: 10 y: 10 anchors.rightMargin: 10 anchors.leftMargin: 10 anchors.bottomMargin: 10 anchors.topMargin: 10 anchors.fill: parent Button { id: button_size text: qsTr("Get size") Layout.fillWidth: true onClicked: { console.log(columnLayout.height); } } Button { id: button3 text: qsTr("Button") Layout.fillWidth: true } Dial { id: dial Layout.fillWidth: true } Button { id: button6 text: qsTr("Button") Layout.fillWidth: true } Label { id: label text: qsTr("Label") Layout.fillWidth: true } Switch { id: switch1 text: qsTr("Switch") Layout.fillWidth: true } RadioDelegate { id: radioDelegate text: qsTr("Radio Delegate") Layout.fillWidth: true } ComboBox { id: comboBox Layout.fillWidth: true } Rectangle { id: rectangle width: 200 height: 200 color: "#991d1d" Layout.minimumHeight: 190 Layout.fillHeight: true Layout.fillWidth: true } Button { id: button_last text: qsTr("Last") Layout.fillWidth: true } } } }
-
I found the solution in this post:
https://forum.qt.io/post/321757