Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. [solved]Unable to assign fix height to TextArea in ColumnLayout
Forum Update on Monday, May 27th 2025

[solved]Unable to assign fix height to TextArea in ColumnLayout

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 2 Posters 1.6k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Q Offline
    Q Offline
    qmlLearner
    wrote on 13 Jan 2014, 17:10 last edited by
    #1

    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.1

    Rectangle {
    id: mainRect
    width: 200
    height: 200

    ColumnLayout {
        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...)

    1 Reply Last reply
    0
    • J Offline
      J Offline
      Jens
      wrote on 13 Jan 2014, 20:39 last edited by
      #2

      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.

      1 Reply Last reply
      0
      • Q Offline
        Q Offline
        qmlLearner
        wrote on 13 Jan 2014, 21:42 last edited by
        #3

        Very nice... Layout.preferredHeight is exactly what I was looking for! Thank you very much!

        1 Reply Last reply
        0

        1/3

        13 Jan 2014, 17:10

        • Login

        • Login or register to search.
        1 out of 3
        • First post
          1/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved