当前位置: 首页>>代码示例>>C++>>正文


C++ QLocale::nativeCountryName方法代码示例

本文整理汇总了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());
}
开发者ID:OniLink,项目名称:Qt5-Rehost,代码行数:11,代码来源:info.cpp

示例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);
		}
	}
开发者ID:ForNeVeR,项目名称:leechcraft,代码行数:45,代码来源:knowndictsmanager.cpp

示例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);
}
开发者ID:,项目名称:,代码行数:65,代码来源:


注:本文中的QLocale::nativeCountryName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。