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. Unable to get height of ColumnLayout
Forum Updated to NodeBB v4.3 + New Features

Unable to get height of ColumnLayout

Scheduled Pinned Locked Moved Solved QML and Qt Quick
flickablecolumnlayout
2 Posts 1 Posters 3.0k Views 1 Watching
  • 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.
  • M Offline
    M Offline
    mbnoimi
    wrote on last edited by
    #1

    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
                }
    
    
            }
        }
    }
    
    1 Reply Last reply
    0
    • M Offline
      M Offline
      mbnoimi
      wrote on last edited by
      #2

      I found the solution in this post:
      https://forum.qt.io/post/321757

      1 Reply Last reply
      0

      • Login

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