Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QCommandLineParser: No stdout output after process()
Forum Updated to NodeBB v4.3 + New Features

QCommandLineParser: No stdout output after process()

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 217 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kkettinger
    wrote on last edited by kkettinger
    #1

    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

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      2
      • K Offline
        K Offline
        kkettinger
        wrote on last edited by
        #3

        I've looked but must have missed it. Thank you.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved