aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/quick/items/qquicktextnodeengine.cpp4
-rw-r--r--tests/auto/quick/qquicktext/data/transparentBackground.qml16
-rw-r--r--tests/auto/quick/qquicktext/tst_qquicktext.cpp22
3 files changed, 40 insertions, 2 deletions
diff --git a/src/quick/items/qquicktextnodeengine.cpp b/src/quick/items/qquicktextnodeengine.cpp
index 5a4ef2b686..f407de84cb 100644
--- a/src/quick/items/qquicktextnodeengine.cpp
+++ b/src/quick/items/qquicktextnodeengine.cpp
@@ -781,8 +781,8 @@ void QQuickTextNodeEngine::addToSceneGraph(QQuickTextNode *parentNode,
for (int i = 0; i < m_backgrounds.size(); ++i) {
const QRectF &rect = m_backgrounds.at(i).first;
const QColor &color = m_backgrounds.at(i).second;
-
- parentNode->addRectangleNode(rect, color);
+ if (color.alpha() != 0)
+ parentNode->addRectangleNode(rect, color);
}
// Add all text with unselected color first
diff --git a/tests/auto/quick/qquicktext/data/transparentBackground.qml b/tests/auto/quick/qquicktext/data/transparentBackground.qml
new file mode 100644
index 0000000000..a10a1779bb
--- /dev/null
+++ b/tests/auto/quick/qquicktext/data/transparentBackground.qml
@@ -0,0 +1,16 @@
+import QtQuick 2.0
+
+Rectangle {
+ width: 200
+ height: 200
+ color: "white"
+ Text {
+ objectName: "text"
+ textFormat: Text.RichText
+ anchors.fill: parent
+ color: "black"
+ text: "<h1 style=\"background-color:rgba(255,255,255,0.00)\">foo</h1>"
+ verticalAlignment: Text.AlignTop
+ horizontalAlignment: Text.AlignLeft
+ }
+}
diff --git a/tests/auto/quick/qquicktext/tst_qquicktext.cpp b/tests/auto/quick/qquicktext/tst_qquicktext.cpp
index eafa6cb052..3414bec4a6 100644
--- a/tests/auto/quick/qquicktext/tst_qquicktext.cpp
+++ b/tests/auto/quick/qquicktext/tst_qquicktext.cpp
@@ -163,6 +163,8 @@ private slots:
void verticallyAlignedImageInTable();
+ void transparentBackground();
+
private:
QStringList standard;
QStringList richText;
@@ -4428,6 +4430,26 @@ void tst_qquicktext::verticallyAlignedImageInTable()
// Don't crash
}
+void tst_qquicktext::transparentBackground()
+{
+ if ((QGuiApplication::platformName() == QLatin1String("offscreen"))
+ || (QGuiApplication::platformName() == QLatin1String("minimal")))
+ QSKIP("Skipping due to grabToImage not functional on offscreen/minimimal platforms");
+
+ QScopedPointer<QQuickView> window(new QQuickView);
+ window->setSource(testFileUrl("transparentBackground.qml"));
+ QTRY_COMPARE(window->status(), QQuickView::Ready);
+
+ window->show();
+ QVERIFY(QTest::qWaitForWindowExposed(window.data()));
+ QImage img = window->grabWindow();
+ QCOMPARE(img.isNull(), false);
+
+ QColor color = img.pixelColor(0, 0);
+ QCOMPARE(color.red(), 255);
+ QCOMPARE(color.blue(), 255);
+ QCOMPARE(color.green(), 255);
+}
QTEST_MAIN(tst_qquicktext)
#include "tst_qquicktext.moc"