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


C++ QFontDatabase::styles方法代码示例

本文整理汇总了C++中QFontDatabase::styles方法的典型用法代码示例。如果您正苦于以下问题:C++ QFontDatabase::styles方法的具体用法?C++ QFontDatabase::styles怎么用?C++ QFontDatabase::styles使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QFontDatabase的用法示例。


在下文中一共展示了QFontDatabase::styles方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main(int argc, char **argv)
{
    QApplication app(argc, argv);

//! [0]
    QFontDatabase database;
    QTreeWidget fontTree;
    fontTree.setColumnCount(2);
    fontTree.setHeaderLabels(QStringList() << "Font" << "Smooth Sizes");

    foreach (const QString &family, database.families()) {
        QTreeWidgetItem *familyItem = new QTreeWidgetItem(&fontTree);
        familyItem->setText(0, family);

        foreach (const QString &style, database.styles(family)) {
            QTreeWidgetItem *styleItem = new QTreeWidgetItem(familyItem);
            styleItem->setText(0, style);

            QString sizes;
            foreach (int points, database.smoothSizes(family, style))
                sizes += QString::number(points) + " ";

            styleItem->setText(1, sizes.trimmed());
        }
//! [0] //! [1]
    }
//! [1]

    fontTree.resizeColumnToContents(0);
    fontTree.show();
    return app.exec();
}
开发者ID:bogdan-voevoda,项目名称:qt4,代码行数:32,代码来源:main.cpp

示例2: setupFontLists

void SettingsDialog::setupFontLists()
{
    QFontDatabase database;
    const QStringList families = database.families();

    console->post(PmChart::DebugUi,
		    "SettingsDialog::setupFontLists: default %s [%d]",
		    PmChart::defaultFontFamily(),
		    PmChart::defaultFontSize());

    QCompleter *completeFamily = new QCompleter(families, familyLineEdit);
    familyLineEdit->setCompleter(completeFamily);

    familyListWidget->insertItems(0, families);
    QString family = globalSettings.fontFamily;
    familyLineEdit->setText(family);
    updateFontList(familyListWidget, family);

    styleListWidget->insertItems(0, database.styles(family));
    QString style = globalSettings.fontStyle;
    styleLineEdit->setText(style);
    updateFontList(styleListWidget, style);

    QStringList sizes;
    foreach (int points, database.smoothSizes(family, style))
	sizes << QString::number(points);
    sizeListWidget->insertItems(0, sizes);
    QString size = QString::number(globalSettings.fontSize);
    sizeLineEdit->setText(size);
    updateFontList(sizeListWidget, size);
}
开发者ID:Aconex,项目名称:pcp,代码行数:31,代码来源:settingsdialog.cpp

示例3: updateFontViaStyle

