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 'option not expecting values' means?
Forum Updated to NodeBB v4.3 + New Features

QCommandLineParser 'option not expecting values' means?

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 1 Posters 249 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.
  • D Offline
    D Offline
    DungeonLords
    wrote on 11 Feb 2025, 11:10 last edited by
    #1

    I want to parse arguments of my CLI app. Why I get warning 'option not expecting values'?

    #include <QCommandLineParser>
    QCommandLineParser parser;
    QCommandLineOption NumOption(QStringList() << "n" << "num", "help text");
    parser.addOption(NumOption);
    const QString numStr= parser.value(NumOption); //warning 'option not expecting values' here
    

    To start app I use

    ./app --num 123
    QCommandLineParser: option not expecting values: "num"
    
    1 Reply Last reply
    0
    • D Offline
      D Offline
      DungeonLords
      wrote on 11 Feb 2025, 11:10 last edited by DungeonLords
      #2

      Because of you use not flag (set/unset) but value (like '-n 123'), you should also set valueName... So your code should be

      QCommandLineOption NumOption(QStringList() << "n" << "num", "help text", "num");
      

      I ask Qt company to make warning message more user-friendly here.

      1 Reply Last reply
      2
      • D DungeonLords has marked this topic as solved on 11 Feb 2025, 11:10

      1/2

      11 Feb 2025, 11:10

      • Login

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