不多说了,QLocale的用法很强大,这里使用了加载所有语言的方法。
int currentlangIndex = -1;
int index = 0;
for (int _lang = QLocale::C;_lang < QLocale::LastLanguage;++_lang)
{
QLocale::Language lang = static_cast<QLocale::Language>(_lang);
QList<QLocale::Country> lstCountry = QLocale::countriesForLanguage(lang);
foreach(QLocale::Country country,lstCountry)
{
QString label = QLocale::countryToString(country)
+QLatin1Char('/')
+QLocale::languageToString(lang);
QLocale locale(lang,country);
if (this->locale().language() == lang && this->locale().country() == country)
{
currentlangIndex = index;
}
d_ptr->m_comboLocal->addItem(label,locale);
index++;
}
}