Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Solved How to get GridLayout height

    QML and Qt Quick
    3
    3
    180
    Loading More Posts
    • 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.
    • B
      BikashRDas last edited by

      I have a GridLayout holding some items in 2 columns and rows as per the requirement.

      GridLayout {
            columns: 2
            rowSpacing: 16
            columnSpacing: 16       
            anchors.margins: 16    
            Repeater {
                  model: _myModel
                  Loader {
                          sourceComponent: _type === "tall" ? _tallComponent : _shortComponent
                  }
           }
      }
      Component {
       id: _tallComponent
       Rectangle {
           width: 500
           height: 200
           color: "red"
       }
      }
      
      Component {
       id: _shortComponent
       Rectangle {
           width: 500
           height: 100
           color: "blue"
       }
      }
      

      I want to put the above in a ScrollView for which I need to set the content height. Is there any way to the height of the GridLayout above?

      ODБOï 1 Reply Last reply Reply Quote 0
      • ODБOï
        ODБOï @BikashRDas last edited by

        @BikashRDas
        GridLayout is an Item, it has a "height" property

        1 Reply Last reply Reply Quote 1
        • ODБOï
          ODБOï @BikashRDas last edited by

          @BikashRDas
          GridLayout is an Item, it has a "height" property

          1 Reply Last reply Reply Quote 1
          • S
            shashikumar last edited by

              ScrollView  {
                            id: scrollV
                            clip: true
                            anchors.fill:parent
                            contentHeight: grid.height                
                            contentWidth: grid.width
                          
                            GridLayout {
                                id:grid
                                width: scrollV.width
                                height: children.length*150
                                spacing: 10
                }
            

            Refer this code, I hope it may help you .

            1 Reply Last reply Reply Quote -1
            • First post
              Last post