How to update size of content in ScrollView ?
Solved
QML and Qt Quick
-
Hello.
I've just faced the trouble: ScrollView doesn't show scroll bars after x:y position of child element was changed (new x:y position greater than original ScrollView's size).
Is there way to update size of ScrollView's content after child elements were changed ?
Thanks.
-
@r3d9u11 so, finally I've replaced ScrollView with Flickable and made function, that is refreshing content size. children elements call it manually:
Flickable { id: fieldMap anchors.fill: parent ScrollBar.horizontal: ScrollBar { active: true; onActiveChanged: { if (!active) active = true; } } ScrollBar.vertical: ScrollBar { active: true; onActiveChanged: { if (!active) active = true; } } function refreshContentSize() { fieldMap.contentWidth = fieldMap.width; fieldMap.contentHeight = fieldMap.height; for (var i = 0; i < fieldMap.contentItem.children.length; ++i) { var item = fieldMap.contentItem.children[i]; var itemX = item.x+item.width; if ( itemX > fieldMap.contentWidth ) fieldMap.contentWidth = itemX; var itemY = item.y+item.height; if ( itemY > fieldMap.contentHeight ) fieldMap.contentHeight = itemY; } } }
Maybe there is better solution