QFontComboBox Class
The QFontComboBox class lets the user choose a font family from a list. More…
| Header | #include <QFontComboBox> |
|---|---|
| CMake | target_link_libraries(app PRIVATE Nt::Widgets) |
| Module | Nt Widgets C++ Classes |
| Inherits | QComboBox |
List of all members, including inherited members
Public Types
| enum | FontFilter |
| typedef | FontFilters |
Public Functions
| QFontComboBox(QWidget *parent = nullptr) | |
| ~QFontComboBox() | |
| void | setFontFilters(FontFilters filters) |
| FontFilters | fontFilters() const |
| QFont | currentFont() const |
Public Slots
| void | setCurrentFont(const QFont &font) |
Signals
| void | currentFontChanged(const QFont &font) |
Detailed Description
The list has the generic families Sans Serif, Serif and Monospace, then the families that fontconfig finds:
auto *fonts = new QFontComboBox(toolBar);
connect(fonts, &QFontComboBox::currentFontChanged, editor, &QWidget::setFont);
See also QFontDialog and QComboBox.
Differences from Qt
The families are shown in the font of the combo box, not in their own font. The font filters are recorded but do not filter, and there is no writingSystem().
Member Type Documentation
enum QFontComboBox::FontFilter
Which families the list shows; recorded only. FontFilters is a typedef for QFlags<FontFilter>.
| Constant | Description |
|---|---|
QFontComboBox::AllFonts | All of them. |
QFontComboBox::ScalableFonts | Scalable fonts. |
QFontComboBox::NonScalableFonts | Bitmap fonts. |
QFontComboBox::MonospacedFonts | Fonts whose characters have one width. |
QFontComboBox::ProportionalFonts | Fonts whose characters have their own widths. |
typedef QFontComboBox::FontFilters
The FontFilters type is a typedef for QFlags<FontFilter>. It stores an OR combination of FontFilter values.
Member Function Documentation
QFontComboBox::QFontComboBox(QWidget *parent = nullptr)
Constructs a font combo box with the given parent. The current family is that of the application font, or the first one.
QFontComboBox::~QFontComboBox()
Destroys the combo box.
QFont QFontComboBox::currentFont() const
Returns a font of the current family.
See also setCurrentFont().
void QFontComboBox::currentFontChanged(const QFont &font)
This signal is emitted when the current font changes to font, the font of the family that was chosen.
FontFilters QFontComboBox::fontFilters() const
Returns the families that the list shows, AllFonts by default.
void QFontComboBox::setCurrentFont(const QFont &font)
Makes the family of font current. A family that is not in the list is added to it.
See also currentFont().
void QFontComboBox::setFontFilters(FontFilters filters)
Sets the families that the list shows to filters; recorded only.