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
qfontcombobox.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QFONTCOMBOBOX_H
5#define QFONTCOMBOBOX_H
6
7#include <QtWidgets/qtwidgetsglobal.h>
8#include <QtWidgets/qcombobox.h>
9#include <QtGui/qfontdatabase.h>
10
11QT_REQUIRE_CONFIG(fontcombobox);
12
14
16
17class Q_WIDGETS_EXPORT QFontComboBox : public QComboBox
18{
20 Q_PROPERTY(QFontDatabase::WritingSystem writingSystem READ writingSystem WRITE setWritingSystem)
21 Q_PROPERTY(FontFilters fontFilters READ fontFilters WRITE setFontFilters)
22 Q_PROPERTY(QFont currentFont READ currentFont WRITE setCurrentFont NOTIFY currentFontChanged)
23
24public:
25 explicit QFontComboBox(QWidget *parent = nullptr);
27
28 void setWritingSystem(QFontDatabase::WritingSystem);
29 QFontDatabase::WritingSystem writingSystem() const;
30
32 AllFonts = 0,
33 ScalableFonts = 0x1,
34 NonScalableFonts = 0x2,
35 MonospacedFonts = 0x4,
36 ProportionalFonts = 0x8
37 };
38 Q_DECLARE_FLAGS(FontFilters, FontFilter)
39 Q_FLAG(FontFilters)
40
41 void setFontFilters(FontFilters filters);
42 FontFilters fontFilters() const;
43
44 QFont currentFont() const;
45 QSize sizeHint() const override;
46
47 void setSampleTextForSystem(QFontDatabase::WritingSystem writingSystem, const QString &sampleText);
48 QString sampleTextForSystem(QFontDatabase::WritingSystem writingSystem) const;
49
50 void setSampleTextForFont(const QString &fontFamily, const QString &sampleText);
51 QString sampleTextForFont(const QString &fontFamily) const;
52
53 void setDisplayFont(const QString &fontFamily, const QFont &font);
54 std::optional<QFont> displayFont(const QString &fontFamily) const;
55
56public Q_SLOTS:
57 void setCurrentFont(const QFont &f);
58
61
62protected:
63 bool event(QEvent *e) override;
64
65private:
66 Q_DISABLE_COPY(QFontComboBox)
67 Q_DECLARE_PRIVATE(QFontComboBox)
68};
69
70Q_DECLARE_OPERATORS_FOR_FLAGS(QFontComboBox::FontFilters)
71
73
74#endif
The QComboBox widget combines a button with a dropdown list.
Definition qcombobox.h:24
\inmodule QtCore
Definition qcoreevent.h:45
The QFontComboBox widget is a combobox that lets the user select a font family.
void currentFontChanged(const QFont &f)
This signal is emitted whenever the current font changes, with the new font.
FontFilter
This enum can be used to only show certain types of fonts in the font combo box.
\threadsafe \inmodule QtGui
WritingSystem
\value Any \value Latin \value Greek \value Cyrillic \value Armenian \value Hebrew \value Arabic \val...
\reentrant
Definition qfont.h:22
\inmodule QtCore
Definition qsize.h:25
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
The QWidget class is the base class of all user interface objects.
Definition qwidget.h:99
Combined button and popup list for selecting options.
#define Q_DECLARE_FLAGS(Flags, Enum)
Definition qflags.h:174
#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags)
Definition qflags.h:194
GLfloat GLfloat f
struct _cl_event * event
#define QT_REQUIRE_CONFIG(feature)
#define Q_PROPERTY(...)
#define Q_OBJECT
#define Q_FLAG(x)
#define Q_SLOTS
#define Q_SIGNALS
#define explicit
const QStringList filters({"Image files (*.png *.xpm *.jpg)", "Text files (*.txt)", "Any files (*)" })
[6]