[Qt-interest] Problem with QString.arg()
Scott Aron Bloom
Scott.Bloom at sabgroup.com
Wed Apr 8 18:15:41 CEST 2009
Oops.. typo
QChar( '0' )
From: qt-interest-bounces at trolltech.com
[mailto:qt-interest-bounces at trolltech.com] On Behalf Of Scott Aron Bloom
Sent: Wednesday, April 08, 2009 8:36 AM
To: Allen, Matthew; qt-interest at trolltech.com
Subject: Re: [Qt-interest] Problem with QString.arg()
The problem is the QChar...
Try this...
.arg( i, 2, 10, QChar( '10' )
Scott
From: qt-interest-bounces at trolltech.com
[mailto:qt-interest-bounces at trolltech.com] On Behalf Of Allen, Matthew
Sent: Wednesday, April 08, 2009 8:29 AM
To: qt-interest at trolltech.com
Subject: [Qt-interest] Problem with QString.arg()
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090408/899d727d/attachment.html
More information about the Qt-interest-old
mailing list