summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorYoann Lopes <yoann.lopes@nokia.com>2009-12-02 14:31:09 (GMT)
committerYoann Lopes <yoann.lopes@nokia.com>2009-12-02 14:31:09 (GMT)
commitccde429536ba29dceb1576b6b981a812b0b846fc (patch)
tree3bdf0ab86eb7f9c074c9cf2dfb9b93a2b4e368df /tests
parent25023911295c201758faaa2c800b2388ddf1e0b0 (diff)
downloadQt-ccde429536ba29dceb1576b6b981a812b0b846fc.zip
Qt-ccde429536ba29dceb1576b6b981a812b0b846fc.tar.gz
Qt-ccde429536ba29dceb1576b6b981a812b0b846fc.tar.bz2
Fixes transformation problems with QGraphicsProxyWidget.
In the paintEvent of the widget used in a QGraphicsProxyWidget, the worldMatrix was wrongly used by the painter instead of the deviceMatrix. Similar problem in the WindowsXP Style, the worldMatrix was used instead of the deviceMatrix for determining if the widget is transformed (reviewed by eblomfel). Task-number: QTBUG-5939 Reviewed-by: bnilsen Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qpainter/tst_qpainter.cpp58
1 files changed, 57 insertions, 1 deletions
diff --git a/tests/auto/qpainter/tst_qpainter.cpp b/tests/auto/qpainter/tst_qpainter.cpp
index 8b71349..67d1972 100644
--- a/tests/auto/qpainter/tst_qpainter.cpp
+++ b/tests/auto/qpainter/tst_qpainter.cpp
@@ -41,7 +41,7 @@
#include <QtTest/QtTest>
-
+#include "../../shared/util.h"
#include <qpainter.h>
#include <qapplication.h>
@@ -67,6 +67,11 @@
#include <qqueue.h>
+#include <qgraphicsview.h>
+#include <qgraphicsscene.h>
+#include <qgraphicsproxywidget.h>
+#include <qlayout.h>
+
#if defined(Q_OS_SYMBIAN)
# define SRCDIR "."
#endif
@@ -244,6 +249,8 @@ private slots:
void setPenColorOnImage();
void setPenColorOnPixmap();
+ void QTBUG5939_attachPainterPrivate();
+
private:
void fillData();
void setPenColor(QPainter& p);
@@ -4404,6 +4411,55 @@ void tst_QPainter::setPenColorOnPixmap()
setPenColor(p);
}
+class TestProxy : public QGraphicsProxyWidget
+{
+public:
+ TestProxy() : QGraphicsProxyWidget() {}
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
+ {
+ QGraphicsProxyWidget::paint(painter, option, widget);
+ deviceTransform = painter->deviceTransform();
+ }
+ QTransform deviceTransform;
+};
+
+class TestWidget : public QWidget
+{
+Q_OBJECT
+public:
+ TestWidget() : QWidget(), painted(false) {}
+ void paintEvent(QPaintEvent *)
+ {
+ QPainter p(this);
+ deviceTransform = p.deviceTransform();
+ worldTransform = p.worldTransform();
+ painted = true;
+ }
+ QTransform deviceTransform;
+ QTransform worldTransform;
+ bool painted;
+};
+
+void tst_QPainter::QTBUG5939_attachPainterPrivate()
+{
+ QWidget *w = new QWidget();
+ QGraphicsScene *scene = new QGraphicsScene();
+ QGraphicsView *view = new QGraphicsView(scene, w);
+ view->move(50 ,50);
+ TestProxy *proxy = new TestProxy();
+ TestWidget *widget = new TestWidget();
+ proxy->setWidget(widget);
+ scene->addItem(proxy);
+ proxy->rotate(45);
+ w->resize(scene->sceneRect().size().toSize());
+
+ w->show();
+ QTRY_VERIFY(widget->painted);
+
+ QVERIFY(widget->worldTransform.isIdentity());
+ QCOMPARE(widget->deviceTransform, proxy->deviceTransform);
+}
+
QTEST_MAIN(tst_QPainter)
#include "tst_qpainter.moc"