Details
-
Bug
-
Resolution: Done
-
P3: Somewhat important
-
5.11.0
-
None
-
f5f36b0db64e77822ef3053245c993ed14949192 (qt/qtquickcontrols2/5.12)
Description
https://doc.qt.io/qt-5/qml-qtquick-controls2-pane.html#content-sizing says:
If only a single item is used within a Pane, it will resize to fit the implicit size of its contained item. This makes it particularly suitable for use together with layouts.
It then shows an example of this:
Pane { ColumnLayout { anchors.fill: parent CheckBox { text: qsTr("E-mail") } CheckBox { text: qsTr("Calendar") } CheckBox { text: qsTr("Contacts") } } }
What it doesn't mention is that if the contentItem has no implicitWidth/Height, it will use the implicitWidth/Height of the first child item of contentItem. This previously happened here in QML, and happens here in C++ in 5.12.
This surprised me, as I understand that the following code would result in the contentWidth being equal to the implicitWidth of the text:
import QtQuick 2.10 import QtQuick.Window 2.10 import QtQuick.Controls 2.3 Window { id: root width: 400 height: 440 visible: true title: pane.contentWidth Pane { id: pane contentItem: Label { text: "Info!" anchors.centerIn: parent } } }
But I wouldn't expect it to use the Label's implicitWidth here:
import QtQuick 2.10 import QtQuick.Window 2.10 import QtQuick.Controls 2.3 Window { id: root width: 400 height: 440 visible: true title: pane.contentWidth Pane { id: pane contentItem: Item { Label { text: "Info!" anchors.centerIn: parent } } } }
Attachments
Issue Links
- relates to
-
QTBUG-74902 StackView doesn't fit its content
- Closed