Results 1 to 4 of 4

Thread: Argument count is >0 when there are no arguments?

  1. #1
    Join Date
    Mar 2011
    Location
    Johannesburg, South Africa
    Posts
    13
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Argument count is >0 when there are no arguments?

    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.

    Qt Code:
    1. ArgumentList a1(argc, argv);
    2. if (a1.count() == 0){
    3. qDebug() << "Contact List Test Driver usage" <<endl... etc
    To copy to clipboard, switch view to plain text mode 

    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?

  2. #2
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Argument count is >0 when there are no arguments?

    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.

  3. #3
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Argument count is >0 when there are no arguments?

    Usually first argument is program name, test if count <= 1.
    Last edited by stampede; 8th April 2011 at 15:24. Reason: too slow ;)

  4. The following user says thank you to stampede for this useful post:

    april26 (8th April 2011)

  5. #4
    Join Date
    Mar 2011
    Location
    Johannesburg, South Africa
    Posts
    13
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Argument count is >0 when there are no arguments?

    You are correct, when the arguments are ==1 it works as it should! thanks for your help!

Similar Threads

  1. Count files of a directory
    By radu_d in forum Qt Programming
    Replies: 6
    Last Post: 27th March 2012, 03:17
  2. QString resize() or count()
    By nagabathula in forum Qt Programming
    Replies: 6
    Last Post: 27th December 2010, 12:55
  3. QThread count in Qt applications.
    By hashimov in forum Qt Programming
    Replies: 21
    Last Post: 22nd October 2010, 13:41
  4. Count indexes in QListView
    By been_1990 in forum Qt Programming
    Replies: 5
    Last Post: 17th December 2009, 19:21
  5. [QGLWidget] Count FPS
    By Macok in forum Qt Programming
    Replies: 0
    Last Post: 13th April 2009, 14:01

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.