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 exit on parse()
Forum Updated to NodeBB v4.3 + New Features

QCommandLineParser exit on parse()

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 3 Posters 2.3k 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.
  • M Offline
    M Offline
    moravas
    wrote on last edited by
    #1

    Hi Folks,

    can anybody tell me, what's the right way for using QCommandLineParser?
    I tried this:
    QCommandLineParser _parser;
    _parser.addHelpOption();
    qDebug() << _parser.addOption(QCommandLineOption(QStringList() << "p" << "port"));
    _parser.process(QCoreApplication::arguments());

    I start the debugger with this simple command line option: --port=65000 and I'm getting back "Unexpected value after '--port' "

    What did I wrong?

    Regards,
    Norbert

    1 Reply Last reply
    0
    • jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by jsulm
      #2

      Replace = by a blank: --port 65000

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • M Offline
        M Offline
        moravas
        wrote on last edited by
        #3

        I tested "--port 65000", parse() has been done without exit, but calling "_parser.value("port")" is empty. It seems, that I cannot put value via the command line option.

        1 Reply Last reply
        0
        • jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          You can, check the example in the documentation: http://doc.qt.io/qt-5/qcommandlineparser.html

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • M Offline
            M Offline
            moravas
            wrote on last edited by
            #5

            Hi,

            well, I think, I isoleted something:

            • if I'm using the examples, and create an option: QCommandLineOption port(QStringList() << "p" << "port", "Write generated data into <file>.", "file"); it works well.
            • if I create the option by this way: QCommandLineOption port("port", "declare port");, than the application exits.

            Any other things are stayed unchanged.

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Hi,

              Can you show your complete parser related code ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              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