diff options
author | Alexis Menard <alexis.menard@nokia.com> | 2010-05-05 04:57:26 (GMT) |
---|---|---|
committer | Alexis Menard <alexis.menard@nokia.com> | 2010-05-05 23:44:28 (GMT) |
commit | 3c4d3a65bbce6b1f9e649412f141ee8890a7b6cd (patch) | |
tree | 801be34e129444e7f7c908b31ef27462637342a2 /tests/auto | |
parent | b7513f4a15ecac1adf54f2abdda6b56c89d6bef4 (diff) | |
download | Qt-3c4d3a65bbce6b1f9e649412f141ee8890a7b6cd.zip Qt-3c4d3a65bbce6b1f9e649412f141ee8890a7b6cd.tar.gz Qt-3c4d3a65bbce6b1f9e649412f141ee8890a7b6cd.tar.bz2 |
QGraphicsWidget was not working properly when ItemSendsPositionChanges is false
The geometry was not properly set because QGraphicsWidget rely on itemChange
to update its own geometry. Now when calling setPos we also ensure that
for a widget the geometry will be up to date. Setting the flag
ItemSendsPositionChanges to false for a given widget will give a small
performance boost.
Reviewed-by:janarve
Reviewed-by:bnilsen
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp index 1930a6f..1a56e6b 100644 --- a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp +++ b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp @@ -166,6 +166,7 @@ private slots: void initialShow(); void initialShow2(); void itemChangeEvents(); + void itemSendGeometryPosChangesDeactivated(); // Task fixes void task236127_bspTreeIndexFails(); @@ -2972,6 +2973,34 @@ void tst_QGraphicsWidget::itemChangeEvents() QTRY_VERIFY(!item->valueDuringEvents.value(QEvent::EnabledChange).toBool()); } +void tst_QGraphicsWidget::itemSendGeometryPosChangesDeactivated() +{ + QGraphicsScene scene; + QGraphicsView view(&scene); + QGraphicsWidget *item = new QGraphicsWidget; + scene.addItem(item); + view.show(); + QTest::qWaitForWindowShown(&view); + item->setGeometry(QRectF(0, 0, 50, 50)); + QTRY_COMPARE(item->geometry(), QRectF(0, 0, 50, 50)); + + item->setFlag(QGraphicsItem::ItemSendsGeometryChanges, false); + item->setGeometry(QRectF(0, 0, 60, 60)); + QCOMPARE(item->geometry(), QRectF(0, 0, 60, 60)); + QCOMPARE(item->pos(), QPointF(0, 0)); + item->setPos(QPointF(10, 10)); + QCOMPARE(item->pos(), QPointF(10, 10)); + QCOMPARE(item->geometry(), QRectF(10, 10, 60, 60)); + + item->setFlag(QGraphicsItem::ItemSendsScenePositionChanges, false); + item->setGeometry(QRectF(0, 0, 60, 60)); + QCOMPARE(item->geometry(), QRectF(0, 0, 60, 60)); + QCOMPARE(item->pos(), QPointF(0, 0)); + item->setPos(QPointF(10, 10)); + QCOMPARE(item->pos(), QPointF(10, 10)); + QCOMPARE(item->geometry(), QRectF(10, 10, 60, 60)); +} + void tst_QGraphicsWidget::QT_BUG_6544_tabFocusFirstUnsetWhenRemovingItems() { QGraphicsScene scene; |