Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qfontdialog.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// Qt-Security score:significant reason:default
4
5#ifndef QFONTDIALOG_H
6#define QFONTDIALOG_H
7
8#include <QtWidgets/qtwidgetsglobal.h>
9#include <QtGui/qwindowdefs.h>
10#include <QtGui/qfont.h>
11
12#include <QtWidgets/qdialog.h>
13
15
16QT_BEGIN_NAMESPACE
17
18class QFontDialogPrivate;
19
20class Q_WIDGETS_EXPORT QFontDialog : public QDialog
21{
22 Q_OBJECT
23 Q_DECLARE_PRIVATE(QFontDialog)
24 Q_PROPERTY(QFont currentFont READ currentFont WRITE setCurrentFont NOTIFY currentFontChanged)
25 Q_PROPERTY(FontDialogOptions options READ options WRITE setOptions)
26
27public:
28 enum FontDialogOption {
29 NoButtons = 0x00000001,
30 DontUseNativeDialog = 0x00000002,
31 ScalableFonts = 0x00000004,
32 NonScalableFonts = 0x00000008,
33 MonospacedFonts = 0x00000010,
34 ProportionalFonts = 0x00000020
35 };
36 Q_ENUM(FontDialogOption)
37
38 Q_DECLARE_FLAGS(FontDialogOptions, FontDialogOption)
39
40 explicit QFontDialog(QWidget *parent = nullptr);
41 explicit QFontDialog(const QFont &initial, QWidget *parent = nullptr);
42 ~QFontDialog();
43
44 void setCurrentFont(const QFont &font);
45 QFont currentFont() const;
46
47 QFont selectedFont() const;
48
49 void setOption(FontDialogOption option, bool on = true);
50 bool testOption(FontDialogOption option) const;
51 void setOptions(FontDialogOptions options);
52 FontDialogOptions options() const;
53
54 using QDialog::open;
55 void open(QObject *receiver, const char *member);
56
57 void setVisible(bool visible) override;
58
59 static QFont getFont(bool *ok, QWidget *parent = nullptr);
60 static QFont getFont(bool *ok, const QFont &initial, QWidget *parent = nullptr, const QString &title = QString(),
61 FontDialogOptions options = FontDialogOptions());
62
63Q_SIGNALS:
64 void currentFontChanged(const QFont &font);
65 void fontSelected(const QFont &font);
66
67protected:
68 void changeEvent(QEvent *event) override;
69 void done(int result) override;
70 bool eventFilter(QObject *object, QEvent *event) override;
71
72private:
73 Q_DISABLE_COPY(QFontDialog)
74};
75
76Q_DECLARE_OPERATORS_FOR_FLAGS(QFontDialog::FontDialogOptions)
77
78QT_END_NAMESPACE
79
80#endif // QFONTDIALOG_H
\inmodule QtWidgets
Definition qfontdialog.h:21
QStringListModel * model() const
int count() const
void setCurrentItem(int item)
void currentChanged(const QModelIndex &current, const QModelIndex &previous) override
This slot is called when a new item becomes the current item.
QString currentText() const
int currentItem() const
QString text(int i) const
friend class QWidget
Definition qpainter.h:431
static const Qt::WindowFlags qfd_DefaultWindowFlags
QT_REQUIRE_CONFIG(thread)