How to get GridLayout height
Solved
QML and Qt Quick
-
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?
-
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?
@BikashRDas
GridLayout is an Item, it has a "height" property -
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 .