[solved]Unable to assign fix height to TextArea in ColumnLayout
-
Unfortunately, I am not able to set the height of a TextArea in a ColumnLayout. The property height doesn't seem to have any influence on the displayed height of the TextArea. Code snipped:
@
import QtQuick 2.2
import QtQuick.Controls 1.1
import QtQuick.Layouts 1.1Rectangle {
id: mainRect
width: 200
height: 200ColumnLayout { id: colLayout anchors.fill: parent Label { text: qsTr("Label") } TextArea { text: "This wants to grow horizontally and should have a fixed height" Layout.fillWidth: true //Layout.fillHeight: false height: 30 //Layout.height: 40 // => non-existent property "height" } Button { text: "Button" } }
}
@How can I fix this? Do I have to use another property?
Thank you for any help!PS: If I use Column, the height of the TextArea behaves correctly. (But then there is an issue with the width, which is why I would prefer to use ColumnLayout...)
-
The height property is ignored because the layout will anyway set this for you. (i.e hardcoding the height is not very meaningful in a stretchable layout, since the layout itself will set the height property for you) What you want is to set either the items implicitHeight or more specifically Layout.preferredHeight instead.
-
Very nice... Layout.preferredHeight is exactly what I was looking for! Thank you very much!