QFontComboBox#

The QFontComboBox widget is a combobox that lets the user select a font family. More

Inheritance diagram of PySide6.QtWidgets.QFontComboBox

Synopsis#

Properties#

Functions#

Slots#

Signals#

Note

This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE

Detailed Description#

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 QToolButton s 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.

../../_images/windowsvista-fontcombobox.png

See also

QComboBox QFont QFontInfo QFontMetrics QFontDatabase Character Map Example

class PySide6.QtWidgets.QFontComboBox([parent=None])#
Parameters:

parentPySide6.QtWidgets.QWidget

Constructs a font combobox with the given parent.

Note

Properties can be used directly when from __feature__ import true_property is used or via accessor functions otherwise.

property PᅟySide6.QtWidgets.QFontComboBox.currentFont: PySide6.QtGui.QFont#

This property holds the currently selected font.

Access functions:
property PᅟySide6.QtWidgets.QFontComboBox.fontFilters: FontFilters#

This property holds the filter for the combobox.

By default, all fonts are listed.

See also

writingSystem

Access functions:
property PᅟySide6.QtWidgets.QFontComboBox.writingSystem: WritingSystem#

This property holds the writing system that serves as a filter for the combobox.

If script is Any (the default), all fonts are listed.

See also

fontFilters

Access functions:
PySide6.QtWidgets.QFontComboBox.FontFilter#

(inherits enum.Flag) This enum can be used to only show certain types of fonts in the font combo box.

Constant

Description

QFontComboBox.AllFonts

Show all fonts

QFontComboBox.ScalableFonts

Show scalable fonts

QFontComboBox.NonScalableFonts

Show non scalable fonts

QFontComboBox.MonospacedFonts

Show monospaced fonts

QFontComboBox.ProportionalFonts

Show proportional fonts

PySide6.QtWidgets.QFontComboBox.currentFont()#
Return type:

PySide6.QtGui.QFont

See also

setCurrentFont()

Getter of property currentFont .

PySide6.QtWidgets.QFontComboBox.currentFontChanged(f)#
Parameters:

fPySide6.QtGui.QFont

This signal is emitted whenever the current font changes, with the new font.

See also

currentFont

Notification signal of property currentFont .

PySide6.QtWidgets.QFontComboBox.fontFilters()#
Return type:

FontFilters

See also

setFontFilters()

Getter of property fontFilters .

PySide6.QtWidgets.QFontComboBox.sampleTextForFont(fontFamily)#
Parameters:

fontFamily – str

Return type:

str

Returns the sample text to show after the font name (when the combo is open) for a given fontFamily.

PySide6.QtWidgets.QFontComboBox.sampleTextForSystem(writingSystem)#
Parameters:

writingSystemWritingSystem

Return type:

str

Returns the sample text to show after the font name (when the combo is open) for a given writingSystem.

PySide6.QtWidgets.QFontComboBox.setCurrentFont(f)#
Parameters:

fPySide6.QtGui.QFont

See also

currentFont()

Setter of property currentFont .

PySide6.QtWidgets.QFontComboBox.setDisplayFont(fontFamily, font)#
Parameters:

Sets the font to be used to display a given fontFamily (when the combo is open).

See also

displayFont()

PySide6.QtWidgets.QFontComboBox.setFontFilters(filters)#
Parameters:

filtersFontFilters

See also

fontFilters()

Setter of property fontFilters .

PySide6.QtWidgets.QFontComboBox.setSampleTextForFont(fontFamily, sampleText)#
Parameters:
  • fontFamily – str

  • sampleText – str

Sets the sampleText to show after the font name (when the combo is open) for a given fontFamily.

The sample text given with this function has priority over the one set with setSampleTextForSystem() .

PySide6.QtWidgets.QFontComboBox.setSampleTextForSystem(writingSystem, sampleText)#
Parameters:

Sets the sampleText to show after the font name (when the combo is open) for a given writingSystem.

The sample text given with setSampleTextForFont() has priority.

PySide6.QtWidgets.QFontComboBox.setWritingSystem(arg__1)#
Parameters:

arg__1WritingSystem

See also

writingSystem()

Setter of property writingSystem .

PySide6.QtWidgets.QFontComboBox.writingSystem()#
Return type:

WritingSystem

Getter of property writingSystem .