[Interest] QVariant toString locale
Etienne Sandré-Chardonnal
etienne.sandre at m4x.org
Wed Oct 17 16:10:04 CEST 2018
Dear all,
I have a big table made of QVariants of many subtypes (dates, floats,
integers, etc...)
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
to avoid...
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?
Best regards,
Etienne
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20181017/2f676f9e/attachment.html>
More information about the Interest
mailing list