Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
5.10, 5.13.2
Description
Run the following code. The text won't show up until it's resized with the sliders.
import QtQuick 2.7 import QtQuick.Layouts 1.3 import QtQuick.Controls 2.3 ApplicationWindow { id: window visible: true width: 400 height: 680 ColumnLayout { anchors.fill: parent anchors.margins: 8 spacing: 20 Slider { id: controlWidthSlider from: 1 // Setting value with a binding works // value: button.implicitWidth to: 200 } Slider { id: controlHeightSlider from: 1 // value: button.implicitHeight to: 100 } // Using a plain item works // Item { // id: controlWidthSlider // property real value // } // Item { // id: controlHeightSlider // property real value // } Component.onCompleted: updateValues() function updateValues() { controlWidthSlider.value = button.implicitWidth; controlHeightSlider.value = button.implicitHeight; } Rectangle { id: button implicitWidth: Math.max(100, textItem.implicitWidth) implicitHeight: Math.max(40, textItem.implicitHeight) color: "grey" property real leftPadding: 10 property real topPadding: 10 property alias text: textItem.text Layout.preferredWidth: { controlWidthSlider.value } Layout.preferredHeight: { controlHeightSlider.value } Connections { target: textItem onWidthChanged: print(textItem.width) } Text { id: textItem text: "Button" x: button.leftPadding y: button.topPadding width: button.width - button.leftPadding * 2 height: button.height - button.topPadding * 2 elide: Text.ElideRight Rectangle { anchors.fill: parent color: "transparent" border.color: "darkorange" } } } } }
The issue was found here: https://codereview.qt-project.org/#/c/188942