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. Cant get QCommandLineParser to ... parse
Forum Updated to NodeBB v4.3 + New Features

Cant get QCommandLineParser to ... parse

Scheduled Pinned Locked Moved Solved General and Desktop
qcommandlinepar
3 Posts 2 Posters 320 Views
  • 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
    Dariusz
    wrote on 11 Feb 2022, 09:34 last edited by
    #1

    Hey

    I'm lost heres my code +/-

    QCommandLineParser parser;
    parser.setApplicationDescription("test App");
    parser.addHelpOption();
    parser.addVersionOption();
    parser.setSingleDashWordOptionMode(QCommandLineParser::ParseAsLongOptions);
    
    QCommandLineOption argTEst(QStringList() << "lala" << "ohDearNuggets", "testStuff");
    
    parser.addOption(argTEst);
    parser.process(app);
    
    if (parser.isSet(argTEst)) {
        qDebug()<< parser.value(argTEst);
    }
    qDebug() << parser.optionNames() << parser.positionalArguments();
    

    This always print empty, I can see a valid argument in optionNames()/positionalArguments... But it never return the value when asked...

    I start app via app.exe -lala tralalalal

    What am I doing wrong here...

    1 Reply Last reply
    0
    • C Offline
      C Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on 11 Feb 2022, 09:42 last edited by
      #3

      See the documentation: "In addition, the valueName needs to be set if the option expects a value. "

      1 Reply Last reply
      2
      • C Offline
        C Offline
        Christian Ehrlicher
        Lifetime Qt Champion
        wrote on 11 Feb 2022, 09:36 last edited by
        #2
        This post is deleted!
        1 Reply Last reply
        0
        • C Offline
          C Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on 11 Feb 2022, 09:42 last edited by
          #3

          See the documentation: "In addition, the valueName needs to be set if the option expects a value. "

          1 Reply Last reply
          2

          3/3

          11 Feb 2022, 09:42

          • Login

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