QCommandLineParser: No stdout output after process()
Solved
General and Desktop
-
Hello,
i want to extend the --help output with some examples, but it seems i can't output anything to stdout after the call to process() was made:
#include <iostream> #include <QCoreApplication> int main(int argc, char *argv[]) { QCoreApplication app(argc, argv); QCoreApplication::setApplicationName("my-copy-program"); QCoreApplication::setApplicationVersion("1.0"); QCommandLineParser parser; parser.setApplicationDescription("Test helper"); parser.addHelpOption(); std::cout << "stdout before parser.process" << std::endl; parser.process(app); std::cout << "stdout after parser.process" << std::endl; return 0; }
When i call the exe directly, i get this:
stdout before parser.process stdout after parser.process
When calling with --help:
stdout before parser.process Usage: example.exe [options] Test helper Options: -?, -h, --help Displays help on commandline options. --help-all Displays help including Qt specific options.
(no output of "stdout after parser.process")
That doesn't make sense to me. Why is that?
Thanks.Best regards,
Kevin -
Perfectly documented:
The builtin options are --version if addVersionOption was called and --help / --help-all if addHelpOption was called.
When invoking one of these options, or when an error happens (for instance an unknown option was passed), the current process will then stop, using the exit() function.
-
I've looked but must have missed it. Thank you.