summaryrefslogtreecommitdiffstats
path: root/examples/opengl/hellowindow/main.cpp
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2017-09-06 13:26:31 +0200
committerLiang Qi <liang.qi@qt.io>2017-09-06 13:26:31 +0200
commit19dd2ca93b8b95a5e2792b29ed62ea23800fb53e (patch)
tree17685d2a9628ec5936155e09da3edd74c9244b0e /examples/opengl/hellowindow/main.cpp
parent942922652481347659a0dae78758c334778a58d2 (diff)
parentd332a2d3ccb485c9decd6c47fa5a5fc02b59d27e (diff)
Merge remote-tracking branch 'origin/5.9' into 5.10
Conflicts: examples/opengl/qopenglwidget/main.cpp src/3rdparty/pcre2/src/pcre2_printint.c src/plugins/platforms/cocoa/qnsview.mm src/widgets/widgets/qcombobox.cpp Change-Id: I37ced9da1e8056f95851568bcc52cd5dc34f56af
Diffstat (limited to 'examples/opengl/hellowindow/main.cpp')
-rw-r--r--examples/opengl/hellowindow/main.cpp27
1 files changed, 23 insertions, 4 deletions
diff --git a/examples/opengl/hellowindow/main.cpp b/examples/opengl/hellowindow/main.cpp
index a20e7002a1..7f0be39f5d 100644
--- a/examples/opengl/hellowindow/main.cpp
+++ b/examples/opengl/hellowindow/main.cpp
@@ -52,6 +52,8 @@
#include <qpa/qplatformintegration.h>
+#include <QCommandLineParser>
+#include <QCommandLineOption>
#include <QGuiApplication>
#include <QScreen>
#include <QThread>
@@ -60,9 +62,26 @@ int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
+ QCoreApplication::setApplicationName("Qt HelloWindow GL Example");
+ QCoreApplication::setOrganizationName("QtProject");
+ QCoreApplication::setApplicationVersion(QT_VERSION_STR);
+ QCommandLineParser parser;
+ parser.setApplicationDescription(QCoreApplication::applicationName());
+ parser.addHelpOption();
+ parser.addVersionOption();
+ QCommandLineOption multipleOption("multiple", "Create multiple windows");
+ parser.addOption(multipleOption);
+ QCommandLineOption multipleSampleOption("multisample", "Multisampling");
+ parser.addOption(multipleSampleOption);
+ QCommandLineOption multipleScreenOption("multiscreen", "Run on multiple screens");
+ parser.addOption(multipleScreenOption);
+ QCommandLineOption timeoutOption("timeout", "Close after 10s");
+ parser.addOption(timeoutOption);
+ parser.process(app);
+
// Some platforms can only have one window per screen. Therefore we need to differentiate.
- const bool multipleWindows = QGuiApplication::arguments().contains(QStringLiteral("--multiple"));
- const bool multipleScreens = QGuiApplication::arguments().contains(QStringLiteral("--multiscreen"));
+ const bool multipleWindows = parser.isSet(multipleOption);
+ const bool multipleScreens = parser.isSet(multipleScreenOption);
QScreen *screen = QGuiApplication::primaryScreen();
@@ -70,7 +89,7 @@ int main(int argc, char *argv[])
QSurfaceFormat format;
format.setDepthBufferSize(16);
- if (QGuiApplication::arguments().contains(QStringLiteral("--multisample")))
+ if (parser.isSet(multipleSampleOption))
format.setSamples(4);
QPoint center = QPoint(screenGeometry.center().x(), screenGeometry.top() + 80);
@@ -136,7 +155,7 @@ int main(int argc, char *argv[])
}
// Quit after 10 seconds. For platforms that do not have windows that are closeable.
- if (QCoreApplication::arguments().contains(QStringLiteral("--timeout")))
+ if (parser.isSet(timeoutOption))
QTimer::singleShot(10000, qGuiApp, &QCoreApplication::quit);
const int exitValue = app.exec();