本文整理汇总了C++中QLocale::nativeCountryName方法的典型用法代码示例。如果您正苦于以下问题:C++ QLocale::nativeCountryName方法的具体用法?C++ QLocale::nativeCountryName怎么用?C++ QLocale::nativeCountryName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QLocale
的用法示例。
在下文中一共展示了QLocale::nativeCountryName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: localeChanged
void InfoWidget::localeChanged(QLocale locale)
{
setLocale(locale);
name->setText(locale.name());
bcp47Name->setText(locale.bcp47Name());
languageName->setText(QLocale::languageToString(locale.language()));
nativeLanguageName->setText(locale.nativeLanguageName());
scriptName->setText(QLocale::scriptToString(locale.script()));
countryName->setText(QLocale::countryToString(locale.country()));
nativeCountryName->setText(locale.nativeCountryName());
}
示例2: rebuildDictsModel
void KnownDictsManager::rebuildDictsModel ()
{
auto candidates = GetSystemPaths ();
candidates.prepend (LocalPath_);
Lang2Path_.clear ();
for (const auto& dir : candidates)
{
if (!QFile::exists (dir))
continue;
for (auto file : QDir (dir).entryList ({ "*.dic" }))
{
if (file.startsWith ("hyph_"))
continue;
file.chop (4);
if (Lang2Path_.contains (file))
continue;
Lang2Path_ [file] = dir;
}
}
Model_->clear ();
Model_->setHorizontalHeaderLabels ({ tr ("Locale"), tr ("Language"), tr ("Country") });
for (auto i = Lang2Path_.begin (); i != Lang2Path_.end (); ++i)
{
auto item = new QStandardItem (i.key ());
item->setCheckable (true);
item->setCheckState (Languages_.contains (i.key ()) ? Qt::Checked : Qt::Unchecked);
const QLocale loc (i.key ());
QList<QStandardItem*> row { item };
row << new QStandardItem (loc.nativeLanguageName ());
row << new QStandardItem (loc.nativeCountryName ());
for (auto item : row)
item->setEditable (false);
Model_->appendRow (row);
}
}
示例3: chosenLanguages
AcceptLanguageDialog::AcceptLanguageDialog(const QString &languages, QWidget *parent) : Dialog(parent),
m_ui(new Ui::AcceptLanguageDialog)
{
m_ui->setupUi(this);
m_model = new QStandardItemModel(this);
m_model->setHorizontalHeaderLabels(QStringList({tr("Name"), tr("Code")}));
m_ui->languagesViewWidget->setModel(m_model);
QStringList chosenLanguages(languages.split(QLatin1Char(','), QString::SkipEmptyParts));
for (int i = 0; i < chosenLanguages.count(); ++i)
{
addLanguage(chosenLanguages.at(i).section(QLatin1Char(';'), 0, 0));
}
const QList<QLocale> locales(QLocale::matchingLocales(QLocale::AnyLanguage, QLocale::AnyScript, QLocale::AnyCountry));
QVector<QPair<QString, QString> > entries;
for (int i = 0; i < locales.count(); ++i)
{
const QLocale locale(locales.at(i));
if (locale != QLocale::c())
{
if (locale.nativeCountryName().isEmpty() || locale.nativeLanguageName().isEmpty())
{
entries.append({tr("Unknown [%1]").arg(locale.bcp47Name()), locale.bcp47Name()});
}
else
{
entries.append({QStringLiteral("%1 - %2 [%3]").arg(locale.nativeLanguageName()).arg(locale.nativeCountryName()).arg(locale.bcp47Name()), locale.bcp47Name()});
}
}
}
QCollator collator;
collator.setCaseSensitivity(Qt::CaseInsensitive);
qSort(entries.begin(), entries.end(), [&](const QPair<QString, QString> &first, const QPair<QString, QString> &second)
{
return (collator.compare(first.first, second.first) < 0);
});
entries.prepend(QPair<QString, QString>(tr("Any other"), QLatin1String("*")));
entries.prepend(QPair<QString, QString>(tr("System language (%1 - %2)").arg(QLocale::system().nativeLanguageName()).arg(QLocale::system().nativeCountryName()), QString("system")));
for (int i = 0; i < entries.count(); ++i)
{
m_ui->languagesComboBox->addItem(entries.at(i).first, entries.at(i).second);
}
m_ui->moveDownButton->setIcon(ThemesManager::createIcon(QLatin1String("arrow-down")));
m_ui->moveUpButton->setIcon(ThemesManager::createIcon(QLatin1String("arrow-up")));
m_ui->languagesComboBox->installEventFilter(this);
connect(m_ui->moveDownButton, &QToolButton::clicked, m_ui->languagesViewWidget, &ItemViewWidget::moveDownRow);
connect(m_ui->moveUpButton, &QToolButton::clicked, m_ui->languagesViewWidget, &ItemViewWidget::moveUpRow);
connect(m_ui->removeButton, &QToolButton::clicked, m_ui->languagesViewWidget, &ItemViewWidget::removeRow);
connect(m_ui->addButton, &QToolButton::clicked, this, &AcceptLanguageDialog::addNewLanguage);
connect(m_ui->languagesViewWidget, &ItemViewWidget::canMoveDownChanged, m_ui->moveDownButton, &QToolButton::setEnabled);
connect(m_ui->languagesViewWidget, &ItemViewWidget::canMoveUpChanged, m_ui->moveUpButton, &QToolButton::setEnabled);
connect(m_ui->languagesViewWidget, &ItemViewWidget::needsActionsUpdate, this, &AcceptLanguageDialog::updateActions);
}