bool QgsFontUtils::updateFontViaStyle( QFont& f, const QString& fontstyle, bool fallback )
{
  if ( fontstyle.isEmpty() )
  {
    return false;
  }

  QFontDatabase fontDB;

  if ( !fallback )
  {
    // does the font even have the requested style?
    bool hasstyle = false;
    foreach ( const QString &style, fontDB.styles( f.family() ) )
    {
      if ( style == fontstyle )
      {
        hasstyle = true;
        break;
      }
    }

    if ( !hasstyle )
    {
      return false;
    }
  }
开发者ID:Adam-Brown,项目名称:Quantum-GIS,代码行数:27,代码来源:qgsfontutils.cpp

示例4: italicOblique

void tst_QFont::italicOblique()
{
    QFontDatabase fdb;

    QStringList families = fdb.families();
    if (families.isEmpty())
        return;

    QStringList::ConstIterator f_it, f_end = families.end();
    for (f_it = families.begin(); f_it != f_end; ++f_it) {

	QString family = *f_it;
	QStringList styles = fdb.styles(family);
	QVERIFY(!styles.isEmpty());
	QStringList::ConstIterator s_it, s_end = styles.end();
	for (s_it = styles.begin(); s_it != s_end; ++s_it) {
	    QString style = *s_it;

	    if (fdb.isSmoothlyScalable(family, style)) {
		if (style.contains("Oblique")) {
		    style.replace("Oblique", "Italic");
		} else if (style.contains("Italic")) {
		    style.replace("Italic", "Oblique");
		} else {
		    continue;
		}
		QFont f = fdb.font(family, style, 12);
		QVERIFY(f.italic());
	    }
	}
    }
}
开发者ID:SfietKonstantin,项目名称:radeon-qt5-qtbase-kms,代码行数:32,代码来源:tst_qfont.cpp

示例5: loadStyles

void BtFontChooserWidget::loadStyles(const QString& font) {
    m_styleListWidget->clear();
    QFontDatabase database;
    Q_FOREACH (const QString &style, database.styles(font)) {
        m_styleListWidget->addItem(style);
        // This triggers loading the sizes for the first style
        restoreListWidgetValue(m_styleListWidget, m_choosenStyle);
    }
}
开发者ID:greg-hellings,项目名称:bibletime,代码行数:9,代码来源:btfontchooserwidget.cpp

示例6: familySelected

void MainWindow::familySelected(const QString &family)
{
    QFontDatabase db;
    QStringList styles = db.styles(family);
    ui->fontStyleCombo->clear();
    ui->fontStyleCombo->addItems(styles);
    ui->familySubstitutionCombo->addItem(family);
    buildFont();
}
开发者ID:venkatarajasekhar,项目名称:Qt,代码行数:9,代码来源:mainwindow.cpp

示例7: printFontList

void printFontList()
{
	QFontDatabase db;
    foreach (const QString &family, db.families()) {
		qStdOut() << family << "\n";
        foreach (const QString &style, db.styles(family)) {
			qStdOut() << "\t" << style << "\n";
		}
	}
}
开发者ID:lambdalisue,项目名称:neovim-qt,代码行数:10,代码来源:fontinfo.cpp

示例8:

void
CQFontChooser::
updateStyles()
{
  QFontDatabase database;

  const QString &family = ncombo_->itemText(ncombo_->currentIndex());

  scombo_->clear();
  scombo_->addItems(database.styles(family));
}
开发者ID:colinw7,项目名称:CQUtil,代码行数:11,代码来源:CQFontChooser.cpp

示例9: fontFamilyHasStyle

bool QgsFontUtils::fontFamilyHasStyle( const QString& family, const QString& style )
{
  QFontDatabase fontDB;
  if ( !fontFamilyOnSystem( family ) )
    return false;

  if ( fontDB.styles( family ).contains( style ) )
    return true;

#ifdef Q_OS_WIN
  QString modified( style );
  if ( style == "Roman" )
    modified = "Normal";
  if ( style == "Oblique" )
    modified = "Italic";
  if ( style == "Bold Oblique" )
    modified = "Bold Italic";
  if ( fontDB.styles( family ).contains( modified ) )
    return true;
#endif

  return false;
}
开发者ID:landryb,项目名称:QGIS,代码行数:23,代码来源:qgsfontutils.cpp

示例10: metrics

void tst_QFontMetrics::metrics()
{
    QFont font;
    QFontDatabase fdb;

    // Query the QFontDatabase for a specific font, store the
    // result in family, style and size.
    QStringList families = fdb.families();
    if (families.isEmpty())
        return;

    QStringList::ConstIterator f_it, f_end = families.end();
    for (f_it = families.begin(); f_it != f_end; ++f_it) {
        const QString &family = *f_it;

        QStringList styles = fdb.styles(family);
        QStringList::ConstIterator s_it, s_end = styles.end();
        for (s_it = styles.begin(); s_it != s_end; ++s_it) {
            const QString &style = *s_it;

            if (fdb.isSmoothlyScalable(family, style)) {
                // smoothly scalable font... don't need to load every pointsize
                font = fdb.font(family, style, 12);

                QFontMetrics fontmetrics(font);
                QCOMPARE(fontmetrics.ascent() + fontmetrics.descent(),
                        fontmetrics.height());

                QCOMPARE(fontmetrics.height() + fontmetrics.leading(),
                        fontmetrics.lineSpacing());
            } else {
                QList<int> sizes = fdb.pointSizes(family, style);
                QVERIFY(!sizes.isEmpty());
                QList<int>::ConstIterator z_it, z_end = sizes.end();
                for (z_it = sizes.begin(); z_it != z_end; ++z_it) {
                    const int size = *z_it;

                    // Initialize the font, and check if it is an exact match
                    font = fdb.font(family, style, size);

                    QFontMetrics fontmetrics(font);
                    QCOMPARE(fontmetrics.ascent() + fontmetrics.descent(),
                            fontmetrics.height());
                    QCOMPARE(fontmetrics.height() + fontmetrics.leading(),
                            fontmetrics.lineSpacing());
                }
            }
        }
    }
}
开发者ID:MarianMMX,项目名称:MarianMMX,代码行数:50,代码来源:tst_qfontmetrics.cpp

示例11: styles

void tst_QFontDatabase::styles()
{
    QFETCH( QString, font );

    QFontDatabase fdb;
    QStringList styles = fdb.styles( font );
    QStringList::Iterator it = styles.begin();
    while ( it != styles.end() ) {
	QString style = *it;
	QString trimmed = style.trimmed();
	++it;

	QCOMPARE( style, trimmed );
    }
}
开发者ID:PNIDigitalMedia,项目名称:emscripten-qt,代码行数:15,代码来源:tst_qfontdatabase.cpp

示例12:

QList<int> FontSettingsPage::pointSizesForSelectedFont() const
{
    QFontDatabase db;
    const QString familyName = d_ptr->m_ui->fontComboBox->currentFont().family();
    QList<int> sizeLst = db.pointSizes(familyName);
    if (!sizeLst.isEmpty())
        return sizeLst;

    QStringList styles = db.styles(familyName);
    if (!styles.isEmpty())
        sizeLst = db.pointSizes(familyName, styles.first());
    if (sizeLst.isEmpty())
        sizeLst = QFontDatabase::standardSizes();

    return sizeLst;
}
开发者ID:kai66673,项目名称:qt-creator,代码行数:16,代码来源:fontsettingspage.cpp

示例13: loadFontInfo

void DFontChooser::loadFontInfo(const QString &family)
{
	QString currentSize = m_fontSize->currentText();
	QString currentStyle = m_fontStyle->currentText();
	
	QFontDatabase fdb;
	
	m_fontStyle->clear();
	m_fontStyle->addItems(fdb.styles(family));
	
	
	m_fontSize->clear();
	
	QList<int> points = fdb.pointSizes(family);
	
	foreach(int point, points)
	{
		m_fontSize->addItem(QString::number(point));
	}
开发者ID:BackupTheBerlios,项目名称:adresis-svn,代码行数:19,代码来源:dfontchooser.cpp

示例14: FontBrowserInterface

FontBrowserServer::FontBrowserServer(ProbeInterface *probe, QObject *parent)
  : FontBrowserInterface(parent)
  , m_selectedFontModel(new FontModel(this))
{
  QStandardItemModel *model = new QStandardItemModel(this);
  model->setHorizontalHeaderLabels(QStringList() << tr("Fonts") << tr("Smooth sizes"));
  QFontDatabase database;
  foreach (const QString &family, database.families()) {
    QStandardItem *familyItem = new QStandardItem;
    familyItem->setText(family);
    familyItem->setEditable(false);
    familyItem->setData(QFont(family));

    foreach (const QString &style, database.styles(family)) {
      QStandardItem *styleItem0 = new QStandardItem;
      styleItem0->setText(style);
      styleItem0->setEditable(false);
      styleItem0->setData(database.font(family, style, 10));

      QString sizes;
      foreach (int points, database.smoothSizes(family, style)) {
        sizes += QString::number(points) + ' ';
      }

      QStandardItem *styleItem1 = new QStandardItem;
      styleItem1->setText(sizes.trimmed());
      styleItem1->setEditable(false);
      styleItem1->setToolTip(sizes.trimmed());

      familyItem->appendRow(QList<QStandardItem*>() << styleItem0 << styleItem1);
    }

    model->appendRow(familyItem);
  }

  probe->registerModel("com.kdab.GammaRay.FontModel", model);
  m_fontSelectionModel = ObjectBroker::selectionModel(model);
  connect(m_fontSelectionModel, SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
          SLOT(updateFonts()));
  probe->registerModel("com.kdab.GammaRay.SelectedFontModel", m_selectedFontModel);
}
开发者ID:02JanDal,项目名称:GammaRay,代码行数:41,代码来源:fontbrowserserver.cpp

示例15: testBruteForce

void FontsTest::testBruteForce()
{
    QFontDatabase fdb;
    QStringList allfamilies = fdb.families();
    foreach(const QString& family, allfamilies) {
        QStringList styles = fdb.styles(family);
        foreach(const QString& style, styles) {
            QFont f(family);
            f.setStyleName(style);

            QString str = fontToString(f);
            QFont f2 = stringToFont(str);
            QCOMPARE(f2.styleName(), style);
            if(str != fontToString(f2)) {
                qDebug() << "faulty font:" << str << f << f2;
            }
            QCOMPARE(fontToString(f2), str);
            if(f != f2) {
                qDebug() << "faulty font:" << f << f2;
            }
//             QCOMPARE(f, f2);
        }
开发者ID:KDE,项目名称:kde-gtk-config,代码行数:22,代码来源:fontstest.cpp


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