I think I came up with something that seems to work but not sure if this is a good way to do this (I also changed from ScrollView to Flickable because I saw online that it is better suited for touch devices.)
Flickable {
id: scroller
anchors.fill: parent
contentHeight: main.height
contentWidth: main.width
GridLayout {
id: main
height: scroller.width > 600 ? scroller.height : children.length * 800
width: scroller.width
columns: 2
states: [
State {
when: root.width <= 600
PropertyChanges {target: left; Layout.row: 1}
PropertyChanges {target: right; Layout.row: 0}
},
State {
when: root.width > 600
PropertyChanges {target: left; Layout.column: 0}
PropertyChanges {target: right; Layout.column: 1}
}
]
Flickable {
id: scroller
anchors.fill: parent
contentHeight: main.height
contentWidth: main.width
GridLayout {
id: main
height: scroller.width > 600 ? scroller.height : children.length * 800
width: scroller.width
columns: 2
states: [
State {
when: root.width <= 600
PropertyChanges {target: left; Layout.row: 1}
PropertyChanges {target: right; Layout.row: 0}
},
State {
when: root.width > 600
PropertyChanges {target: left; Layout.column: 0}
PropertyChanges {target: right; Layout.column: 1}
}
]
To copy to clipboard, switch view to plain text mode
Basically I set the GridLayout's height to the height of the scroller or to a very high height (800 * children.length) if the width gets narrower (<= 600 in this case).
Is there a better way to do it or is it "good enough"?
Bookmarks