summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gui/doc/snippets/qfontdatabase/qfontdatabase_snippets.cpp (renamed from src/gui/doc/snippets/qfontdatabase/main.cpp)49
-rw-r--r--src/gui/doc/snippets/qfontdatabase/qfontdatabase_snippets.pro5
-rw-r--r--src/gui/doc/snippets/snippets.pro4
-rw-r--r--src/gui/text/qfontdatabase.cpp3
4 files changed, 31 insertions, 30 deletions
diff --git a/src/gui/doc/snippets/qfontdatabase/main.cpp b/src/gui/doc/snippets/qfontdatabase/qfontdatabase_snippets.cpp
index 5a5aa7b485..3200ac94b1 100644
--- a/src/gui/doc/snippets/qfontdatabase/main.cpp
+++ b/src/gui/doc/snippets/qfontdatabase/qfontdatabase_snippets.cpp
@@ -50,38 +50,33 @@
#include <QtWidgets>
-int main(int argc, char **argv)
+namespace qfontdatabase_snippets {
+void wrapper()
{
- QApplication app(argc, argv);
-
//! [0]
- QFontDatabase database;
- QTreeWidget fontTree;
- fontTree.setColumnCount(2);
- fontTree.setHeaderLabels(QStringList() << "Font" << "Smooth Sizes");
+QFontDatabase database;
+QTreeWidget fontTree;
+fontTree.setColumnCount(2);
+fontTree.setHeaderLabels(QStringList() << "Font" << "Smooth Sizes");
- const QStringList fontFamilies = database.families();
- for (const QString &family : fontFamilies) {
- QTreeWidgetItem *familyItem = new QTreeWidgetItem(&fontTree);
- familyItem->setText(0, family);
+const QStringList fontFamilies = database.families();
+for (const QString &family : fontFamilies) {
+ QTreeWidgetItem *familyItem = new QTreeWidgetItem(&fontTree);
+ familyItem->setText(0, family);
- const QStringList fontStyles = database.styles(family);
- for (const QString &style : fontStyles) {
- QTreeWidgetItem *styleItem = new QTreeWidgetItem(familyItem);
- styleItem->setText(0, style);
+ const QStringList fontStyles = database.styles(family);
+ for (const QString &style : fontStyles) {
+ QTreeWidgetItem *styleItem = new QTreeWidgetItem(familyItem);
+ styleItem->setText(0, style);
- QString sizes;
- const QList<int> smoothSizes = database.smoothSizes(family, style)
- for (int points : smoothSizes)
- sizes += QString::number(points) + ' ';
+ QString sizes;
+ const QList<int> smoothSizes = database.smoothSizes(family, style);
+ for (const auto &points : smoothSizes)
+ sizes += QString::number(points) + ' ';
- styleItem->setText(1, sizes.trimmed());
- }
-//! [0] //! [1]
+ styleItem->setText(1, sizes.trimmed());
}
-//! [1]
-
- fontTree.resizeColumnToContents(0);
- fontTree.show();
- return app.exec();
}
+//! [0]
+} // wrapper
+} // qfontdatabase_snippets
diff --git a/src/gui/doc/snippets/qfontdatabase/qfontdatabase_snippets.pro b/src/gui/doc/snippets/qfontdatabase/qfontdatabase_snippets.pro
new file mode 100644
index 0000000000..5c7e455360
--- /dev/null
+++ b/src/gui/doc/snippets/qfontdatabase/qfontdatabase_snippets.pro
@@ -0,0 +1,5 @@
+TEMPLATE = lib
+TARGET = qfontdatabase_snippets
+QT += core gui widgets
+
+SOURCES = qfontdatabase_snippets.cpp
diff --git a/src/gui/doc/snippets/snippets.pro b/src/gui/doc/snippets/snippets.pro
index f9d818e83e..6ad2d78387 100644
--- a/src/gui/doc/snippets/snippets.pro
+++ b/src/gui/doc/snippets/snippets.pro
@@ -2,5 +2,7 @@ TEMPLATE = subdirs
SUBDIRS =
contains(QT_BUILD_PARTS, tests) {
- SUBDIRS +=
+ SUBDIRS += \
+ qfontdatabase
}
+
diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp
index 1afaedaa09..43f7f5b35a 100644
--- a/src/gui/text/qfontdatabase.cpp
+++ b/src/gui/text/qfontdatabase.cpp
@@ -1237,8 +1237,7 @@ QString QFontDatabase::styleString(const QFontInfo &fontInfo)
Example:
- \snippet qfontdatabase/main.cpp 0
- \snippet qfontdatabase/main.cpp 1
+ \snippet qfontdatabase/qfontdatabase_snippets.cpp 0
This example gets the list of font families, the list of
styles for each family, and the point sizes that are available for