Warning QString::arg() argument missing
greetings,
in the following code i am intializing a QString object
Code:
...
labelString.clear();
labelString
=QString("X%1 Y%2").
arg(p.
x()).
arg(p.
y());
//getting warning for this line..
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
Re: Warning QString::arg() argument missing
I don't see anything wrong with that particular line. Are you 100% sure it's that line? :)
Re: Warning QString::arg() argument missing
yes, i am.
I have tried to make diferent string. Like
Code:
labelString
=QString("X%1f Y%2y).arg(p.x()).arg(p.y());
This results in 'f' succesiding numbers.
Re: Warning QString::arg() argument missing
So what's wrong with it? What would you like to get?
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.
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?
Re: Warning QString::arg() argument missing
Maybe you use that labelString in arg() in some other place?
Re: Warning QString::arg() argument missing
here is part of code generated this warning.
Code:
{ //std::cout<<"|"<<mX<<" "<<mY;
//preparing label to be displayed
if(mLabelIndex==0) {
labelString.clear();
labelString.setNum(mNo);
}
else if(mLabelIndex==1) {
QgsPoint p
=toMapCoords
(QPoint(mX,mY
));
qWarning("Hello");
labelString
=QString("X%1 Y%1").
arg(p.
x()+mapCenterX
).
arg(p.
y()+mapCenterY
);
qWarning("Bye");
}
if(mId==0) /
{ p.save();
p.setBrush(brush);
p.
drawEllipse(QRect(mX
-3+mapCenterX,mY
-3+mapCenterY,
16,
16));
p.drawLine(mX+mapCenterX, mY+mapCenterY, mX+mapCenterX, mY-10+mapCenterY);
if(mShowLabel)
p.
drawText(QPoint(mX
+5+mapCenterX, mY
+5+mapCenterY
) , labelString
);
p.restore();
}
else if (mId==1)
{ brush.setColor(Qt::red);
p.save();
p.setBrush(brush);
p.
drawEllipse(QRect(mX
-3+mapCenterX, mY
-3+mapCenterY,
1 6,
16));
p.drawLine(mX+mapCenterX, mY+mapCenterY, mX+mapCenterX, mY-10+mapCenterY);
if(mShowLabel)
p.
drawText(QPoint(mX
+5+mapCenterX, mY
+5+mapCenterY
), labelString
);
p.restore();
}
else if(mId==2)
{ brush.setColor(Qt::yellow);
p.save();
p.setBrush(brush);
p.
drawEllipse(QRect(mX
-3+mapCenterX, mY
-3+mapCenterY,
6,
6));
p.drawLine(mX+mapCenterX, mY+mapCenterY,mX+mapCenterX, mY-25+mapCenterY);
if(mShowLabel)
p.
drawText(QPoint(mX
+5+mapCenterX,mY
+5+mapCenterY
),labelString
);
p.restore();
}
//updateCanvas();
}
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
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.
Re: Warning QString::arg() argument missing
Look closely:
Quote:
Originally Posted by
quickNitin
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.