Results 1 to 2 of 2

Thread: Change usage information that comes by default with QCommandLineParser class

  1. #1
    Join Date
    Mar 2016
    Posts
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default Change usage information that comes by default with QCommandLineParser class

    I am working on a simple command line parser using QCommandLineParser class(Qt Version 5.4.0). Below is the code:

    Qt Code:
    1. #include <QCommandLineOption>
    2. #include <QCommandLineParser>
    3. #include <QCoreApplication>
    4. #include <QDebug>
    5. #include <QString>
    6. #include <QStringList>
    7.  
    8. int main(int argc, char *argv[])
    9. {
    10. QCoreApplication app(argc, argv);
    11. QCommandLineParser parser;
    12. parser.addHelpOption();
    13. parser.process(app);
    14. return 0;
    15. }
    To copy to clipboard, switch view to plain text mode 
    When I execute the program, I see the following output

    >./firstCommandLineParser --help
    Usage: ./firstCommandLineParser [options]

    Options:
    -h, --help Displays this help.
    The format of usage information displayed contains only [options] and additionally I can specify positional arguments with addPositionalArgument method.

    However, I want to see the usage information displayed in the following format:

    Usage: ./firstCommandLineParser [-d/-D] directory -s configFile

    Can you please suggest a method to do this?
    Last edited by anda_skoa; 9th March 2016 at 14:05. Reason: missing [code] tags

  2. #2
    Join Date
    Dec 2009
    Location
    New Orleans, Louisiana
    Posts
    791
    Thanks
    13
    Thanked 153 Times in 150 Posts
    Qt products
    Qt5
    Platforms
    MacOS X

    Default Re: Change usage information that comes by default with QCommandLineParser class

    I don't see a way to override the format of the help function. I guess I would say that the help function is there to give you a convenient method of showing usage information. You don't have to use that of course, you can simply write your own usage information to stderr instead of using the built-in help/usage info.
    I write the best type of code possible, code that I want to write, not code that someone tells me to write!

Similar Threads

  1. windows deployment of Qt<while Font class usage>
    By smagesh89 in forum Installation and Deployment
    Replies: 4
    Last Post: 26th November 2015, 18:47
  2. Replies: 4
    Last Post: 16th June 2015, 17:50
  3. What is Type information when creating Class
    By vinothrajendran in forum Qt Tools
    Replies: 1
    Last Post: 20th March 2015, 12:11
  4. QCommandLineParser to complex application
    By atomic in forum Qt Programming
    Replies: 10
    Last Post: 29th August 2014, 12:26
  5. How to change default windows class name?
    By Kevin Hoang in forum Qt Programming
    Replies: 5
    Last Post: 11th January 2012, 22:37

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.