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 |
Public Types
enum | DisplayFlag { NoDisplayFlags, FixedFontsOnly, DisplayFrame, ShowDifferences } |
flags | DisplayFlags |
enum | FontColumn { FamilyList, StyleList, SizeList } |
enum | FontDiff { NoFontDiffFlags, FontDiffFamily, FontDiffStyle, FontDiffSize, AllFontDiffs } |
flags | FontDiffFlags |
enum | FontListCriteria { FixedWidthFonts, ScalableFonts, SmoothScalableFonts } |
Properties
- backgroundColor : QColor
- color : QColor
- font : QFont
- sampleText : QString
Public Functions
(since 5.86) | KFontChooser(QWidget *parent = nullptr) |
(since 5.86) | KFontChooser(KFontChooser::DisplayFlags flags, QWidget *parent = nullptr) |
QColor | backgroundColor() const |
QColor | color() const |
void | enableColumn(int column, bool state) |
QFont | font() const |
KFontChooser::FontDiffFlags | fontDiffFlags() const |
QString | sampleText() const |
void | setBackgroundColor(const QColor &col) |
void | setColor(const QColor &col) |
void | setFont(const QFont &font, bool onlyFixed = false) |
(since 5.86) void | setFontListItems(const QStringList &fontList) |
(since 5.86) void | setMinVisibleItems(int visibleItems) |
void | setSampleBoxVisible(bool visible) |
void | setSampleText(const QString &text) |
Signals
void | fontSelected(const QFont &font) |
Static Public Members
(since 5.86) QStringList | createFontList(uint fontListCriteria) |
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 | FontDiffSize |
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:
QColor | backgroundColor() const |
void | setBackgroundColor(const QColor &col) |
color : QColor
Access functions:
font : QFont
Access functions:
Notifier signal:
void | fontSelected(const QFont &font) |
sampleText : QString
Access functions:
QString | sampleText() const |
void | setSampleText(const QString &text) |
Member Function Documentation
[explicit, since 5.86]
KFontChooser::KFontChooser(QWidget *parent = nullptr)
Constructs a font picker widget.
parent the parent widget
This function was introduced in 5.86.
[explicit, since 5.86]
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
This function was introduced in 5.86.
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, since 5.86]
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
This function was introduced in 5.86.
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().
[since 5.86]
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.
This function was introduced in 5.86.
See also KFontChooser::createFontList(uint) and KFontChooser::FontListCriteria.
[since 5.86]
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.
This function was introduced in 5.86.
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().