[Qt-interest] Problem with QString.arg()

Ian Thomson Ian.Thomson at iongeo.com
Wed Apr 8 17:36:08 CEST 2009


Hi,

Have you tried initializing the character as QChar('0') instead of just 
'0'? That might help the compiler understand which function to use.

Cheers,
Ian.

Allen, Matthew wrote:
> I’m getting this error from the compiler:
> 
>  
> 
> pdf_viewer.cpp:697: error: ISO C++ says that these are ambiguous, even 
> though the worst conversion for the first is better than the worst 
> conversion for the second:
> 
> /usr/include/QtCore/qstring.h:129: note: candidate 1: QString 
> QString::arg(double, int, char, int, const QChar&) const
> 
> /usr/include/QtCore/qstring.h:625: note: candidate 2: QString 
> QString::arg(int, int, int, const QChar&) const
> 
>  
> 
> The line it is bitching about is:
> 
>  
> 
> tmpString.append(QString("%1").arg((int)i, 2, 10, '0') + "|");
> 
>  
> 
> Yes, I just realized that I can put the “|” inside the QString argument 
> but I’m trying to find out what is wrong with the line itself. i is an 
> int and is a counter in a for loop.
> 
>  
> 
> Basically, I’m trying to take an int and pad it to 2 digits and zero 
> filled. I’ll use sprintf if I have to but I’d rather not.
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest




More information about the Qt-interest-old mailing list