Results 1 to 4 of 4

Thread: Command Line Arguments Parser

  1. #1
    Join Date
    Sep 2010
    Posts
    62
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Command Line Arguments Parser

    Hello,

    I couldn't find in the Qt help any class that encapsulates command line argument parsing (like getopt(3) or getopt_long(3).
    Is there anything like this or I have to use one of the above methods?

    THX for your help

  2. #2
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Command Line Arguments Parser

    I'd use something like:

    http://api.kde.org/4.x-api/kdelibs-a...dLineArgs.html

    or

    http://code.google.com/p/qtargparser/

    Note however that you should instantiate QApplication before attempting to parse any arguments, as stated in the documentation.

  3. #3
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Command Line Arguments Parser

    What exactly do you need?
    If you just need a list of the arguments given to the application, QApplication::arguments() will give you a QStringList with all the arguments.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  4. #4
    Join Date
    Jan 2006
    Posts
    9
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Command Line Arguments Parser

    There is one now. I wrote QCommandLineParser, which is in Qt 5.2.

Similar Threads

  1. Replies: 7
    Last Post: 15th November 2010, 09:00
  2. Replies: 1
    Last Post: 7th September 2010, 15:49
  3. Internal Qt4 Standards for Command Line Arguments
    By wswartzendruber in forum Newbie
    Replies: 3
    Last Post: 8th October 2009, 07:16
  4. QTest and Command Line Arguments
    By ManuMies in forum Qt Programming
    Replies: 2
    Last Post: 23rd April 2009, 12:32
  5. Retrieving command line arguments inside a Qt application
    By prykHetQuo in forum Qt Programming
    Replies: 5
    Last Post: 14th February 2009, 14:28

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.