summaryrefslogtreecommitdiffstats
path: root/examples/pdfwidgets/pdfviewer/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'examples/pdfwidgets/pdfviewer/main.cpp')
-rw-r--r--examples/pdfwidgets/pdfviewer/main.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/examples/pdfwidgets/pdfviewer/main.cpp b/examples/pdfwidgets/pdfviewer/main.cpp
index 7df5fe253..6b890e0ac 100644
--- a/examples/pdfwidgets/pdfviewer/main.cpp
+++ b/examples/pdfwidgets/pdfviewer/main.cpp
@@ -3,16 +3,27 @@
#include "mainwindow.h"
#include <QApplication>
+#include <QCommandLineParser>
+#include <QCommandLineOption>
#include <QUrl>
int main(int argc, char *argv[])
{
+ QCoreApplication::setApplicationName("Qt PDF Viewer");
+ QCoreApplication::setOrganizationName("QtProject");
+
QApplication a(argc, argv);
+
+ QCommandLineParser parser;
+ parser.addHelpOption();
+ parser.addVersionOption();
+ parser.addPositionalArgument("file", "The file to open.");
+ parser.process(a);
+
MainWindow w;
- QStringList args = a.arguments();
w.show();
- if (args.length() > 1)
- w.open(QUrl::fromLocalFile(args[1]));
+ if (!parser.positionalArguments().isEmpty())
+ w.open(QUrl::fromLocalFile(parser.positionalArguments().constFirst()));
return a.exec();
}