diff options
author | Morten Johan Sørvig <morten.sorvig@qt.io> | 2017-04-19 11:19:19 +0200 |
---|---|---|
committer | Morten Johan Sørvig <morten.sorvig@qt.io> | 2017-05-11 07:22:51 +0000 |
commit | d7a9e08f0ada36ad8ad44651f27a76c9c74e3428 (patch) | |
tree | e4093a502e10fc0b72ff2fbb98b6659f4be02ef5 /tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp | |
parent | 3ae34b7ead938dc716e2fad2fa686d6867466255 (diff) |
Make QWindow::setVisible() work for widgets
QWidget has its own setVisible() code that needs to
be run in order to correctly transition widget visibility.
It is desirable to be able to show and hide (native)
widgets also from the QWindow side, for example from
the platform plugin, or from generic QWindow handling
code in QtGui.
Add a new virtual QWindowPrivate::setVisible() and
move the QWindow visibility implementation there.
Subclasses can now override this function to add custom
code.
Make QWidgetPrivate::show/hide_sys() call the QWindowPrivate
setVisible implementation instead of the QWindow setVisible
public API.
Change-Id: I082f174b100659e1221d5898b490f8a9f498abdf
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp')
-rw-r--r-- | tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp b/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp index 97d7d78153..a6855a417e 100644 --- a/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp +++ b/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp @@ -102,6 +102,8 @@ private slots: void setWindowState_data(); void setWindowState(); + + void nativeShow(); }; void tst_QWidget_window::initTestCase() @@ -915,5 +917,19 @@ void tst_QWidget_window::setWindowState() QCOMPARE(w.windowHandle()->windowStates(), state | Qt::WindowMinimized); } +void tst_QWidget_window::nativeShow() +{ + // Verify that a native widget can be shown using the QWindow::setVisible() API + QWidget w; + w.winId(); + w.windowHandle()->setVisible(true); + QTest::qWaitForWindowExposed(&w); + QVERIFY(w.isVisible()); + + // ... and that we can hide it + w.windowHandle()->setVisible(false); + QTRY_VERIFY(!w.isVisible()); +} + QTEST_MAIN(tst_QWidget_window) #include "tst_qwidget_window.moc" |