PDA

View Full Version : Override locale with QSystemLocale



sedi
4th February 2013, 01:02
Hi,

I need QString::localeAwareCompare to properly sort German names.
This works on my desktop.

Unfortunately my tablet seems to provide a wrong system locale.

I've tried

mainWin.setLocale(QLocale(QLocale::German,QLocale: :Germany));
as well as

QLocale::setDefault(QLocale(QLocale::German,QLocal e::Germany));
but "Z" is still less than "Ö" (When "Ö" shoud be between "O" and "P").

I've looked into QSystemLocale, but there are no setter methods (and the documentation
is vague, actually saying " only useful in very rare cases."), so I don't understand how I
can use this. I didn't find anything particularly helpful about this on web research or in this Forum.

Is there any way to override the system locale and force Qt into using
a specific locale?

How do I use QSystemLocale (if at all) to force Qt into German sorting?

sedi
9th February 2013, 22:15
Nobody with an idea or a pointer to some documentation?

frost_asm
23rd April 2013, 11:04
This code work for me.


#include <QSystemLocale>

class MySystemLocale : QSystemLocale
{

public: MySystemLocale() { }

QVariant query(QueryType type, QVariant in) const
{
if (type==QSystemLocale::DecimalPoint) {
return ".";
}
return QSystemLocale::query(type, in);
}

};

int main(int argc, char *argv[])
{
MySystemLocale appSystemLocale; // work fine
QApplication a(argc, argv);
// MySystemLocale appSystemLocale;// not work

return a.exec();
}