Details
-
Bug
-
Resolution: Done
-
P2: Important
-
6.2.4, 6.3.2, 6.4.0 Beta4
-
None
-
-
4945fd93f1 (qt/qtbase/dev) 4945fd93f1 (qt/tqtc-qtbase/dev)
Description
QTextLayout::maximumWidth() doesn't handle correctly internal text spaces when wrapping is used.
Test case
#include <QGuiApplication> #include <QTextLayout> int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); const QString text("text text"); QTextLayout referenceLayout(text); referenceLayout.beginLayout(); while (referenceLayout.createLine().isValid()) { } referenceLayout.endLayout(); QTextLayout layout(text); layout.beginLayout(); for (auto line = layout.createLine(); line.isValid(); line = layout.createLine()) line.setLineWidth(40); layout.endLayout(); qreal refMaxWidth = referenceLayout.maximumWidth(); qDebug() << "reference maxwidth:" << refMaxWidth; qreal wrappedMaxWidth = layout.maximumWidth(); qDebug() << "wrapped maxwidth:" << wrappedMaxWidth; Q_ASSERT(qFuzzyCompare(refMaxWidth, wrappedMaxWidth)); return 0; }
Output:
reference maxwidth: 144.781
wrapped maxwidth: 79.7813
ASSERT: "qFuzzyCompare(refMaxWidth, wrappedMaxWidth)" in file ..\TextLayout\main.cpp, line 27
Attachments
Issue Links
- 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
-