[Qt-interest] Formatting strings using arg() and system's locale

Marcelo Magno T. Sales mmtsales at gmail.com
Mon Oct 25 14:15:45 CEST 2010


Hello,

I'm trying to format strings which represent numeric values using the 
arg() method. I want the strings to be formatted according to system's 
locale.
The documentation of arg() says:
"The conversion uses the default locale, set by 
QLocale::setDefaultLocale(). If no default locale was specified, the "C" 
locale is used."

However, there is no QLocale::setDefaultLocale().
There is QLocale::setDefault(), but executing 
QLocale::setDefault(QLocale::system()) does not seem to produce any 
effect on QString::arg(). I still get strings formatted according to c 
locale, which is the default for arg().
I can get strings formatted the way I want, however, if I declare a 
QLocale object and use its toString() method.

What am I missing here?

Thanks,

Marcelo



More information about the Qt-interest-old mailing list