Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
6.8.1
-
None
-
Windows 11
2 screens: MSI G273Q (primary screen, 2560x1440 with 125% display scaling), LG SDQHD (2560x2880 with 150% display scaling)
Description
When running the code below, I end up with my window on the wrong screen and also out of bounds after calling showNormal.
From debugging, it seems like this is related to QWindowsWindow::m_savedFrameGeometry used in QWindowsWindow::setWindowState_sys. For some reason, when calling showNormal, m_savedFrameGeometry is still using the previous screen.
Code to reproduce:
QApplication application(argc, argv); QMainWindow window; auto screens = application.screens(); // Move to secondary screen, I think this needs to be a different screen than the one that the MainWindow was created on by default window.setScreen(screens[1]); window.setGeometry(window.screen()->geometry()); window.showFullScreen(); // Move back to primary screen window.setScreen(screens[0]); window.setGeometry(window.screen()->geometry()); window.showFullScreen(); // After this call, the window will show back on the secondary screen window.showNormal(); application.exec();