Results 1 to 4 of 4

Thread: Error "QString::arg: Argument missing"

  1. #1
    Join Date
    Dec 2008
    Location
    Qt Reference Documentation
    Posts
    62
    Thanks
    25
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Question Error "QString::arg: Argument missing"

    When building and executing the following code:
    Qt Code:
    1. #include <QString>
    2. #include <iostream>
    3.  
    4. int main()
    5. {
    6. QString someString = QString("1%").arg("Hello World!");
    7.  
    8. std::cout << someString.toStdString();
    9.  
    10. return 0;
    11. }
    To copy to clipboard, switch view to plain text mode 
    I get this output:
    Qt Code:
    1. QString::arg: Argument missing: 1%, Hello World!
    2. 1%
    To copy to clipboard, switch view to plain text mode 

    which includes the error message "QString::arg: Argument missing", why am I getting this??

    Thanks in advance.

  2. #2
    Join Date
    Feb 2008
    Posts
    40
    Thanks
    9
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Error "QString::arg: Argument missing"

    It should be %1, not 1%.

  3. The following user says thank you to gruszczy for this useful post:

    Lawand (18th February 2009)

  4. #3
    Join Date
    Dec 2006
    Posts
    426
    Thanks
    8
    Thanked 18 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Error "QString::arg: Argument missing"

    Change 1% -> %1

  5. The following user says thank you to lni for this useful post:

    Lawand (18th February 2009)

  6. #4
    Join Date
    Dec 2008
    Location
    Qt Reference Documentation
    Posts
    62
    Thanks
    25
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Smile Re: Error "QString::arg: Argument missing"

    Qt Code:
    1. Hello World!
    To copy to clipboard, switch view to plain text mode 
    Thanks gruszczy, the problem drove me crazy, but now it's solved

Tags for this Thread

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.