Results 1 to 10 of 10

Thread: Warning QString::arg() argument missing

  1. #1
    Join Date
    Apr 2006
    Posts
    122
    Thanks
    18
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Warning QString::arg() argument missing

    greetings,
    in the following code i am intializing a QString object
    Qt Code:
    1. QString labelString;
    2. ...
    3. labelString.clear();
    4. labelString=QString("X%1 Y%2").arg(p.x()).arg(p.y()); //getting warning for this line
    5. ..
    To copy to clipboard, switch view to plain text mode 

    This code is resulting in warning

    Warning: QString::arg() :Argument Missing : X1.2233 Y4.23232

    I couldn't find out the cause of this. Sicne this code is used very frequently so its like getting 200 wanings in 1 sec.

    quickNitin

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Warning QString::arg() argument missing

    I don't see anything wrong with that particular line. Are you 100% sure it's that line?
    J-P Nurmi

  3. #3
    Join Date
    Apr 2006
    Posts
    122
    Thanks
    18
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Warning QString::arg() argument missing

    yes, i am.
    I have tried to make diferent string. Like
    Qt Code:
    1. labelString=QString("X%1f Y%2y).arg(p.x()).arg(p.y());
    To copy to clipboard, switch view to plain text mode 
    This results in 'f' succesiding numbers.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Warning QString::arg() argument missing

    So what's wrong with it? What would you like to get?

  5. #5
    Join Date
    Apr 2006
    Posts
    122
    Thanks
    18
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Warning QString::arg() argument missing

    its giving me what output i want but it is resulting in a warning also. Since this code is continuously used so many warnings which i want to avoid as i can't see other info on terminal.

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Warning QString::arg() argument missing

    But this code is correct (apart from a missing quote). Are you sure the warning is related to this line? Could you provide a minimal compilable example which reproduces the problem?

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Warning QString::arg() argument missing

    Maybe you use that labelString in arg() in some other place?

  8. #8
    Join Date
    Apr 2006
    Posts
    122
    Thanks
    18
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Warning QString::arg() argument missing

    here is part of code generated this warning.

    Qt Code:
    1. virtual void drawShape(QPainter &p)
    2. { //std::cout<<"|"<<mX<<" "<<mY;
    3.  
    4. //preparing label to be displayed
    5. QString labelString;
    6. if(mLabelIndex==0) {
    7. labelString.clear();
    8. labelString.setNum(mNo);
    9. }
    10. else if(mLabelIndex==1) {
    11. QgsPoint p=toMapCoords(QPoint(mX,mY));
    12. qWarning("Hello");
    13. labelString=QString("X%1 Y%1").arg(p.x()+mapCenterX).arg(p.y()+mapCenterY);
    14. qWarning("Bye");
    15. }
    16. QBrush brush(Qt::blue);
    17. if(mId==0) /
    18. { p.save();
    19. p.setBrush(brush);
    20. p.drawEllipse(QRect(mX-3+mapCenterX,mY-3+mapCenterY,16,16));
    21. p.drawLine(mX+mapCenterX, mY+mapCenterY, mX+mapCenterX, mY-10+mapCenterY);
    22. if(mShowLabel)
    23. p.drawText(QPoint(mX+5+mapCenterX, mY+5+mapCenterY) , labelString);
    24. p.restore();
    25. }
    26. else if (mId==1)
    27. { brush.setColor(Qt::red);
    28. p.save();
    29. p.setBrush(brush);
    30. p.drawEllipse(QRect(mX-3+mapCenterX, mY-3+mapCenterY,1 6,16));
    31. p.drawLine(mX+mapCenterX, mY+mapCenterY, mX+mapCenterX, mY-10+mapCenterY);
    32. if(mShowLabel)
    33. p.drawText(QPoint(mX+5+mapCenterX, mY+5+mapCenterY), labelString);
    34. p.restore();
    35. }
    36. else if(mId==2)
    37. { brush.setColor(Qt::yellow);
    38. p.save();
    39. p.setBrush(brush);
    40. p.drawEllipse(QRect(mX-3+mapCenterX, mY-3+mapCenterY,6,6));
    41. p.drawLine(mX+mapCenterX, mY+mapCenterY,mX+mapCenterX, mY-25+mapCenterY);
    42. if(mShowLabel)
    43. p.drawText(QPoint(mX+5+mapCenterX,mY+5+mapCenterY),labelString);
    44. p.restore();
    45. }
    46. //updateCanvas();
    47. }
    To copy to clipboard, switch view to plain text mode 

    This is virtual function of a class which is derived from a class inhertiting Q3CanvasItemRectangle.
    Here same warning appears between 2 warnings . except this function i am nowhere using this string

    regards
    quickNitin

  9. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Warning QString::arg() argument missing

    Could you please prepare a minimal compilable example reproducing the problem? It would be much easier for us all to notice the issue.

  10. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Warning QString::arg() argument missing

    Look closely:
    Quote Originally Posted by quickNitin View Post
    labelString=QString("X%1 Y%1").arg(p.x()+mapCenterX).arg(p.y()+mapCenterY) ;
    You have %1 twice, not %1 and %2 as you have shown us earlier.

  11. The following user says thank you to jacek for this useful post:

    quickNitin (17th November 2006)

Similar Threads

  1. problem with linking
    By mickey in forum Qt Programming
    Replies: 49
    Last Post: 12th August 2006, 21:41
  2. how to corss compile for windows in Linux
    By safknw in forum Qt Programming
    Replies: 24
    Last Post: 13th May 2006, 05:23
  3. a Text Editor with line numbers...
    By fullmetalcoder in forum Qt Programming
    Replies: 47
    Last Post: 5th April 2006, 11:10
  4. warning message on compile not understood
    By impeteperry in forum Qt Programming
    Replies: 13
    Last Post: 23rd January 2006, 23:36

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.