-
Bug
-
Resolution: Done
-
P3: Somewhat important
-
4.4.0
-
None
Floating toolbars and dock widgets can get stuck off screen under the following circumstances:
A user with dual monitors opens an application with floating toolbars
The user then repositions the application's toolbar on the secondary screen.
The user closes the application, where a call to saveState() saves the positions
The user then removes the secondary monitor and reopens the application.
The application uses restoreState() to position the toolbars, and the toolbars are located offscreen.
QMainWindow::saveState()/restoreState() could be a bit smarter, and check somehow if the positions that it restores windows too are visible with the current screen.
This is reproduceable on windows and mac using the following patch:
==== examples/mainwindows/application/mainwindow.cpp#1 -examples/mainwindows/application/mainwindow.cpp ====
@@ -250,7 +250,11 @@
QSettings settings("Trolltech", "Application Example");
QPoint pos = settings.value("pos", QPoint(200, 200)).toPoint();
QSize size = settings.value("size", QSize(400, 400)).toSize();
- resize(size);
+ QByteArray positions = settings.value("positions").toByteArray();
+
+ restoreState(positions);
+
+ resize(size);
move(pos);
}
//! [35] //! [36]
@@ -262,6 +266,8 @@
QSettings settings("Trolltech", "Application Example");
settings.setValue("pos", pos());
settings.setValue("size", size());
+ settings.setValue("positions", saveState());
+
}
//! [38] //! [39]