How to control the position of QDialog?

Is there an easy way to open Qt dialogs in the same position as the last time the application was opened?
that is, to maintain the position of dialogs between application sessions?

In an easy way, I mean not to manually write the window position in the file, and then read :)

+4
source share
3 answers

You can use the QSettings class for this. This is an abstraction class that allows your applications to save their settings in order to get them the next time they start.

Save Settings:

QSettings settings("ValueName", "Value"); 

Reading settings:

 QString v = settings.value("ValueName"); 
+10
source

Use QSettings along with QWidget :: restoreGeometry () and QWidget :: saveGeometry ().

+3
source

It is better to save the dialog-> pos (), dialog-> size (), dialog-> isMaximized (), call the dialog-> saveGeometry () does not maximize the window.

QSettings - Preferred Way to Save Configuration

+2
source

All Articles