#include <QApplication>
#include <QMainWindow>
#include <QSettings>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    a.setApplicationName("app");
    a.setOrganizationName("org");

    QSettings settings;
    QByteArray geometry = settings.value("geometry").toByteArray();

    QMainWindow w;
    if (!geometry.isEmpty())
        w.restoreGeometry(geometry);

    if (w.isMaximized()) {
        w.showNormal();
        w.showMaximized();
    } else {
        w.show();
    }

    int res = a.exec();
    settings.setValue("geometry", w.saveGeometry());
    return res;
}
