[Interest] QVariant toString locale
etienne.sandre at m4x.org
Wed Oct 17 16:10:04 CEST 2018
I have a big table made of QVariants of many subtypes (dates, floats,
I need to output it in csv format with a user defined locale.
It seems, after searching the documentation for all possible ways:
1) QTextStream can be set a locale, but it does not accepts QVariant
2) QVariant has a toString method, but no custom locale can be used. The
documentation says nothing about the locale it uses, probably
QLocale::system() or QApplication::locale but maybe not.
So, I have to either:
1) Handle all possible QVariant subtypes in a big switch block, I'd like
2) Figure out if QVariant uses QApplication::locale(); change this locale,
do all the conversion, and restore QApplication::locale(), but this could
cause GUI flickers (as the GUI uses the app locale for display) and I would
rely on an undocumented assumption...
So as you see, it seems there is a hole in Qt's otherwise excellent
handling of locales. Am I wrong? Is there a good solution?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Interest