diff options
author | Bjørn Erik Nilsen <bjorn.nilsen@nokia.com> | 2009-06-22 10:09:53 +0200 |
---|---|---|
committer | Bjørn Erik Nilsen <bjorn.nilsen@nokia.com> | 2009-06-22 12:39:33 +0200 |
commit | 5281f264dc605766ba82c36fc2c88055234824ff (patch) | |
tree | 0c16efb51157d22496b44b4885f11bc2b89d51a7 /tests/auto/qwidget | |
parent | 4c515cebc653e44fe6374058b205610592128ea4 (diff) | |
download | qt4-tools-5281f264dc605766ba82c36fc2c88055234824ff.tar.gz |
Moving a child widget right after show() does not work as expected.
The problem was that we did an accelerated move, i.e. scrolled the
widget's contents in the backing store and repainted the old area. We
cannot do this trick when the widget has been invalidated (show(),
resize()). In this case the widget had never been painted, so we
basically scrolled the content of its parent and the widget itself
appeared as invisible.
Auto-test included.
Task-number: 255117
Reviewed-by: Paul
Diffstat (limited to 'tests/auto/qwidget')
-rw-r--r-- | tests/auto/qwidget/tst_qwidget.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp index a6458a58eb..e65fef12e0 100644 --- a/tests/auto/qwidget/tst_qwidget.cpp +++ b/tests/auto/qwidget/tst_qwidget.cpp @@ -252,6 +252,7 @@ private slots: void moveChild_data(); void moveChild(); + void showAndMoveChild(); void subtractOpaqueSiblings(); @@ -5303,6 +5304,33 @@ void tst_QWidget::moveChild() parent.color); } +void tst_QWidget::showAndMoveChild() +{ + QWidget parent(0, Qt::FramelessWindowHint); + parent.resize(300, 300); + parent.setPalette(Qt::red); + parent.show(); +#ifdef Q_WS_X11 + qt_x11_wait_for_window_manager(&parent); +#endif + QTest::qWait(200); + + const QPoint tlwOffset = parent.geometry().topLeft(); + QWidget child(&parent); + child.resize(100, 100); + child.setPalette(Qt::blue); + child.setAutoFillBackground(true); + + // Ensure that the child is repainted correctly when moved right after show. + // NB! Do NOT processEvents() (or qWait()) in between show() and move(). + child.show(); + child.move(150, 150); + qApp->processEvents(); + + VERIFY_COLOR(child.geometry().translated(tlwOffset), Qt::blue); + VERIFY_COLOR(QRegion(parent.geometry()) - child.geometry().translated(tlwOffset), Qt::red); +} + void tst_QWidget::subtractOpaqueSiblings() { #ifdef QT_MAC_USE_COCOA |