summaryrefslogtreecommitdiffstats
path: root/examples/webenginewidgets/simplebrowser
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2017-09-25 16:27:00 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2017-09-28 15:16:45 +0000
commit0fe0b133b7410940fcba89539d512a7bc13df979 (patch)
tree5719e4094ae2147f0c452f34d74875ae6b93a6e3 /examples/webenginewidgets/simplebrowser
parentec37477bf8a9f8f2591670f04c9e21c697d7e4e4 (diff)
Change the minimal example to be minimally useful
Open the first non-flag argument if one is given Fixes up simplebrowser to act similarly Change-Id: I40270a0f7bc06ce52117f23f7ccbdd743d3d97f6 Reviewed-by: Peter Varga <pvarga@inf.u-szeged.hu> Reviewed-by: Kai Koehne <kai.koehne@qt.io>
Diffstat (limited to 'examples/webenginewidgets/simplebrowser')
-rw-r--r--examples/webenginewidgets/simplebrowser/main.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/examples/webenginewidgets/simplebrowser/main.cpp b/examples/webenginewidgets/simplebrowser/main.cpp
index 93dfc8a8c..25eb15f86 100644
--- a/examples/webenginewidgets/simplebrowser/main.cpp
+++ b/examples/webenginewidgets/simplebrowser/main.cpp
@@ -44,12 +44,14 @@
#include <QApplication>
#include <QWebEngineSettings>
-QUrl getCommandLineUrlArgument()
+QUrl commandLineUrlArgument()
{
const QStringList args = QCoreApplication::arguments();
- if (args.count() > 1)
- return QUrl::fromUserInput(args.last());
- return QUrl();
+ for (const QString &arg : args.mid(1)) {
+ if (!arg.startsWith(QLatin1Char('-')))
+ return QUrl::fromUserInput(arg);
+ }
+ return QUrl(QStringLiteral("https://www.qt.io"));
}
int main(int argc, char **argv)
@@ -62,9 +64,7 @@ int main(int argc, char **argv)
QWebEngineSettings::defaultSettings()->setAttribute(QWebEngineSettings::PluginsEnabled, true);
- QUrl url = getCommandLineUrlArgument();
- if (!url.isValid())
- url = QStringLiteral("https://www.qt.io");
+ QUrl url = commandLineUrlArgument();
Browser browser;
BrowserWindow *window = browser.createWindow();