diff options
author | Shawn Rutledge <[email protected]> | 2023-05-16 07:59:46 +0200 |
---|---|---|
committer | Shawn Rutledge <[email protected]> | 2023-05-16 11:48:14 +0200 |
commit | e5007fcc43af6751c72ec970eed11df5fdb8638e (patch) | |
tree | 8ba622dbc887b2e9f6a3382f9f1c41341f6fcc3b | |
parent | 30560d0c3331582a85d594c3a24a1731a5e53859 (diff) |
qml tool: Use QCommandLineParser::process() rather than parse()
This handles the --version, --help and --help-all options.
Apparently there's no other way to handle --help-all, because
addHelpOption() adds two options but only returns one of them.
Amends bb6602bca2b20d98f24320b10c7a039e605c9a05
Fixes: QTBUG-100678
Pick-to: 6.2 6.5 5.15
Change-Id: Iddd1ba2dae975d7256935d8d357e2f3ac6c013d6
Reviewed-by: Ulf Hermann <[email protected]>
-rw-r--r-- | tools/qml/main.cpp | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/tools/qml/main.cpp b/tools/qml/main.cpp index 9ea69b272d..03925dfdb4 100644 --- a/tools/qml/main.cpp +++ b/tools/qml/main.cpp @@ -441,8 +441,8 @@ int main(int argc, char *argv[]) QCommandLineParser parser; parser.setSingleDashWordOptionMode(QCommandLineParser::ParseAsLongOptions); parser.setOptionsAfterPositionalArgumentsMode(QCommandLineParser::ParseAsPositionalArguments); - const QCommandLineOption helpOption = parser.addHelpOption(); - const QCommandLineOption versionOption = parser.addVersionOption(); + parser.addHelpOption(); + parser.addVersionOption(); #ifdef QT_GUI_LIB QCommandLineOption apptypeOption(QStringList() << QStringLiteral("a") << QStringLiteral("apptype"), QCoreApplication::translate("main", "Select which application class to use. Default is gui."), @@ -530,14 +530,7 @@ int main(int argc, char *argv[]) parser.addPositionalArgument("args", QCoreApplication::translate("main", "Arguments after '--' are ignored, but passed through to the application.arguments variable in QML."), "[-- args...]"); - if (!parser.parse(QCoreApplication::arguments())) { - qWarning() << parser.errorText(); - exit(1); - } - if (parser.isSet(versionOption)) - parser.showVersion(); - if (parser.isSet(helpOption)) - parser.showHelp(); + parser.process(*app); if (parser.isSet(verboseOption)) verboseMode = true; if (parser.isSet(quietOption)) { |