[Development] [Qt5-feedback] Command line parser in QtCore?

Craig.Scott at csiro.au Craig.Scott at csiro.au
Mon Oct 24 00:21:36 CEST 2011

On 24/10/2011, at 7:15 AM, Stephen Bryant wrote:

> Hey guys,
> Apologies for being late to the party!
> If Craig doesn't like QCommandLine, and the other implementation mentioned has 
> legal restrictions, I have an implementation I wrote - with no legal 
> restrictions other than normal Qt license compatibility.

My opinion here is just one among many. ;)

> It supports most of the usual suspects: long and short options, aliases (ie: 
> you can treat 'h', '?' and 'help' as the same thing), parameters (even 
> multiple), and optionally stopping at '--'.  There's no type conversion - 
> everything stays as a QString, but you can ask it what it found, in what 
> order, what it didn't recognise and what was left over at the end!

Sounds more complete than the code I put up for comment. It appears you'd still have to do validation outside of the class, but if I'm the only one who cares about that, it should be trivial for us to wrap your class with something that handled validation as well.

> Oh - it doesn't need subclassing, or use signals or slots.  I'm afraid it's 
> just old-fashioned calls to methods on an object!  :-)

That should keep more people happy. ;)

> It's 2 classes, 755 lines - including Doxygen comments.
> Who should I send a copy to?  (I didn't want to spam the whole list!)

For easy reference, you could just copy the header to pastebin.com and send the link to this list. That would at least allow us to review the API, which is probably more important at this first stage than the implementation.

Dr Craig Scott
Computational Software Engineering Team Leader, CSIRO (CMIS)
Melbourne, Australia

More information about the Development mailing list