Saving Window Size State
Jump to navigation
Jump to search
English Български
Saving Window Size State
class MainWindow : public QMainWindow<br />{<br /> Q_OBJECT
public:<br /> MainWindow(QWidget *parent = 0) : QMainWindow(parent) {<br /> QSettings settings;
restoreGeometry(settings.value("mainWindowGeometry&quot;).toByteArray());
// create docks, toolbars, etc…
restoreState(settings.value("mainWindowState&quot;).toByteArray());<br /> }
void closeEvent(QCloseEvent *event) {<br /> QSettings settings;<br /> settings.setValue("mainWindowGeometry&quot;, saveGeometry());<br /> settings.setValue("mainWindowState&quot;, saveState());<br /> }<br />};
int main(int argc, char *argv[])<br />{<br /> QApplication a(argc, argv);<br /> QCoreApplication::setOrganizationDomain("OrgDomain&quot;);<br /> QCoreApplication::setOrganizationName("OrgName&quot;);<br /> QCoreApplication::setApplicationName("AppName&quot;);<br /> QCoreApplication::setApplicationVersion("1.0.0&quot;);
MainWindow w;<br /> w.show();
return a.exec&amp;#40;&#41;;<br />}