diff options
author | J-P Nurmi <j-p.nurmi@nokia.com> | 2011-04-05 11:35:30 (GMT) |
---|---|---|
committer | Samuel Rødal <samuel.rodal@nokia.com> | 2011-04-05 11:35:44 (GMT) |
commit | 42c1f472dff49cb972066d3d7a65460894bcd92e (patch) | |
tree | 21032deeb869ee1ad4be9bce62649ab4c2f5211c /src/gui/graphicsview | |
parent | 4dc5dafb4c5185a81446463382e7eab2c3a0b21e (diff) | |
download | Qt-42c1f472dff49cb972066d3d7a65460894bcd92e.zip Qt-42c1f472dff49cb972066d3d7a65460894bcd92e.tar.gz Qt-42c1f472dff49cb972066d3d7a65460894bcd92e.tar.bz2 |
Draw graphics item bounding rects drawn when QT_DRAW_SCENE_ITEM_RECTS=1
It is extremely handy to visualize bounding rects when developing pixel
perfect graphics view based applications. This change makes it possible
to define an environment variable (inspired by QT_FLUSH_PAINT) to enable
drawing of graphics items' bounding rects with random colors. Any
graphics view/declarative example can be used to test the feature.
Merge-request: 981
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
Diffstat (limited to 'src/gui/graphicsview')
-rw-r--r-- | src/gui/graphicsview/qgraphicsscene.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index 7932a73..faa29e5 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -4948,6 +4948,19 @@ void QGraphicsScenePrivate::draw(QGraphicsItem *item, QPainter *painter, const Q if (painterStateProtection || restorePainterClip) painter->restore(); + + static int drawRect = qgetenv("QT_DRAW_SCENE_ITEM_RECTS").toInt(); + if (drawRect) { + QPen oldPen = painter->pen(); + QBrush oldBrush = painter->brush(); + quintptr ptr = reinterpret_cast<quintptr>(item); + const QColor color = QColor::fromHsv(ptr % 255, 255, 255); + painter->setPen(color); + painter->setBrush(Qt::NoBrush); + painter->drawRect(adjustedItemBoundingRect(item)); + painter->setPen(oldPen); + painter->setBrush(oldBrush); + } } // Draw children in front |