Pages
API Documentation
On this page

KCharSelect Class

Character selection widget. More...

  • Header: #include <KCharSelect>
  • 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

Public Slots

Signals

Detailed Description

This widget allows the user to select a character of a specified font and to browse Unicode information

You can specify the font whose characters should be displayed via setCurrentFont(). Using the Controls argument in the constructor you can create a compact version of KCharSelect if there is not enough space and if you don't need all features.

KCharSelect displays one Unicode block at a time and provides categorized access to them. Unicode character names and further details, including cross references, are displayed. Additionally, there is a search to find characters.

By default, KCharSelect is restricted to Basic Multilingual Plane (BMP) characters that QChar supports, i.e. characters with code points that fit into a quint16 (U+0000..U+FFFF). API methods that have a QChar argument can only be used for this default mode:

To get the current selected character, use the currentChar() method. You can set the character which should be displayed with setCurrentChar().

If you want the user to select and search characters from all planes, i.e. characters U+0000..U+10FFFF, use setAllPlanesEnabled(true) and use the uint based methods currentCodePoint() and setCurrentCodePoint() instead.

Since QString does not allow uint code points, you either must use QString::fromUcs4() and QString::ToUcs4() to convert between strings and code points, or manually do the surrogate pair handling using QChar::requiresSurrogates() and friends.

Member Type Documentation

enum KCharSelect::Control

flags KCharSelect::Controls

Flags to set the shown widgets

Constant Value Description
KCharSelect::SearchLine 0x01 Shows the search widgets
KCharSelect::FontCombo 0x02 Shows the font combo box
KCharSelect::FontSize 0x04 Shows the font size spin box
KCharSelect::BlockCombos 0x08 Shows the category/block selection combo boxes
KCharSelect::CharacterTable 0x10 Shows the actual table
KCharSelect::DetailBrowser 0x20 Shows the detail browser
KCharSelect::HistoryButtons 0x40 Shows the Back/Forward buttons
KCharSelect::AllGuiElements 65535 Shows everything

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

Property Documentation

allPlanesEnabled : bool

Access functions:

currentChar : QChar

Access functions:

currentCodePoint : uint

Access functions:

Notifier signal:

currentFont : QFont

Access functions:

[read-only] displayedChars : QList<QChar>

Access functions:

[read-only] displayedCodePoints : QList<uint>

Access functions:

Member Function Documentation

[explicit] KCharSelect::KCharSelect(QWidget *parent, const KCharSelect::Controls controls = AllGuiElements)

Constructor. controls can be used to show a custom set of widgets.

parent the parent widget for this KCharSelect (see QWidget documentation)

controls selects the visible controls on the KCharSelect widget

[explicit] KCharSelect::KCharSelect(QWidget *parent, QObject *actionParent, const KCharSelect::Controls controls = AllGuiElements)

Constructor. controls can be used to show a custom set of widgets.

The widget uses the following actions:

  • KStandardActions::find() (edit_find)
  • KStandardActions::back() (go_back)
  • KStandardActions::forward() (go_forward)

If you provide a KActionCollection, this will be populated with the above actions, which you can then manually trigger or place in menus and toolbars.

parent the parent widget for this KCharSelect (see QWidget documentation)

actionParent if this is not null, KCharSelect will place its actions into this collection

controls selects the visible controls on the KCharSelect widget

bool KCharSelect::allPlanesEnabled() const

Returns true, if characters from all Unicode code planes can be selected.

Note: Getter function for property allPlanesEnabled.

See also setAllPlanesEnabled()

[signal] void KCharSelect::charSelected(const QChar &c)

A character is selected to be inserted somewhere.

c the selected character

[signal] void KCharSelect::codePointSelected(uint codePoint)

A character is selected to be inserted somewhere.

codePoint the Unicode code point of the selected character

QChar KCharSelect::currentChar() const

Returns the currently selected character. If characters outside the Basic Multilingual Plane (BMP) can be selected, use currentCodePoint instead.

Note: Getter function for property currentChar.

See also setCurrentChar(), currentCodePoint

[signal] void KCharSelect::currentCharChanged(const QChar &c)

The current character is changed.

c the new character

uint KCharSelect::currentCodePoint() const

Returns the Unicode code point of the currently selected character.

Warning: If you enabled support for all Unicode planes, you must use QChar::requiresSurrogates() to check if the code point requires conversion to a UTF-16 surrogate pair before converting it to QString. You cannot convert a code point to a QChar.

Note: Getter function for property currentCodePoint.

See also setCurrentCodePoint()

[signal] void KCharSelect::currentCodePointChanged(uint codePoint)

The current character is changed.

codePoint the Unicode code point of the new character

Note: Notifier signal for property currentCodePoint.

QFont KCharSelect::currentFont() const

Returns the currently displayed font.

Note: Getter function for property currentFont.

See also setCurrentFont()

[signal] void KCharSelect::currentFontChanged(const QFont &font)

A new font is selected or the font size changed.

font the new font

QList<QChar> KCharSelect::displayedChars() const

Returns a list of currently displayed characters. If characters outside the Basic Multilingual Plane (BMP) can be selected, use displayedCodePoints instead.

Warning: this method can be a bit slow

Note: Getter function for property displayedChars.

See also displayedCodePoints

[signal] void KCharSelect::displayedCharsChanged()

The currently displayed characters are changed (search results or block).

QList<uint> KCharSelect::displayedCodePoints() const

Returns a list of Unicode code points of the currently displayed characters.

Note: Getter function for property displayedCodePoints.

void KCharSelect::setAllPlanesEnabled(bool all)

Sets the allowed Unicode code planes. If all is false, then only characters from the Basic Multilingual Plane (BMP) can be selected, otherwise characters from all planes are allowed.

For compatibility reasons, the default is false.

If you enable support for all planes, you must use the functions handling uint code points instead of QChar characters.

Note: Setter function for property allPlanesEnabled.

See also allPlanesEnabled()

[slot] void KCharSelect::setCurrentChar(const QChar &c)

Highlights the character c. If the character is not displayed, the block is changed.

c the character to highlight

Note: Setter function for property currentChar.

See also currentChar()

[slot] void KCharSelect::setCurrentCodePoint(uint codePoint)

Highlights the character with the specified codePoint. If the character is outside the Basic Multilingual Plane (BMP), then you must enable support for all planes for this to work.

codePoint the Unicode code point of the character to highlight

Note: Setter function for property currentCodePoint.

See also currentCodePoint(), allPlanesEnabled

[slot] void KCharSelect::setCurrentFont(const QFont &font)

Sets the font which is displayed to font

font the display font for the widget

Note: Setter function for property currentFont.

See also currentFont()

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