summaryrefslogtreecommitdiff
path: root/tests/auto/qgraphicsview
diff options
context:
space:
mode:
authorYoann Lopes <yoann.lopes@nokia.com>2009-11-20 13:29:57 +0100
committerYoann Lopes <yoann.lopes@nokia.com>2009-11-20 15:19:11 +0100
commit0b8639aee92913cdfaa4386aa09dde0f5cb2eaee (patch)
treeb6289e83299ac217f4aacc93d53e33791b67402e /tests/auto/qgraphicsview
parent7871ebfc4d2adf2313c7431c9d6fa221a903b81d (diff)
downloadqt4-tools-0b8639aee92913cdfaa4386aa09dde0f5cb2eaee.tar.gz
Fixes painting issues when scaling a QGraphicsView.
The problem was that the 'exposed rectangle' passed to the Item's paint() function was rounded to Int values, whereas the one passed to drawBackground and drawForeground was not. Autotest included. Task-number: QTBUG-5859 Reviewed-by: bnilsen
Diffstat (limited to 'tests/auto/qgraphicsview')
-rw-r--r--tests/auto/qgraphicsview/tst_qgraphicsview.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp
index 1ff06c2f6f..797e1fbf7b 100644
--- a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp
+++ b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp
@@ -235,6 +235,7 @@ private slots:
void task259503_scrollingArtifacts();
void QTBUG_4151_clipAndIgnore_data();
void QTBUG_4151_clipAndIgnore();
+ void QTBUG_5859_exposedRect();
};
void tst_QGraphicsView::initTestCase()
@@ -3867,5 +3868,43 @@ void tst_QGraphicsView::QTBUG_4151_clipAndIgnore()
QCOMPARE(view.items(view.rect()).size(), numItems);
}
+void tst_QGraphicsView::QTBUG_5859_exposedRect()
+{
+ class CustomScene : public QGraphicsScene
+ {
+ public:
+ CustomScene(const QRectF &rect) : QGraphicsScene(rect) { }
+ void drawBackground(QPainter *painter, const QRectF &rect)
+ { lastBackgroundExposedRect = rect; }
+ QRectF lastBackgroundExposedRect;
+ };
+
+ class CustomRectItem : public QGraphicsRectItem
+ {
+ public:
+ CustomRectItem(const QRectF &rect) : QGraphicsRectItem(rect)
+ { setFlag(QGraphicsItem::ItemUsesExtendedStyleOption); }
+ void paint(QPainter * painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0)
+ { lastExposedRect = option->exposedRect; }
+ QRectF lastExposedRect;
+ };
+
+ CustomScene scene(QRectF(0,0,50,50));
+
+ CustomRectItem item(scene.sceneRect());
+
+ scene.addItem(&item);
+
+ QGraphicsView view(&scene);
+ view.scale(4.15, 4.15);
+ view.show();
+ QTest::qWaitForWindowShown(&view);
+
+ view.viewport()->repaint(10,10,20,20);
+ QApplication::processEvents();
+
+ QCOMPARE(item.lastExposedRect, scene.lastBackgroundExposedRect);
+}
+
QTEST_MAIN(tst_QGraphicsView)
#include "tst_qgraphicsview.moc"