summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2020-08-12 13:21:42 +0200
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2020-08-17 15:08:39 +0200
commitc54a5b83804c00474d141b485b752a7c54169ebf (patch)
tree9016e1579b219072547a4d6892f500929e01e3c8 /tests/auto/widgets
parentc4366ff0183a9a4a5c6eff0312b713e9c5eb97ea (diff)
Introduce QWidget::setScreen
Follows the QWindow semantics, and is a replacement for creating a QWidget with a QDesktopScreenWidget as the parent. We can now remove much of the special handling of QDesktopWidget and the Qt::Desktop window type, and get rid of QDesktopScreenWidget. Add a manual test that allows local testing. Our CI environments only have a single screen, and no multi-head display server setup which is the primary case where QWidget::setScreen is interesting. For the more common case of a virtual desktop, QWidget::setScreen has no real impact (just as QWindow::setScreen doesn't). Change-Id: Id0099e069d316741bacd8c795c396ccad37be297 Fixes: QTBUG-85483 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'tests/auto/widgets')
-rw-r--r--tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
index 6e304f2152..ae91685697 100644
--- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
+++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
@@ -196,6 +196,7 @@ private slots:
void activation();
#endif
void reparent();
+ void setScreen();
void windowState();
void showMaximized();
void showFullScreen();
@@ -2943,6 +2944,29 @@ void tst_QWidget::reparent()
QTRY_COMPARE(childTLW.pos(), tlwPos);
}
+void tst_QWidget::setScreen()
+{
+ const auto screens = QApplication::screens();
+ if (screens.count() < 2)
+ QSKIP("This test tests nothing on a machine with a single screen.");
+
+ QScreen *screen0 = screens.at(0);
+ QScreen *screen1 = screens.at(1);
+
+ QWidget window;
+ window.setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint);
+ window.setScreen(screen0);
+ QCOMPARE(window.screen(), screen0);
+ window.setScreen(screen1);
+ QCOMPARE(window.screen(), screen1);
+
+ // calling setScreen on a widget that is not a window does nothing
+ QWidget child(&window);
+ const QScreen *childScreen = child.screen();
+ child.setScreen(childScreen == screen0 ? screen1 : screen0);
+ QCOMPARE(child.screen(), childScreen);
+}
+
// Qt/Embedded does it differently.
void tst_QWidget::icon()
{