本文整理汇总了C++中QLocale::countryToString方法的典型用法代码示例。如果您正苦于以下问题:C++ QLocale::countryToString方法的具体用法?C++ QLocale::countryToString怎么用?C++ QLocale::countryToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QLocale
的用法示例。
在下文中一共展示了QLocale::countryToString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QDialog
AcceptLanguage::AcceptLanguage(QWidget* parent)
: QDialog(parent)
, ui(new Ui::AcceptLanguage)
{
ui->setupUi(this);
ui->listWidget->setLayoutDirection(Qt::LeftToRight);
Settings settings;
settings.beginGroup("Language");
QStringList langs = settings.value("acceptLanguage", defaultLanguage()).toStringList();
settings.endGroup();
foreach (const QString &code, langs) {
QString code_ = code;
QLocale loc = QLocale(code_.replace(QLatin1Char('-'), QLatin1Char('_')));
QString label;
if (loc.language() == QLocale::C) {
label = tr("Personal [%1]").arg(code);
}
else {
label = QString("%1/%2 [%3]").arg(loc.languageToString(loc.language()), loc.countryToString(loc.country()), code);
}
ui->listWidget->addItem(label);
}
示例2: main
int main(int argc, char *argv[]) {
QDir dir(QDir::homePath());
dir.mkdir(Configuration::CacheDirectory);
qInstallMsgHandler(handleMessage);
QApplication app(argc, argv);
QLocale systemLocale = QLocale::system();
Services::initialize();
Configuration *config = Configuration::getInstance();
config->load();
QTranslator translator;
translator.load(QString(":/translations/qwit_") + (config->language == "system" ? systemLocale.name() : config->language));
app.installTranslator(&translator);
Configuration::TranslationsCodes.push_back("system");
Configuration::TranslationsCountries.push_back(systemLocale.name().mid(3, 2));
Configuration::TranslationsTitles.push_back(app.tr("System (%1, %2)").arg(systemLocale.languageToString(systemLocale.language())).arg(systemLocale.countryToString(systemLocale.country())));
QDir translationsDir(":/translations");
QStringList translationNames = translationsDir.entryList(QStringList("*.qm"), QDir::Files, QDir::Name);
QMutableStringListIterator i(translationNames);
while (i.hasNext()) {
i.next();
QString languageCode = i.value().mid(5, 5);
QLocale locale(languageCode);
Configuration::TranslationsCodes.push_back(languageCode);
Configuration::TranslationsCountries.push_back(languageCode.mid(3, 2));
Configuration::TranslationsTitles.push_back(QString("%1, %2").arg(systemLocale.languageToString(locale.language())).arg(systemLocale.countryToString(locale.country())));
}
MainWindow *mainWindow = MainWindow::getInstance();
if (!config->startMinimized) mainWindow->show();
return app.exec();
}