mirror of
https://github.com/crystalidea/qt6windows7.git
synced 2024-11-24 04:20:46 +08:00
33 lines
960 B
C++
33 lines
960 B
C++
|
// Copyright (C) 2016 The Qt Company Ltd.
|
||
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
||
|
|
||
|
//! [0]
|
||
|
#include <QApplication>
|
||
|
#include <QCommandLineParser>
|
||
|
#include <QCommandLineOption>
|
||
|
|
||
|
#include "mainwindow.h"
|
||
|
|
||
|
int main(int argc, char *argv[])
|
||
|
{
|
||
|
Q_INIT_RESOURCE(application);
|
||
|
|
||
|
QApplication app(argc, argv);
|
||
|
QCoreApplication::setOrganizationName("QtProject");
|
||
|
QCoreApplication::setApplicationName("Application Example");
|
||
|
QCoreApplication::setApplicationVersion(QT_VERSION_STR);
|
||
|
QCommandLineParser parser;
|
||
|
parser.setApplicationDescription(QCoreApplication::applicationName());
|
||
|
parser.addHelpOption();
|
||
|
parser.addVersionOption();
|
||
|
parser.addPositionalArgument("file", "The file to open.");
|
||
|
parser.process(app);
|
||
|
|
||
|
MainWindow mainWin;
|
||
|
if (!parser.positionalArguments().isEmpty())
|
||
|
mainWin.loadFile(parser.positionalArguments().first());
|
||
|
mainWin.show();
|
||
|
return app.exec();
|
||
|
}
|
||
|
//! [0]
|