Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-82887

QCommandLineParser --help-all argument doesn't work with parse(), only with process()

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 5.14.1
    • Core: Other
    • None

    Description

      If I build qtbase/tests/auto/corelib/tools/qcommandlineparser/testhelper and run it with no arguments, -h or --help-all I don't see a difference: just help about the specified options. I don't see help about Qt options like -geometry or -plugin for example.

      QCommandLineParser::addHelpOption() returns a QCommandLineOption object, which I can check afterwards:

          if (parser.isSet(helpOption))
              parser.showHelp();
      

      But is --help-all supposed to be a different option? How can I tell which help option the user chose? (Do I even need to?)

      In my application, it doesn't seem like the statement in the docs that "These options are handled automatically by QCommandLineParser." is always true. qtbase/tests/auto/corelib/tools/qcommandlineparser/testhelper does not test the option object, but only tests whether any positional arguments were given; if none were given, it exits, but help is shown. But in my application, positional arguments are optional; so it seems to me that I need to check whether help was explicitly requested and decide for myself whether to show it or not. If I comment out those lines, my application ignores the help option and opens the window as usual, with no content loaded (as if no options were given). So I think showHelp() should show either the basic help or the extended help with all Qt options (which is not happening anyway). And to make the "handled automatically" statement true, it would have to exit if the user has used any of the help options. Maybe it's better to change the docs to recommend testing isSet(helpOption) instead?

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              dfaure_kdab David Faure
              srutledg Shawn Rutledge
              Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes