PDA

View Full Version : Argument count is >0 when there are no arguments?



april26
8th April 2011, 15:17
I have created a small application and 99% is fine. However I have a message that should appear (in main) if there are no arguments in the application.


ArgumentList a1(argc, argv);
if (a1.count() == 0){
qDebug() << "Contact List Test Driver usage" <<endl... etc

The message doesn't appear coded like this, but does appear if I change ==0 to >0.

Clearly the program is getting arguments from somewhere. I usually set them under Projects / Build settings but is there somewhere else where it could be finding arguments?

Zlatomir
8th April 2011, 15:23
Usually there is one argument passed by the OS, the name (and path) of the executable, this is the first one, any other you pass form console are after this one.

//you can print the arguments and see what it's passed.

stampede
8th April 2011, 15:24
Usually first argument is program name, test if count <= 1.

april26
8th April 2011, 16:44
You are correct, when the arguments are ==1 it works as it should! thanks for your help!