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

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


Sorry for the noise, I've found the problem. I had to use "%L1" instead 
of "%1" when formatting the string with QString::arg(). The only error 
in the documentation is the name of QLocale's method to set the default 
location, which is setDefault() and not setDefaultLocale().

[]'s
Marcelo


Em segunda-feira 25 outubro 2010, Marcelo Magno T. Sales escreveu:
> 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
> _______________________________________________
> 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