Unsolved How to set Flickable.contentHeight with dynamic height of Column?
-
how can i reduce my scroll-area to the size of the Column
in my real example the 3 rectangles are a model and Loaders with items of different height, that sometimes change based on the modelbut i can't even get it work in this simple example
and ideas?
import QtQuick 2.5 Item { width: 500 height: 500 Flickable { id: myList width: 200 height: 100 contentWidth: width // how to set this property based on Column.height contentHeight: 50+2+70+2+20+2 // list.height is NaN clip: true Column { id: list spacing: 2 Rectangle { color: "red"; width: 50; height: 50 } Rectangle { color: "green"; width: 20; height: 70 } Rectangle { color: "blue"; width: 50; height: 20 } } } Rectangle { anchors.fill: myList color: "transparent" border { width: 2; color: "green" } } }
Screenshot:
-
this should work:
Flickable { id: myList anchors.fill:parent contentWidth: width contentHeight: lastItem.y + lastItem.height clip: true Column { id: list spacing: 2 Rectangle { color: "red"; width: 50; height: 50 } Rectangle { color: "green"; width: 20; height: 70 } Rectangle { id:lastItem; color: "blue"; width: 50; height: 20 } } }
-
The real height for such items as Column is stored at
implicitHeight
property. Just setcontentHeight: list.implicitHeight
for your flickable.