Fix QSettings documentation
QMainWindow::saveGeometry()/restoreGeometry() should be used to save and restore geometries instead of saving pos/size since it also works in multiscreen settings. Pick-to: 6.1 Change-Id: I27cc5ec13e69266367f035796e208d214f84b043 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
parent
253d97cce6
commit
c59fbf576d
@ -152,8 +152,7 @@ void MainWindow::writeSettings()
|
||||
QSettings settings("Moose Soft", "Clipper");
|
||||
|
||||
settings.beginGroup("MainWindow");
|
||||
settings.setValue("size", size());
|
||||
settings.setValue("pos", pos());
|
||||
settings.setValue("geometry", saveGeometry());
|
||||
settings.endGroup();
|
||||
}
|
||||
//! [16]
|
||||
@ -164,8 +163,11 @@ void MainWindow::readSettings()
|
||||
QSettings settings("Moose Soft", "Clipper");
|
||||
|
||||
settings.beginGroup("MainWindow");
|
||||
resize(settings.value("size", QSize(400, 400)).toSize());
|
||||
move(settings.value("pos", QPoint(200, 200)).toPoint());
|
||||
const auto geometry = settings.value("geometry", QByteArray()).toByteArray();
|
||||
if (geometry.isEmpty())
|
||||
setGeometry(200, 200, 400, 400);
|
||||
else
|
||||
restoreGeometry(geometry)
|
||||
settings.endGroup();
|
||||
}
|
||||
//! [17]
|
||||
|
Loading…
Reference in New Issue
Block a user