QFontComboBox Class
The QFontComboBox widget is a combobox that lets the user select a font family. More...
Header: | #include <QFontComboBox> |
qmake: | QT += widgets |
Since: | Qt 4.2 |
Inherits: | QComboBox |
Public Types
enum | FontFilter { AllFonts, ScalableFonts, NonScalableFonts, MonospacedFonts, ProportionalFonts } |
flags | FontFilters |
Properties
- currentFont : QFont
- fontFilters : FontFilters
- writingSystem : QFontDatabase::WritingSystem
- 14 properties inherited from QComboBox
- 59 properties inherited from QWidget
- 1 property inherited from QObject
Public Functions
QFontComboBox(QWidget *parent = Q_NULLPTR) | |
~QFontComboBox() | |
QFont | currentFont() const |
FontFilters | fontFilters() const |
void | setFontFilters(FontFilters filters) |
void | setWritingSystem(QFontDatabase::WritingSystem) |
QFontDatabase::WritingSystem | writingSystem() const |
Reimplemented Public Functions
virtual QSize | sizeHint() const |
- 60 public functions inherited from QComboBox
- 214 public functions inherited from QWidget
- 32 public functions inherited from QObject
- 14 public functions inherited from QPaintDevice
Public Slots
void | setCurrentFont(const QFont &f) |
- 5 public slots inherited from QComboBox
- 19 public slots inherited from QWidget
- 1 public slot inherited from QObject
Signals
void | currentFontChanged(const QFont &font) |
- 8 signals inherited from QComboBox
- 3 signals inherited from QWidget
- 2 signals inherited from QObject
Reimplemented Protected Functions
virtual bool | event(QEvent *e) |
- 15 protected functions inherited from QComboBox
- 35 protected functions inherited from QWidget
- 9 protected functions inherited from QObject
- 1 protected function inherited from QPaintDevice
Additional Inherited Members
- 5 static public members inherited from QWidget
- 11 static public members inherited from QObject
- 15 protected functions inherited from QComboBox
- 35 protected functions inherited from QWidget
- 9 protected functions inherited from QObject
- 1 protected function inherited from QPaintDevice
- 1 protected slot inherited from QWidget
Detailed Description
The QFontComboBox widget is a combobox that lets the user select a font family.
The combobox is populated with an alphabetized list of font family names, such as Arial, Helvetica, and Times New Roman. Family names are displayed using the actual font when possible. For fonts such as Symbol, where the name is not representable in the font itself, a sample of the font is displayed next to the family name.
QFontComboBox is often used in toolbars, in conjunction with a QComboBox for controlling the font size and two QToolButtons for bold and italic.
When the user selects a new font, the currentFontChanged() signal is emitted in addition to currentIndexChanged().
Call setWritingSystem() to tell QFontComboBox to show only fonts that support a given writing system, and setFontFilters() to filter out certain types of fonts as e.g. non scalable fonts or monospaced fonts.
See also QComboBox, QFont, QFontInfo, QFontMetrics, QFontDatabase, and Character Map Example.
Member Type Documentation
enum QFontComboBox::FontFilterflags QFontComboBox::FontFilters
This enum can be used to only show certain types of fonts in the font combo box.
Constant | Value | Description |
---|---|---|
QFontComboBox::AllFonts |
0 |
Show all fonts |
QFontComboBox::ScalableFonts |
0x1 |
Show scalable fonts |
QFontComboBox::NonScalableFonts |
0x2 |
Show non scalable fonts |
QFontComboBox::MonospacedFonts |
0x4 |
Show monospaced fonts |
QFontComboBox::ProportionalFonts |
0x8 |
Show proportional fonts |
The FontFilters type is a typedef for QFlags<FontFilter>. It stores an OR combination of FontFilter values.
Property Documentation
currentFont : QFont
This property holds the currently selected font
Access functions:
QFont | currentFont() const |
void | setCurrentFont(const QFont &f) |
Notifier signal:
void | currentFontChanged(const QFont &font) |
See also currentIndex and currentText.
fontFilters : FontFilters
This property holds the filter for the combobox
By default, all fonts are listed.
Access functions:
FontFilters | fontFilters() const |
void | setFontFilters(FontFilters filters) |
See also writingSystem.
writingSystem : QFontDatabase::WritingSystem
This property holds the writing system that serves as a filter for the combobox
If script is QFontDatabase::Any (the default), all fonts are listed.
Access functions:
QFontDatabase::WritingSystem | writingSystem() const |
void | setWritingSystem(QFontDatabase::WritingSystem) |
See also fontFilters.
Member Function Documentation
QFontComboBox::QFontComboBox(QWidget *parent = Q_NULLPTR)
Constructs a font combobox with the given parent.
QFontComboBox::~QFontComboBox()
Destroys the combobox.
[signal]
void QFontComboBox::currentFontChanged(const QFont &font)
This signal is emitted whenever the current font changes, with the new font.
Note: Notifier signal for property currentFont.
See also currentFont.
[virtual protected]
bool QFontComboBox::event(QEvent *e)
Reimplemented from QObject::event().
[virtual]
QSize QFontComboBox::sizeHint() const
Reimplemented from QWidget::sizeHint().
© The Qt Company Ltd
Licensed under the GNU Free Documentation License, Version 1.3.
https://doc.qt.io/qt-5.9/qfontcombobox.html