-
Bug
-
Resolution: Fixed
-
P2: Important
-
None
-
5.15.2, 6.2.4, 6.3.0
-
None
-
-
013c346a8d (qt/qtbase/dev) 013c346a8d (qt/tqtc-qtbase/dev) 70e33a585c (qt/qtbase/6.4) 70e33a585c (qt/tqtc-qtbase/6.4) 07bde1cadf (qt/tqtc-qtbase/6.2)
QML Text's implicit width is calculated incorrectly when wrapMode other than Text.NoWrap is used.
See attached screenshot and sample code.
This is very bad for scenarios where Text is used in layouts, because layouts use implicitWidth of content.
import QtQuick 2.15
import QtQuick.Layouts 1.15
import QtQuick.Window 2.12
Window {
width: 640
height: 480
visible: true
title: qsTr("Hello World")
Rectangle {
anchors.fill: layout
color: 'transparent'
border.color: '#999999'
border.width: 1
radius: 2
Text {
anchors.bottom: parent.top
anchors.bottomMargin: 5
text: "Here everything is OK. Text's implicit width is correct, layout size is correct"
}
}
ColumnLayout {
id: layout
x: 40
y: 40
spacing: 10
Text {
text: 'Single line text'
Rectangle {
anchors.fill: parent
color: Qt.rgba(0,0,1,0.1)
}
}
Text {
text: 'Another single line text'
Rectangle {
anchors.fill: parent
color: Qt.rgba(0,0,1,0.1)
}
}
Text {
text: 'Multi line\ntext'
Rectangle {
anchors.fill: parent
color: Qt.rgba(0,0,1,0.1)
}
}
}
Rectangle {
anchors.fill: brokenLayout
color: 'transparent'
border.color: '#999999'
border.width: 1
radius: 2
Text {
anchors.bottom: parent.top
anchors.bottomMargin: 5
text: "Now we add wrapMode to Text and implicit width is a sum of all lines widths"
}
}
ColumnLayout {
id: brokenLayout
x: 40
y: 40 + layout.height + 40
spacing: 10
Text {
text: 'Multi line\ntext'
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
Rectangle {
anchors.fill: parent
color: Qt.rgba(1,0,0,0.1)
}
}
Text {
text: 'Another\nmulti\nline\ntext'
wrapMode: Text.WordWrap
Rectangle {
anchors.fill: parent
color: Qt.rgba(1,0,0,0.1)
}
}
}
}
- relates to
-
QTBUG-106909 QML Text's implicit size is not correct for an item with fixed size
-
- Closed
-
-
QTBUG-104986 QTextLayout::maximumWidth() is not correct for multi-line text
-
- Closed
-
-
QTBUG-109411 Quick Text's implicitWidth doesn't respect maximumLineCount
-
- Closed
-
| For Gerrit Dashboard: QTBUG-89557 | ||||||
|---|---|---|---|---|---|---|
| # | Subject | Branch | Project | Status | CR | V |
| 433371,10 | QTextLayout: fix maximumWidth() for a text containing line separator | dev | qt/qtbase | Status: MERGED | +2 | 0 |
| 433832,2 | QTextLayout: fix maximumWidth() for a text containing line separator | 6.4 | qt/qtbase | Status: MERGED | +2 | 0 |
| 433835,2 | QTextLayout: fix maximumWidth() for a text containing line separator | tqtc/lts-6.2 | qt/tqtc-qtbase | Status: MERGED | +2 | 0 |
| 434531,2 | Revert "QTextLayout: fix maximumWidth() for a text containing line separator" | dev | qt/qtbase | Status: MERGED | +2 | 0 |
| 434719,2 | Revert "QTextLayout: fix maximumWidth() for a text containing line separator" | 6.4 | qt/qtbase | Status: MERGED | +2 | 0 |
| 434725,2 | Revert "QTextLayout: fix maximumWidth() for a text containing line separator" | tqtc/lts-6.2 | qt/tqtc-qtbase | Status: MERGED | +2 | 0 |
| 435080,6 | QTextLayout: fix maximumWidth() for a text containing line separator | dev | qt/qtbase | Status: MERGED | +2 | 0 |