PDA

View Full Version : Command Line Arguments Parser



lotek
14th March 2011, 16:49
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

squidge
14th March 2011, 18:01
I'd use something like:

http://api.kde.org/4.x-api/kdelibs-apidocs/kdecore/html/classKCmdLineArgs.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.

high_flyer
14th March 2011, 18:25
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.

dfaure
4th October 2013, 17:04
There is one now. I wrote QCommandLineParser, which is in Qt 5.2.