Details
-
Bug
-
Resolution: Done
-
P2: Important
-
4.7.3
-
None
-
6e5a642c9484536fc173714f560f739944368cf5
Description
A Text element's implicitWidth should be the width that allow all of its text to be shown. Thus setting an explicit width that results in the text being truncated should have no effect on the implicitWidth, even if "elide" is enabled.
Run the code below. Note that the console printout is
67 63 0
while the expected result is 67 in each case, as is the case if the "elide: Text.ElideRight" line is commented out.
CheckBox.qml
import QtQuick 1.1 Item { id: checkbox implicitHeight: 30 implicitWidth: button.implicitWidth + label.implicitWidth + spacing*3 property alias theLabel: label.text property real margin: 5 property real spacing: label.text.length > 0 ? 5 : 0 Rectangle { id: button anchors.left: parent.left anchors.top: parent.top anchors.bottom: parent.bottom implicitWidth: height color: "green" } Text { id: label anchors.left: button.right anchors.leftMargin: spacing anchors.right: parent.right anchors.verticalCenter: button.verticalCenter elide: Text.ElideRight Rectangle { color: "red"; opacity: 0.2; anchors.fill: parent } Component.onCompleted: print(implicitWidth) } Rectangle { color: "yellow"; opacity: 0.2; anchors.fill: parent } }
main.qml
import QtQuick 1.1 Rectangle { width: 400 height: 400 Column { spacing: 5 CheckBox { theLabel: "Hello World" } CheckBox { theLabel: "Hello World" width: 100 } CheckBox { theLabel: "Hello World" width: 200 } Rectangle { color: "red" width: 100 height: 10 } } }