[SOLVED] After using QMainWindow restoreState QDockWidgets added don't end up in expected position
-
I've put together a QMainWindow with a number of QDockWidgets in the designer. The layout is saved using QSettings when the application closes and restored when the application launches after the QMainWindow is constructed.
After this another QDockWidget is generated and added to the QMainWindow like this
@QDockWidget *runtime_widget(new QDockWidget.......);
runtime_widget->setAllowedAreas(Qt::AllDockWidgetAreas);
addDockWidget(Qt::RightDockWidgetArea, runtime_widget);@In the designer I've placed a dock widget in the RightDockWidgetArea (let's call it designer_widget). The user moves designer_widget to the LeftDockWidgetArea then closes the application. The user re-opens the application and designer_widget appear on the left hand side, however, instead of showing up in the RightDockWidgetArea runtime_widget will show up tabbed along with designer_widget. Other dock widgets (created in the designer) show up wherever the user put them.
What am I forgetting to do so that runtime_widget shows up on the right hand side of the main window?
-
Hi,
Can you show the store and restore related code ?
-
Did you also do the same for the geometry ?
-
I wasn't, however, I just added that in but am getting the same behavior.
@QSettings().setValue("WindowGeometry", saveGeometry());
QSettings().setValue("WindowState", saveState());@@restoreGeometry(QSettings().value("WindowGeometry").toByteArray());
restoreState(QSettings().value("WindowState").toByteArray());@ -
Did you set a name on your dock widgets ?
-
Why delete it ? It can give a hint to another user experiencing the same problem as you.
Just update the thread title prepending [solved] so other forum users may know a solution has been found :)