[PySide] Strange behaviour of QLocale.toString()

Tim Doty thoromyr at mac.com
Sun Apr 14 19:32:17 CEST 2013


For the PySide what is really happening is not a rounding error/precision as suggested, but printing an integer with floating point notation. When the floating point is converted to an integer it is rounded. To satisfy yourself that this is in fact happening change the number to be printed (e.g., 9999999.5 vs 9999999.4).

I'm not really conversant with PySide, but from http://srinikom.github.io/pyside-docs/PySide/QtCore/QLocale.html it appears that there is no floating point version of the toString() function, just integer, date, and dateTime. As Qt has a variety of floating point overloads for that function (https://qt-project.org/doc/qt-4.8/qlocale.html#toString) it would look to me like a bug/oversight on the part of the PySide implementation.

Tim Doty

On Apr 14, 2013, at 5:03 AM, Alexey Vihorev <vihorev at gmail.com> wrote:

> Hi!
> 1.  from PySide.QtCore import QLocale as PySideLocale #PySide 1.1.2 on Win32
> 2.  from PyQt4.QtCore import QLocale as PyQtLocale
> 3.   
> 4.  print(PySideLocale().toString(9999999.99, 'f', 2)) #prints '10 000 000,00'
> 5.  print(PyQtLocale().toString(9999999.99, 'f', 2)) #prints '9 999 999,99'
> I guess it’s a bug, right?
>  
> _______________________________________________
> PySide mailing list
> PySide at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/pyside




More information about the PySide mailing list