Saving Window Size State/bg
Jump to navigation
Jump to search
Български English
Запаметяване на състоянието на прозорец
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 />}