Details
-
Bug
-
Resolution: Done
-
P5: Not important
-
5.6.0
-
None
-
aa570a7720dc508f83c32aee81ac1d6ea21d6757
Description
The following code use anchoring to parent:
import QtQuick 2.6 import QtQuick.Layouts 1.3 import QtQuick.Window 2.2 Window { visible: true width: 1000 height: 400 Flickable { id: flickable height: parent.height width: height contentHeight: contentRect.implicitHeight contentWidth: contentRect.implicitWidth Rectangle { id: contentRect anchors.right: parent.right anchors.left: parent.left // width: flickable.width implicitWidth: 800 implicitHeight: 800 color: "red" } } }
Result in the attachment: instead of width limit, rectangle has wrong width.
Seems, content item resized to contentWidth, contentHeight and anchoring to it doesn't work properly.
Another example:
Flickable { id: flickable width: 320 height: 240 contentWidth: column.implicitWidth contentHeight: column.implicitHeight Column { id: column // width: flickable.width // width: parent.width anchors.left: parent.left anchors.right: parent.right spacing: 8 Text { text: parent.width + " x " + parent.height width: parent.width Component.onCompleted: console.log(parent.width, parent.parent.width, parent.parent.parent.width) } Text { text: "this should be wrapped because it's a bit too much text to fit in its parent Column" wrapMode: Text.WordWrap width: parent.width } Text { text: "this should be wrapped too, because it's also a bit too much text to fit in its parent Column" wrapMode: Text.WordWrap width: parent.width } } }
The only working case, is to bind width to the Flickable by id.
https://codereview.qt-project.org/#/c/162177/ is an attempt to fix docs, until this bug would be fixed.