summaryrefslogtreecommitdiffstats
path: root/src/gui/text
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2010-03-30 12:20:56 (GMT)
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2010-03-30 12:36:23 (GMT)
commit1dece0c73feb0307f90acdc127891fa6313da4cd (patch)
treeed17d259ea0577c0d30f691a9703726aeada4c22 /src/gui/text
parent6e173f50f6b04057040b1e5c4125e3f1b6f885ce (diff)
downloadQt-1dece0c73feb0307f90acdc127891fa6313da4cd.zip
Qt-1dece0c73feb0307f90acdc127891fa6313da4cd.tar.gz
Qt-1dece0c73feb0307f90acdc127891fa6313da4cd.tar.bz2
Support the pen set on the painter in QStaticText when using rich text
When using rich text, QStaticText should still respect the painter's pen color as the default. Since QTextDocument does not respect the pen set on the painter, we need to set its default style sheet to include the pen color as well. Reviewed-by: Olivier
Diffstat (limited to 'src/gui/text')
-rw-r--r--src/gui/text/qstatictext.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/gui/text/qstatictext.cpp b/src/gui/text/qstatictext.cpp
index 45252d8..5f31ef0 100644
--- a/src/gui/text/qstatictext.cpp
+++ b/src/gui/text/qstatictext.cpp
@@ -584,6 +584,11 @@ void QStaticTextPrivate::paintText(const QPointF &topLeftPosition, QPainter *p)
textLayout.draw(p, topLeftPosition);
} else {
QTextDocument document;
+ QColor color = p->pen().color();
+ document.setDefaultStyleSheet(QString::fromLatin1("body { color: #%1%2%3 }")
+ .arg(QString::number(color.red(), 16), 2, QLatin1Char('0'))
+ .arg(QString::number(color.green(), 16), 2, QLatin1Char('0'))
+ .arg(QString::number(color.blue(), 16), 2, QLatin1Char('0')));
document.setDefaultFont(font);
document.setDocumentMargin(0.0);
if (textWidth >= 0.0)