Details
-
Bug
-
Resolution: Done
-
P2: Important
-
4.8.0, 5.2.0, 5.8.0
-
win32-msvc2008
win32-msvc2013
-
Fix normal geometry on Windows: b9fe8e30cbd7564d9610e097e219212663e42165 (dev, 7.2.2014, 5.3) Fix restore to maximized in Qt 5 ae4243df1e53b0aaeada708f6fa7979a0f0d216a (dev 12.2.2014, 5.3), Qt 4.8.6: d38ae7ea322bedb16045d0dc4a71498fadfb2dd9 (14.3.2014)
Description
QWidget::restoreGeometry always shows application window on primary screen if it was in maximized or fullScreen state before calling QWidget::saveGeometry. I have to write something like this to restore my application in fullScreen state on non-primary screens:
QSettings settings; restoreGeometry(settings.value("mainWindowGeometry").toByteArray()); // Application is on primary screen if ( isFullScreen() ) { showNormal(); showFullScreen(); // Application is on another screen, where is was before calling QWidget::saveGeometry };
Update 2017-02-14:
Same thing with window moving (win32-msvc2013, Qt-5.8.0).
/* I want to move a window from screen 0 to screen 1 in fullscreen state, screen 0 has different resolution than screen 1. */ void CMyWindow::moveToScreen(int screen) { // window is on screen 0 in fullscreen state // screen == 1 QDesktopWidget desktop; if (desktop.screenCount() <= screen) return; // screenCount returns 2 QRect screenGeometry = desktop.availableGeometry(screen); bool fullScreen = this->isFullScreen(); bool maximized = this->isMaximized(); // screenGeometry is corrent // fullScreen == true if (fullScreen || maximized) this->showNormal(); // window is on screen 0 in normal state QRect geometry = this->geometry(); geometry.moveCenter(screenGeometry.center()); this->setGeometry(geometry); // window is on screen 1 in normal state if (fullScreen) this->showFullScreen(); if (maximized) this->showMaximized(); // Window is on screen 0 in fullscreen state. // BUG, it must be on screen 1, but it is on screen 0 somehow. // bug walkaround if (fullScreen) { this->showNormal(); this->showFullScreen(); }; // window is on screen 1 in fullscreen state };
Attachments
Issue Links
- relates to
-
QTBUG-30636 Regression: QWidget::restoreGeometry does not work correctly after maximized
- Closed
-
QTBUG-36407 After restoring the settings from Qt 4.8.4 the position of a dialog doesn't get restored correctly with a Dell notebook with dual monitor
- Closed
-
QTBUG-26322 Restoring from an initial Maximized state doesn’t work (anymore?) on Windows
- Closed
- resulted from
-
QTBUG-4397 QWidget::RestoreGeometry does not work if saveGeometry() is called while a widget is maximized [regression]
- Closed