Details
-
Bug
-
Resolution: Done
-
P1: Critical
-
4.7.1, 4.8.4, 5.0.2, 5.7.0, 5.9.0 Beta 1
-
Windows, Linux
-
cbfb6bda1d1ce3e169db6a0deb9bd901076653e4
Description
The geometry is not restored correctly when running the example below and following these steps:
1. Build and run the app,
2. Maximize the mainwindow and put dockwidget1 in the left dockarea and dockwidget2 in the bottom dockarea.
3. Close the application.
4. Run the application again. The geometry and state are correct.
5. Resize the left dock and bottom dock bigger, so that the central widget is displayed very small in the top right corner.
6. Close the app
8. Re-run the app - the geometry and state from point 5 are not restored, instead the geometry and state from point 2 are shown.
#include <QtGui> #if QT_VERSION >= 0x50000 #include <QtWidgets> #endif class MainWindow : public QMainWindow { public: MainWindow() { setCentralWidget(new QTextEdit(this)); QDockWidget *dock1 = new QDockWidget(this); dock1->setObjectName("First dock"); dock1->setWidget(new QLabel("Label 1", dock1)); QDockWidget *dock2 = new QDockWidget(this); dock2->setObjectName("Second dock"); dock2->setWidget(new QLabel("Label 2", dock2)); addDockWidget(Qt::TopDockWidgetArea, dock1); addDockWidget(Qt::TopDockWidgetArea, dock2); readSettings(); } void readSettings() { QSettings settings("SomeTest", "SaveRestore Example"); restoreGeometry(settings.value("geometry").toByteArray()); restoreState(settings.value("windowState").toByteArray()); } void writeSettings() { QSettings settings("SomeTest", "SaveRestore Example"); settings.setValue("geometry", saveGeometry()); settings.setValue("windowState", saveState()); } void closeEvent(QCloseEvent *event) { QMainWindow::closeEvent(event); writeSettings(); } }; int main(int argc, char** argv) { QApplication app(argc, argv); MainWindow window; window.show(); return app.exec(); }
with qtbug16252.zip:
- Run app, maximize
- Enlarge left dock widget until it covers approx 2/3 of screen width
- Quit
- Relaunch: Note dock widget width is not restored
Attachments
Issue Links
- relates to
-
QTBUG-46620 QMainWindow:restoreState doesnt restore width of QDockWidgets in maximized QMainWindow
- Closed
-
QTBUG-40155 QMainWindow::restoreDockWidget will not restore a floating dock window to a secondary monitor screen
- Closed
- resulted in
-
QTBUG-68939 Regression caused by the fix for QTBUG-16252
- Closed