1

I have a Qt application that load .dlls which in turn will add QDockwidget widgets to a QMainWindow. To maintain the size and geometry I am saving them in QMainWindow

    QSettings settings;
    settings.setValue("MainWindow/geometry", saveGeometry());
    settings.setValue("MainWindow/windowState", saveState());

and on startup I read back the settings

    QSettings settings;
    restoreState(settings.value("MainWindow/windowState").toByteArray());
    restoreGeometry(settings.value("MainWindow/geometry").toByteArray());

Just before calling show().

When I run the app, close it, then delete one of the dlls (effectively removing a QDockwidget that previously loaded at start up), the app will freeze on the show() call in QMainWindow. I can get the application to start up properly by deleting the registry folder (I'm in Windows) HKEY_CURRENT_USER\Software\MyCompany\MyApplication\MainWindow, but I lose all the other information stored there.

What I want is for the UI to come up as if the missing QDockWidget is hidden and can never be restored, not this nonsense of destroying all of the geometry and state information.

Has anyone seen this problem? Solved it even!?! I would be grateful for any hints, tips, or work-arounds!

Cheers

zdp
  • 119
  • 4
  • 1
    If you know which dock widget will be removed, you can close it before saving the state of the main window, so that the state will not contain removed dock widget's settings at all. – vahancho Mar 07 '14 at 21:32
  • Why don't you check the availability of the dlls with QLibrary and if the corresponding libs are not available, you do not read things in from QSettings respectively? – László Papp Mar 08 '14 at 02:38
  • The problem is that it is an open interface and we can't know what will be loaded. So we don't know the dlls or the widget names – zdp Mar 09 '14 at 21:44

0 Answers0