diff options
author | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com> | 2010-08-27 10:28:40 (GMT) |
---|---|---|
committer | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com> | 2010-08-27 10:46:21 (GMT) |
commit | a2fd1b5265b1c6e9b3d8e1a03ddb2675f5df748d (patch) | |
tree | 71d27a73882696240de49330600e2ca6f5c5275d /src | |
parent | bdcfcc607c1a6744cf1b35eca0914fa96e70071c (diff) | |
download | Qt-a2fd1b5265b1c6e9b3d8e1a03ddb2675f5df748d.zip Qt-a2fd1b5265b1c6e9b3d8e1a03ddb2675f5df748d.tar.gz Qt-a2fd1b5265b1c6e9b3d8e1a03ddb2675f5df748d.tar.bz2 |
Make sure propagated font in QGraphicsWidget can be set on a QPainter
In QWidget and QGraphicsWidget, propagating fonts blank out the resolve
mask, mainly to help in determining inheritance. This means that when
the font is set on a QPainter with device and therefore resolved against
the device font, none of the attributes in the font will take presedence
and the font will essentially just be ignored. For QWidgets this has not
been a problem due to the fact that the painter is opened on the widget,
getting the propagated font as its device font. For QGraphicsWidget,
however, the QPainter is opened on the viewport and the viewport's font
will therefore override the propagated font when it's passed into
setFont(). To fix this, we need the font returned by
QGraphicsWidget::font() to contain the resolve mask of the inherited
parts of its font as well. This is done last minute to avoid messing
up the rules of inheritance in the QGraphicsWidget tree (problem arises
e.g. in hierarchy A -> B -> C and a font is set on B which should override
the font C has previously inherited from A.)
Task-number: QTBUG-13188
Reviewed-by: Lars
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/graphicsview/qgraphicswidget.cpp | 4 | ||||
-rw-r--r-- | src/gui/graphicsview/qgraphicswidget_p.cpp | 3 |
2 files changed, 6 insertions, 1 deletions
diff --git a/src/gui/graphicsview/qgraphicswidget.cpp b/src/gui/graphicsview/qgraphicswidget.cpp index 0fabd18..1bfe266 100644 --- a/src/gui/graphicsview/qgraphicswidget.cpp +++ b/src/gui/graphicsview/qgraphicswidget.cpp @@ -937,7 +937,9 @@ void QGraphicsWidget::setStyle(QStyle *style) QFont QGraphicsWidget::font() const { Q_D(const QGraphicsWidget); - return d->font; + QFont fnt = d->font; + fnt.resolve(fnt.resolve() | d->inheritedFontResolveMask); + return fnt; } void QGraphicsWidget::setFont(const QFont &font) { diff --git a/src/gui/graphicsview/qgraphicswidget_p.cpp b/src/gui/graphicsview/qgraphicswidget_p.cpp index f7850ca..3466733 100644 --- a/src/gui/graphicsview/qgraphicswidget_p.cpp +++ b/src/gui/graphicsview/qgraphicswidget_p.cpp @@ -254,7 +254,10 @@ void QGraphicsWidgetPrivate::setFont_helper(const QFont &font) void QGraphicsWidgetPrivate::resolveFont(uint inheritedMask) { + Q_Q(QGraphicsWidget); inheritedFontResolveMask = inheritedMask; + if (QGraphicsWidget *p = q->parentWidget()) + inheritedFontResolveMask |= p->d_func()->inheritedFontResolveMask; QFont naturalFont = naturalWidgetFont(); QFont resolvedFont = font.resolve(naturalFont); updateFont(resolvedFont); |