diff options
author | J-P Nurmi <jpnurmi@digia.com> | 2012-11-29 23:02:52 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2012-11-30 19:32:35 +0100 |
commit | d8fcfbc3c336b76f486ce4fc215076e96ea8090c (patch) | |
tree | 962e0d052b6997f81d5d73600724c5315fa375f3 /src/widgets/graphicsview/qgraphicsitem.cpp | |
parent | 39058bfe8e41badd9297f6eddd26008f39f9a1d8 (diff) | |
download | qtbase-d8fcfbc3c336b76f486ce4fc215076e96ea8090c.tar.gz |
QGV: set QStyleOption::styleObject for graphics items & widgets
Certain QStyle code paths expect the style object to be set. This will
avoid problems when QGraphicsItems/Widgets utilize QStyle for drawing.
Even if things will not necessarily animate properly, such legacy code
won't cause a crash at least.
Change-Id: Ic77cb4ee9820d6c4ec92c7278fd87cb866f5a780
Reviewed-by: Andreas Aardal Hanssen <andreas@hanssen.name>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>
Diffstat (limited to 'src/widgets/graphicsview/qgraphicsitem.cpp')
-rw-r--r-- | src/widgets/graphicsview/qgraphicsitem.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/widgets/graphicsview/qgraphicsitem.cpp b/src/widgets/graphicsview/qgraphicsitem.cpp index 70b44428f2..c30435e56a 100644 --- a/src/widgets/graphicsview/qgraphicsitem.cpp +++ b/src/widgets/graphicsview/qgraphicsitem.cpp @@ -1315,6 +1315,14 @@ void QGraphicsItemPrivate::initStyleOption(QStyleOptionGraphicsItem *option, con option->rect = brect.toRect(); option->levelOfDetail = 1; option->exposedRect = brect; + + // Style animations require a QObject-based animation target. + // If a plain QGraphicsItem is used to draw animated controls, + // QStyle is let to send animation updates to the whole scene. + option->styleObject = q_ptr->toGraphicsObject(); + if (!option->styleObject) + option->styleObject = scene; + if (selected) option->state |= QStyle::State_Selected; if (enabled) |