summaryrefslogtreecommitdiffstats
path: root/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
diff options
context:
space:
mode:
authorAlexis Menard <alexis.menard@nokia.com>2009-10-02 10:32:26 (GMT)
committerAlexis Menard <alexis.menard@nokia.com>2009-10-02 10:32:26 (GMT)
commit13a1cc06e9c65205d4485091c97800a7eea68cc6 (patch)
tree0a34a2f04462fd841066ad5110b8121f4b21bbe6 /tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
parentb0b8d8f7a65e31c0edabe7fbe6ee91bb62a67d7c (diff)
parent0573653f830fada99311c88ab46e8f5a37854b90 (diff)
downloadQt-13a1cc06e9c65205d4485091c97800a7eea68cc6.zip
Qt-13a1cc06e9c65205d4485091c97800a7eea68cc6.tar.gz
Qt-13a1cc06e9c65205d4485091c97800a7eea68cc6.tar.bz2
Merge branch '4.5' of git@scm.dev.nokia.troll.no:qt/qt into 4.6
Conflicts: src/gui/graphicsview/qgraphicsscene.cpp src/gui/graphicsview/qgraphicsscene_p.h
Diffstat (limited to 'tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp')
-rw-r--r--tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
index 297b6d3..9545198 100644
--- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
+++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
@@ -49,12 +49,14 @@
#include <QAbstractTextDocumentLayout>
#include <QBitmap>
#include <QCursor>
+#include <QLabel>
#include <QDial>
#include <QGraphicsItem>
#include <QGraphicsScene>
#include <QGraphicsSceneEvent>
#include <QGraphicsView>
#include <QGraphicsWidget>
+#include <QGraphicsProxyWidget>
#include <QPainter>
#include <QScrollBar>
#include <QVBoxLayout>
@@ -330,6 +332,7 @@ private slots:
void itemClipsChildrenToShape();
void itemClipsChildrenToShape2();
void itemClipsChildrenToShape3();
+ void itemClipsChildrenToShape4();
void itemClipsTextChildToShape();
void itemClippingDiscovery();
void ancestorFlags();
@@ -5170,6 +5173,44 @@ void tst_QGraphicsItem::itemClipsChildrenToShape3()
QCOMPARE(scene.itemAt(175,175), (QGraphicsItem *)0);
}
+class MyProxyWidget : public QGraphicsProxyWidget
+{
+public:
+ MyProxyWidget(QGraphicsItem *parent) : QGraphicsProxyWidget(parent)
+ {
+ painted = false;
+ }
+
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
+ {
+ QGraphicsProxyWidget::paint(painter, option, widget);
+ painted = true;
+ }
+ bool painted;
+};
+
+void tst_QGraphicsItem::itemClipsChildrenToShape4()
+{
+ QGraphicsScene scene;
+ QGraphicsView view(&scene);
+
+ QGraphicsWidget * outerWidget = new QGraphicsWidget();
+ outerWidget->setFlag(QGraphicsItem::ItemClipsChildrenToShape, true);
+ MyProxyWidget * innerWidget = new MyProxyWidget(outerWidget);
+ QLabel * label = new QLabel();
+ label->setText("Welcome back my friends to the show that never ends...");
+ innerWidget->setWidget(label);
+ view.resize(300, 300);
+ scene.addItem(outerWidget);
+ outerWidget->resize( 200, 100 );
+ scene.addEllipse( 100, 100, 100, 50 ); // <-- this is important to trigger the right codepath*
+ //now the label is shown
+ outerWidget->setFlag(QGraphicsItem::ItemClipsChildrenToShape, false );
+ QApplication::setActiveWindow(&view);
+ view.show();
+ QTRY_COMPARE(QApplication::activeWindow(), (QWidget *)&view);
+ QTRY_COMPARE(innerWidget->painted, true);
+}
void tst_QGraphicsItem::itemClipsTextChildToShape()
{