summaryrefslogtreecommitdiffstats
path: root/src/gui/graphicsview
diff options
context:
space:
mode:
authorJ-P Nurmi <j-p.nurmi@nokia.com>2011-04-05 11:35:30 (GMT)
committerSamuel Rødal <samuel.rodal@nokia.com>2011-04-05 11:35:44 (GMT)
commit42c1f472dff49cb972066d3d7a65460894bcd92e (patch)
tree21032deeb869ee1ad4be9bce62649ab4c2f5211c /src/gui/graphicsview
parent4dc5dafb4c5185a81446463382e7eab2c3a0b21e (diff)
downloadQt-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.cpp13
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