Etienne Sandré-Chardonnal
2018-10-17 14:10:04 UTC
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
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