diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2019-02-27 19:48:22 +0100 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2019-02-28 19:09:23 +0000 |
commit | 634b59f187c8697f03a606cbacb5f0a69650ea7c (patch) | |
tree | 9ac452c5667c9a0ce8eaf8d91561e2608b3e440c /src/quick/items/qquicktext.cpp | |
parent | 6bc72d76b60de1e02e5356d48ee662568cc624c6 (diff) |
Text: render table cell backgrounds properly
QQuickTextNodeEngine::addTextBlock() was noticing the background color of
text fragments, including those within table cells (and adding to the
colorChanges vector for rendering), but not rendering a rectangle for the
background of the entire table cell. So while the color was correct, it
only took up as much space as the text itself.
Also, QTextDocumentLayout needs to be told how much width is available
so that QTextDocumentLayoutPrivate::layoutTable() will allocate cell width
appropriately in case width is given as a percentage, e.g. <td width="20%">.
This is done by calling QTextDocument::setPageSize() with correct width in
pixels rather than zero.
Fixes: QTBUG-72457
Change-Id: I5c8f861829f76d1cf4044fccd1142c3817bb33bc
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/quick/items/qquicktext.cpp')
-rw-r--r-- | src/quick/items/qquicktext.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/quick/items/qquicktext.cpp b/src/quick/items/qquicktext.cpp index dd7fbccff5..8b6f59497f 100644 --- a/src/quick/items/qquicktext.cpp +++ b/src/quick/items/qquicktext.cpp @@ -442,7 +442,7 @@ void QQuickTextPrivate::updateSize() if (internalWidthUpdate) return; - extra->doc->setPageSize(QSizeF()); + extra->doc->setPageSize(QSizeF(q->width(), -1)); if (q->widthValid() && (wrapMode != QQuickText::NoWrap || extra->doc->idealWidth() < availableWidth())) extra->doc->setTextWidth(availableWidth()); else @@ -1247,7 +1247,7 @@ void QQuickTextPrivate::ensureDoc() if (!extra.isAllocated() || !extra->doc) { Q_Q(QQuickText); extra.value().doc = new QQuickTextDocumentWithImageResources(q); - extra->doc->setPageSize(QSizeF(0, 0)); + extra->doc->setPageSize(QSizeF(q->width(), -1)); extra->doc->setDocumentMargin(0); extra->doc->setBaseUrl(q->baseUrl()); qmlobject_connect(extra->doc, QQuickTextDocumentWithImageResources, SIGNAL(imagesLoaded()), |