Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qfontdatabase_snippets.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3
4#include <QtWidgets>
5
7void wrapper()
8{
10QTreeWidget fontTree;
11fontTree.setColumnCount(2);
12fontTree.setHeaderLabels(QStringList() << "Font" << "Smooth Sizes");
13
14const QStringList fontFamilies = QFontDatabase::families();
15for (const QString &family : fontFamilies) {
16 QTreeWidgetItem *familyItem = new QTreeWidgetItem(&fontTree);
17 familyItem->setText(0, family);
18
19 const QStringList fontStyles = QFontDatabase::styles(family);
20 for (const QString &style : fontStyles) {
21 QTreeWidgetItem *styleItem = new QTreeWidgetItem(familyItem);
22 styleItem->setText(0, style);
23
25 const QList<int> smoothSizes = QFontDatabase::smoothSizes(family, style);
26 for (const auto &points : smoothSizes)
28
29 styleItem->setText(1, sizes.trimmed());
30 }
31}
33} // wrapper
34} // qfontdatabase_snippets
static QStringList families(WritingSystem writingSystem=Any)
Returns a sorted list of the available font families which support the writingSystem.
static QList< int > smoothSizes(const QString &family, const QString &style)
Returns the point sizes of a font that has family family and style styleName that will look attractiv...
static QStringList styles(const QString &family)
Returns a list of the styles available for the font family family.
\inmodule QtCore
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qstring.cpp:8084
The QTreeWidgetItem class provides an item for use with the QTreeWidget convenience class.
Definition qtreewidget.h:23
The QTreeWidget class provides a tree view that uses a predefined tree model.
void setColumnCount(int columns)
QList< QString > QStringList
Constructs a string list that contains the given string, str.
GLfixed GLfixed GLint GLint GLfixed points
GLuint GLsizei const GLuint const GLintptr const GLsizeiptr * sizes