diff options
author | Yann Bodson <yann.bodson@nokia.com> | 2010-11-02 06:41:01 (GMT) |
---|---|---|
committer | Yann Bodson <yann.bodson@nokia.com> | 2010-11-02 06:43:34 (GMT) |
commit | 11bb4f85ef38270758ec0930709c23c7fcb5840c (patch) | |
tree | 5cbefe18875c73f2a7441de0ef51894fea38be34 /src/declarative | |
parent | 13eebf835df3d8fec88a68b571d33e73da929413 (diff) | |
download | Qt-11bb4f85ef38270758ec0930709c23c7fcb5840c.zip Qt-11bb4f85ef38270758ec0930709c23c7fcb5840c.tar.gz Qt-11bb4f85ef38270758ec0930709c23c7fcb5840c.tar.bz2 |
Regression: Text element breaks when using \n for separating lines
Task-number: QTBUG-14915
Reviewed-by: Michael Brasser
Diffstat (limited to 'src/declarative')
-rw-r--r-- | src/declarative/graphicsitems/qdeclarativetext.cpp | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativetext.cpp b/src/declarative/graphicsitems/qdeclarativetext.cpp index 03c9765..8cb47aa 100644 --- a/src/declarative/graphicsitems/qdeclarativetext.cpp +++ b/src/declarative/graphicsitems/qdeclarativetext.cpp @@ -291,30 +291,30 @@ QSize QDeclarativeTextPrivate::setupTextLayout() qreal height = 0; qreal lineWidth = 0; - //set manual width - if (q->widthValid()) - lineWidth = q->width(); - QTextOption textOption = layout.textOption(); - textOption.setWrapMode(QTextOption::WrapMode(wrapMode)); + textOption.setWrapMode(QTextOption::NoWrap); textOption.setAlignment(Qt::Alignment(hAlign)); - layout.setTextOption(textOption); + // if the item has an explicit width, we set the line width and enable wrapping + if (q->widthValid()) { + lineWidth = q->width(); + textOption.setWrapMode(QTextOption::WrapMode(wrapMode)); + } + + layout.setTextOption(textOption); layout.beginLayout(); while (1) { QTextLine line = layout.createLine(); if (!line.isValid()) break; - if (q->widthValid()) { - line.setLineWidth(lineWidth); - line.setPosition(QPointF(0, height)); - height += line.height(); - } + line.setLineWidth(lineWidth); + line.setPosition(QPointF(0, height)); + height += line.height(); } layout.endLayout(); - return QSize(qCeil(layout.boundingRect().width()), layout.boundingRect().height()); + return layout.boundingRect().toAlignedRect().size(); } /*! |