diff options
author | mae <qt-info@nokia.com> | 2009-04-09 10:20:35 (GMT) |
---|---|---|
committer | mae <qt-info@nokia.com> | 2009-04-09 10:20:35 (GMT) |
commit | f3ee66750d279fb3d44cd13307312b703c77172f (patch) | |
tree | e0ad2350dff9a2df89153289638a9b96525f9708 | |
parent | 37c72476fc444d3089075473cb4e9aa42ed64694 (diff) | |
download | Qt-f3ee66750d279fb3d44cd13307312b703c77172f.zip Qt-f3ee66750d279fb3d44cd13307312b703c77172f.tar.gz Qt-f3ee66750d279fb3d44cd13307312b703c77172f.tar.bz2 |
Default text width before QPlainTextEdit was shown for the first time
QTextEdit fakes an infinite width, while QPlainTextEdit defaulted to 0.
This was discovered in creator's auto tests.
-rw-r--r-- | src/gui/widgets/qplaintextedit.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/gui/widgets/qplaintextedit.cpp b/src/gui/widgets/qplaintextedit.cpp index 2e9201d..a51ed2d 100644 --- a/src/gui/widgets/qplaintextedit.cpp +++ b/src/gui/widgets/qplaintextedit.cpp @@ -370,11 +370,16 @@ void QPlainTextDocumentLayout::layoutBlock(const QTextBlock &block) extraMargin += fm.width(QChar(0x21B5)); } tl->beginLayout(); + qreal availableWidth = d->width; + if (availableWidth <= 0) { + availableWidth = INT_MAX; // similar to text edit with pageSize.width == 0 + } + availableWidth -= 2*margin + extraMargin; while (1) { QTextLine line = tl->createLine(); if (!line.isValid()) break; - line.setLineWidth(d->width - 2*margin - extraMargin); + line.setLineWidth(availableWidth); height += leading; line.setPosition(QPointF(margin, height)); |