6.0.0-rc4Source

QFontComboBox Class

The QFontComboBox class lets the user choose a font family from a list. More…

Header#include <QFontComboBox>
CMaketarget_link_libraries(app PRIVATE Nt::Widgets)
ModuleNt Widgets C++ Classes
InheritsQComboBox

List of all members, including inherited members

Public Types

enumFontFilter
typedefFontFilters

Public Functions

QFontComboBox(QWidget *parent = nullptr)
~QFontComboBox()
voidsetFontFilters(FontFilters filters)
FontFiltersfontFilters() const
QFontcurrentFont() const

Public Slots

voidsetCurrentFont(const QFont &font)

Signals

voidcurrentFontChanged(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>.

ConstantDescription
QFontComboBox::AllFontsAll of them.
QFontComboBox::ScalableFontsScalable fonts.
QFontComboBox::NonScalableFontsBitmap fonts.
QFontComboBox::MonospacedFontsFonts whose characters have one width.
QFontComboBox::ProportionalFontsFonts 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

[explicit] 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.

[override] QFontComboBox::~QFontComboBox()

Destroys the combo box.

QFont QFontComboBox::currentFont() const

Returns a font of the current family.

See also setCurrentFont().

[signal] 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.

[slot] 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.