Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
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
6
namespace
qfontdatabase_snippets
{
7
void
wrapper
()
8
{
9
//! [0]
10
QTreeWidget fontTree;
11
fontTree.setColumnCount(2);
12
fontTree.setHeaderLabels(QStringList() <<
"Font"
<<
"Smooth Sizes"
);
13
14
const
QStringList fontFamilies = QFontDatabase::families();
15
for
(
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
24
QString sizes;
25
const
QList<
int
> smoothSizes = QFontDatabase::smoothSizes(family, style);
26
for
(
const
auto
&points : smoothSizes)
27
sizes += QString::number(points) +
' '
;
28
29
styleItem->setText(1, sizes.trimmed());
30
}
31
}
32
//! [0]
33
}
// wrapper
34
}
// qfontdatabase_snippets
qfontdatabase_snippets
Definition
qfontdatabase_snippets.cpp:6
qfontdatabase_snippets::wrapper
void wrapper()
Definition
qfontdatabase_snippets.cpp:7
qtbase
src
gui
doc
snippets
qfontdatabase
qfontdatabase_snippets.cpp
Generated on
for Qt by
1.18.0