Pages
API Documentation
On this page

KFontChooser Class

A font selection widget. More...

  • Header: #include <KFontChooser>
  • CMake: find_package(KF6 REQUIRED COMPONENTS WidgetsAddons)
    target_link_libraries(mytarget PRIVATE KF6::WidgetsAddons)
  • Inherits: QWidget

List of all members, including inherited members

Public Types

Properties

Public Functions

Signals

Static Public Members

Detailed Description

While KFontChooser as an ordinary widget can be embedded in custom dialogs and therefore is very flexible, in most cases it is preferable to use the convenience functions in QFontDialog.

See also KFontRequester

Member Type Documentation

enum KFontChooser::DisplayFlag

flags KFontChooser::DisplayFlags

Flags for selecting what is displayed in the widget.

Constant Value Description
KFontChooser::NoDisplayFlags 0 No flags set
KFontChooser::FixedFontsOnly 1 Only show monospaced/fixed-width fonts, *excluding proportional fonts, (the checkbox to toggle showing only monospaced fonts is not shown in this case)
KFontChooser::DisplayFrame 2 = Show a visual frame around the chooser
KFontChooser::ShowDifferences 4 Display the font differences interfaces

The DisplayFlags type is a typedef for QFlags<DisplayFlag>. It stores an OR combination of DisplayFlag values.

enum KFontChooser::FontColumn

Displayed columns.

Constant Value Description
KFontChooser::FamilyList 0x01 Identifies the family (leftmost) list.
KFontChooser::StyleList 0x02 Identifies the style (center) list.
KFontChooser::SizeList 0x04 Identifies the size (rightmost) list.

enum KFontChooser::FontDiff

flags KFontChooser::FontDiffFlags

Flags for selecting which font attributes to change

Constant Value Description
KFontChooser::NoFontDiffFlags 0 No flags set
KFontChooser::FontDiffFamily 1 Identifies a requested change in the font family.
KFontChooser::FontDiffStyle 2 Identifies a requested change in the font style.
KFontChooser::FontDiffSize 4 Identifies a requested change in the font size.
KFontChooser::AllFontDiffs `FontDiffFamily FontDiffStyle

The FontDiffFlags type is a typedef for QFlags<FontDiff>. It stores an OR combination of FontDiff values.

enum KFontChooser::FontListCriteria

The selection criteria for the font families shown in the dialog.

Constant Value Description
KFontChooser::FixedWidthFonts 0x01 If set, only show fixed fixed-width (monospace) fonts.
KFontChooser::ScalableFonts 0x02 If set, only show scalable fonts. Certain configurations allow bitmap fonts to remain unscaled and thus these fonts have limited number of sizes.
KFontChooser::SmoothScalableFonts 0x04 If set, only show smooth scalable fonts. This will return only non-bitmap fonts which are scalable to any size requested. Setting this option means the ScalableFonts flag is ignored.

Property Documentation

backgroundColor : QColor

Access functions:

color : QColor

Access functions:

font : QFont

Access functions:

  • QFont font() const
  • void setFont(const QFont &font, bool onlyFixed = false)

Notifier signal:

sampleText : QString

Access functions:

Member Function Documentation

[explicit] KFontChooser::KFontChooser(QWidget *parent = nullptr)

Constructs a font picker widget.

parent the parent widget

[explicit] KFontChooser::KFontChooser(KFontChooser::DisplayFlags flags, QWidget *parent = nullptr)

Create a font picker widget.

flags a combination of OR-ed values from the KFontChooser::DisplayFlags enum, the default is DisplayFonts::NoDisplayFlags

parent the parent widget, if not nullptr the windowing system will use it to position the chooser widget relative to it

QColor KFontChooser::backgroundColor() const

Returns the background color currently used in the preview area (default: the base color of the active colorgroup)

Note: Getter function for property backgroundColor.

See also setBackgroundColor()

QColor KFontChooser::color() const

Returns the color currently used for the font in the preview area (default: the text color of the active color group).

Note: Getter function for property color.

See also setColor()

[static] QStringList KFontChooser::createFontList(uint fontListCriteria)

Returns a list of font faimly name strings filtered based on fontListCriteria.

fontListCriteria specifies the criteria used to select fonts to add to the list, a combination of OR-ed values from KFontChooser::FontListCriteria

void KFontChooser::enableColumn(int column, bool state)

Enables or disables a column (family, style, size) in the widget.

Use this function if your application does not need or support all font properties.

column specify the column(s) to enable/disable, an OR-ed combination of KFontChooser::FontColumn enum values

state if false the columns are disabled, and vice-versa

QFont KFontChooser::font() const

Returns the currently selected font in the chooser.

Note: Getter function for property font.

See also setFont()

KFontChooser::FontDiffFlags KFontChooser::fontDiffFlags() const

Returns the bitmask corresponding to the attributes the user wishes to change.

[signal] void KFontChooser::fontSelected(const QFont &font)

Emitted when the selected font changes.

Note: Notifier signal for property font.

QString KFontChooser::sampleText() const

Returns the current text in the sample text input area.

Note: Getter function for property sampleText.

See also setSampleText()

void KFontChooser::setBackgroundColor(const QColor &col)

Sets the background color to use in the preview area.

Note: Setter function for property backgroundColor.

See also backgroundColor()

void KFontChooser::setColor(const QColor &col)

Sets the color to use for the font in the preview area.

Note: Setter function for property color.

See also color()

void KFontChooser::setFont(const QFont &font, bool onlyFixed = false)

Sets the currently selected font in the widget.

font the font to select

onlyFixed if true, the font list will only display fixed-width fonts, otherwise all fonts are displayed. The default is false.

Note: Setter function for property font.

See also font()

void KFontChooser::setFontListItems(const QStringList &fontList)

Uses fontList to fill the font family list in the widget.

You can create a custom list of fonts using the static createFontList(uint criteria) to only include fonts that meet certain criteria (e.g. only smooth-scalable fonts).

Note that if fontList is empty, the font list in the chooser will show all the available fonts on the system.

See also KFontChooser::createFontList(uint), KFontChooser::FontListCriteria

void KFontChooser::setMinVisibleItems(int visibleItems)

Sets the minimum number of items that should be visible in the child list widgets; this number will be used to compute and set the minimum heights for those widgets.

void KFontChooser::setSampleBoxVisible(bool visible)

If visible is true the preview area will be shown, and vice-versa is it's false.

void KFontChooser::setSampleText(const QString &text)

Sets the sample text in the preview area; this is useful if you want to use text in your native language.

text the new sample text (it will replace the current text)

Note: Setter function for property sampleText.

See also sampleText()

We use cookies to personalize content and to analyze our traffic. Please decide if you are willing to accept cookies from our website.