They both work here (Qt 4.7.4):
#include <QtCore>
#include <QDebug>
int main(int argc, char **argv)
{
int dataAsInt = 10234;
QString dataDescription
= QString("%L1").
arg(dataAsInt
);
// doesn't work qDebug() << dataDescription; // outputs "10,234"
dataDescription = aEnglish.toString(dataAsInt); // doesn't work
qDebug() << dataDescription; // outputs "10,234"
return 0;
}
#include <QtCore>
#include <QDebug>
int main(int argc, char **argv)
{
QCoreApplication app(argc, argv);
int dataAsInt = 10234;
QString dataDescription = QString("%L1").arg(dataAsInt); // doesn't work
qDebug() << dataDescription; // outputs "10,234"
QLocale::setDefault(QLocale(QLocale::English, QLocale::UnitedStates));
QLocale aEnglish;
dataDescription = aEnglish.toString(dataAsInt); // doesn't work
qDebug() << dataDescription; // outputs "10,234"
return 0;
}
To copy to clipboard, switch view to plain text mode
My default locale is Australia, English with group separator ','.
So, the question is, "How doesn't it work for you?"
Edit: D'oh! I should have looked harder at the preview before posting
Bookmarks