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. How to get GridLayout height

How to get GridLayout height

Scheduled Pinned Locked Moved Solved QML and Qt Quick
3 Posts 3 Posters 758 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.
  • B Offline
    B Offline
    BikashRDas
    wrote on last edited by
    #1

    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ïO 1 Reply Last reply
    0
    • B BikashRDas

      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ïO Offline
      ODБOïO Offline
      ODБOï
      wrote on last edited by
      #2

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

      1 Reply Last reply
      1
      • S Offline
        S Offline
        shashikumar
        wrote on last edited by
        #3
          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
        -1

        • Login

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