diff options
author | Denis Dzyubenko <denis.dzyubenko@nokia.com> | 2009-08-19 09:35:24 (GMT) |
---|---|---|
committer | Denis Dzyubenko <denis.dzyubenko@nokia.com> | 2009-08-19 12:36:18 (GMT) |
commit | 774543a3336841df4a13d3e283af83cf4b53b966 (patch) | |
tree | 9d3ca5468d9b766476bb1f44b4c41fc940cf510a /doc/src/snippets/code | |
parent | b26af959573407b3bb4cb657f08b76023554607f (diff) | |
download | Qt-774543a3336841df4a13d3e283af83cf4b53b966.zip Qt-774543a3336841df4a13d3e283af83cf4b53b966.tar.gz Qt-774543a3336841df4a13d3e283af83cf4b53b966.tar.bz2 |
Improved the documentation of saving and restoring window geometry.
Mentioned in the doc that the preferred way to save/restore a geometry
of a QMainWindow is to use both saveGeometry() and saveState().
Reviewed-by: Kavindra Devi Palaraja
Diffstat (limited to 'doc/src/snippets/code')
-rw-r--r-- | doc/src/snippets/code/src_gui_widgets_qmainwindow.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/doc/src/snippets/code/src_gui_widgets_qmainwindow.cpp b/doc/src/snippets/code/src_gui_widgets_qmainwindow.cpp new file mode 100644 index 0000000..0e4040a --- /dev/null +++ b/doc/src/snippets/code/src_gui_widgets_qmainwindow.cpp @@ -0,0 +1,19 @@ +//! [0] +void MyMainWindow::closeEvent(QCloseEvent *event) +{ + QSettings settings("MyCompany", "MyApp"); + settings.setValue("geometry", saveGeometry()); + settings.setValue("windowState", saveState()); + QMainWindow::closeEvent(event); +} +//! [0] + + +//! [1] +void MainWindow::readSettings() +{ + QSettings settings("MyCompany", "MyApp"); + restoreGeometry(settings.value("myWidget/geometry").toByteArray()); + restoreState(settings.value("myWidget/windowState").toByteArray()); +} +//! [1] |