KTextEdit
#include <KTextEdit>

Signals | |
void | aboutToShowContextMenu (QMenu *menu) |
void | checkSpellingChanged (bool) |
void | languageChanged (const QString &language) |
void | spellCheckerAutoCorrect (const QString ¤tWord, const QString &autoCorrectWord) |
void | spellCheckingCanceled () |
void | spellCheckingFinished () |
void | spellCheckStatus (const QString &) |
Public Slots | |
void | addTextDecorator (Sonnet::SpellCheckDecorator *decorator) |
void | checkSpelling () |
void | clearDecorator () |
void | replace () |
void | setSpellCheckingLanguage (const QString &language) |
void | showSpellConfigDialog (const QString &windowIcon=QString()) |
Protected Slots | |
void | slotDoFind () |
void | slotDoReplace () |
void | slotFind () |
void | slotFindNext () |
void | slotFindPrevious () |
void | slotReplace () |
void | slotReplaceNext () |
void | slotSpeakText () |
Protected Member Functions | |
KTEXTWIDGETS_NO_EXPORT | KTextEdit (KTextEditPrivate &dd, const QString &text, QWidget *parent) |
KTEXTWIDGETS_NO_EXPORT | KTextEdit (KTextEditPrivate &dd, QWidget *parent) |
void | contextMenuEvent (QContextMenuEvent *) override |
virtual void | deleteWordBack () |
virtual void | deleteWordForward () |
bool | event (QEvent *) override |
void | focusInEvent (QFocusEvent *) override |
void | keyPressEvent (QKeyEvent *) override |
![]() | |
virtual bool | canInsertFromMimeData (const QMimeData *source) const const |
virtual void | changeEvent (QEvent *e) override |
virtual QMimeData * | createMimeDataFromSelection () const const |
virtual void | dragEnterEvent (QDragEnterEvent *e) override |
virtual void | dragLeaveEvent (QDragLeaveEvent *e) override |
virtual void | dragMoveEvent (QDragMoveEvent *e) override |
virtual void | dropEvent (QDropEvent *e) override |
virtual bool | focusNextPrevChild (bool next) override |
virtual void | focusOutEvent (QFocusEvent *e) override |
virtual void | inputMethodEvent (QInputMethodEvent *e) override |
virtual void | insertFromMimeData (const QMimeData *source) |
virtual void | keyReleaseEvent (QKeyEvent *e) override |
virtual void | mouseDoubleClickEvent (QMouseEvent *e) override |
virtual void | mouseMoveEvent (QMouseEvent *e) override |
virtual void | mousePressEvent (QMouseEvent *e) override |
virtual void | mouseReleaseEvent (QMouseEvent *e) override |
virtual void | paintEvent (QPaintEvent *event) override |
virtual void | resizeEvent (QResizeEvent *e) override |
virtual void | scrollContentsBy (int dx, int dy) override |
virtual void | showEvent (QShowEvent *) override |
virtual void | wheelEvent (QWheelEvent *e) override |
![]() | |
void | setViewportMargins (const QMargins &margins) |
void | setViewportMargins (int left, int top, int right, int bottom) |
virtual bool | viewportEvent (QEvent *event) |
QMargins | viewportMargins () const const |
virtual QSize | viewportSizeHint () const const |
![]() | |
void | initStyleOption (QStyleOptionFrame *option) const const |
![]() | |
virtual void | actionEvent (QActionEvent *event) |
virtual void | closeEvent (QCloseEvent *event) |
void | create (WId window, bool initializeWindow, bool destroyOldWindow) |
void | destroy (bool destroyWindow, bool destroySubWindows) |
virtual void | enterEvent (QEvent *event) |
bool | focusNextChild () |
bool | focusPreviousChild () |
virtual void | hideEvent (QHideEvent *event) |
virtual void | initPainter (QPainter *painter) const const override |
virtual void | leaveEvent (QEvent *event) |
virtual int | metric (QPaintDevice::PaintDeviceMetric m) const const override |
virtual void | moveEvent (QMoveEvent *event) |
virtual bool | nativeEvent (const QByteArray &eventType, void *message, long *result) |
virtual void | tabletEvent (QTabletEvent *event) |
void | updateMicroFocus () |
![]() | |
virtual void | childEvent (QChildEvent *event) |
virtual void | connectNotify (const QMetaMethod &signal) |
virtual void | customEvent (QEvent *event) |
virtual void | disconnectNotify (const QMetaMethod &signal) |
bool | isSignalConnected (const QMetaMethod &signal) const const |
int | receivers (const char *signal) const const |
QObject * | sender () const const |
int | senderSignalIndex () const const |
virtual void | timerEvent (QTimerEvent *event) |
Additional Inherited Members | |
![]() | |
enum | AutoFormattingFlag |
enum | LineWrapMode |
![]() | |
enum | SizeAdjustPolicy |
![]() | |
enum | Shadow |
enum | Shape |
enum | StyleMask |
![]() | |
enum | RenderFlag |
![]() | |
enum | PaintDeviceMetric |
![]() | |
QWidget * | createWindowContainer (QWindow *window, QWidget *parent, Qt::WindowFlags flags) |
QWidget * | find (WId id) |
QWidget * | keyboardGrabber () |
QWidget * | mouseGrabber () |
void | setTabOrder (QWidget *first, QWidget *second) |
![]() | |
QMetaObject::Connection | connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, Functor functor) |
bool | disconnect (const QMetaObject::Connection &connection) |
bool | disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method) |
bool | disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method) |
bool | disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method) |
QString | tr (const char *sourceText, const char *disambiguation, int n) |
QString | trUtf8 (const char *sourceText, const char *disambiguation, int n) |
![]() | |
AutoAll | |
AutoBulletList | |
typedef | AutoFormatting |
AutoNone | |
FixedColumnWidth | |
FixedPixelWidth | |
NoWrap | |
WidgetWidth | |
![]() | |
AdjustIgnored | |
AdjustToContents | |
AdjustToContentsOnFirstShow | |
![]() | |
Box | |
HLine | |
NoFrame | |
Panel | |
Plain | |
Raised | |
Shadow_Mask | |
Shape_Mask | |
StyledPanel | |
Sunken | |
VLine | |
WinPanel | |
![]() | |
DrawChildren | |
DrawWindowBackground | |
IgnoreMask | |
typedef | RenderFlags |
![]() | |
typedef | QObjectList |
![]() | |
PdmDepth | |
PdmDevicePixelRatio | |
PdmDevicePixelRatioScaled | |
PdmDpiX | |
PdmDpiY | |
PdmHeight | |
PdmHeightMM | |
PdmNumColors | |
PdmPhysicalDpiX | |
PdmPhysicalDpiY | |
PdmWidth | |
PdmWidthMM | |
Detailed Description
This is just a little subclass of QTextEdit, implementing some standard KDE features, like cursor auto-hiding, configurable wheelscrolling (fast-scroll or zoom), spell checking and deleting of entire words with Ctrl-Backspace or Ctrl-Delete.
This text edit provides two ways of spell checking: background checking, which will mark incorrectly spelled words red, and a spell check dialog, which lets the user check and correct all incorrectly spelled words.
Basic rule: whenever you want to use QTextEdit, use KTextEdit!

- See also
- QTextEdit
Definition at line 45 of file ktextedit.h.
Constructor & Destructor Documentation
◆ KTextEdit() [1/2]
Constructs a KTextEdit object.
See QTextEdit::QTextEdit for details.
Definition at line 230 of file ktextedit.cpp.
◆ KTextEdit() [2/2]
|
explicit |
Constructs a KTextEdit object.
See QTextEdit::QTextEdit for details.
Definition at line 244 of file ktextedit.cpp.
◆ ~KTextEdit()
|
overridedefault |
Destroys the KTextEdit object.
Member Function Documentation
◆ aboutToShowContextMenu
|
signal |
Emitted before the context menu is displayed.
The signal allows you to add your own entries into the the context menu that is created on demand.
NOTE: Do not store the pointer to the QMenu provided through since it is created and deleted on demand.
- Parameters
-
p the context menu about to be displayed
- Since
- 4.5
◆ addTextDecorator
|
slot |
◆ checkSpelling
|
slot |
Show a dialog to check the spelling.
The spellCheckStatus() signal will be emitted when the spell checking dialog is closed.
Definition at line 738 of file ktextedit.cpp.
◆ checkSpellingChanged
|
signal |
emit signal when we activate or not autospellchecking
- Since
- 4.1
◆ checkSpellingEnabled()
|
virtual |
Returns true if background spell checking is enabled for this text edit.
Note that it even returns true if this is a read-only KTextEdit, where spell checking is actually disabled. By default spell checking is disabled.
- See also
- setCheckSpellingEnabled()
◆ clearDecorator
|
slot |
clearDecorator clear the spellcheckerdecorator
- Since
- 5.11
Definition at line 618 of file ktextedit.cpp.
◆ clickMessage()
|
inline |
- Returns
- the message set with setClickMessage
- Deprecated:
- since 5.0, use QTextEdit::placeholderText instead
Definition at line 204 of file ktextedit.h.
◆ contextMenuEvent()
|
overrideprotectedvirtual |
Reimplemented from QTextEdit to add spelling related items when appropriate.
Reimplemented from QTextEdit.
Definition at line 592 of file ktextedit.cpp.
◆ createHighlighter()
|
virtual |
Allows to create a specific highlighter if reimplemented.
By default, it creates a normal highlighter, based on the config file given to setSpellCheckingConfigFileName().
This highlighter is set each time spell checking is toggled on by calling setCheckSpellingEnabled(), but can later be overridden by calling setHighlighter().
- See also
- setHighlighter()
- highlighter()
- setSpellCheckingConfigFileName()
Definition at line 602 of file ktextedit.cpp.
◆ deleteWordBack()
|
protectedvirtual |
Deletes a word backwards from the current cursor position, if available.
Definition at line 446 of file ktextedit.cpp.
◆ deleteWordForward()
|
protectedvirtual |
Deletes a word forwards from the current cursor position, if available.
Definition at line 453 of file ktextedit.cpp.
◆ enableFindReplace()
void KTextEdit::enableFindReplace | ( | bool | enabled | ) |
◆ event()
|
overrideprotectedvirtual |
Reimplemented to catch "delete word" shortcut events.
Reimplemented from QAbstractScrollArea.
Definition at line 298 of file ktextedit.cpp.
◆ focusInEvent()
|
overrideprotectedvirtual |
Reimplemented to instantiate a KDictSpellingHighlighter, if spellchecking is enabled.
Reimplemented from QTextEdit.
Definition at line 675 of file ktextedit.cpp.
◆ forceSpellChecking()
void KTextEdit::forceSpellChecking | ( | ) |
- Since
- 4.10 create a modal spellcheck dialogbox and spellCheckingFinished signal we sent when we finish spell checking or spellCheckingCanceled signal when we cancel spell checking
Definition at line 745 of file ktextedit.cpp.
◆ highlighter()
Sonnet::Highlighter * KTextEdit::highlighter | ( | ) | const |
Returns the current highlighter, which is 0 if spell checking is disabled.
The default highlighter is the one created by createHighlighter(), but might be overridden by setHighlighter().
- See also
- setHighlighter()
- createHighlighter()
Definition at line 607 of file ktextedit.cpp.
◆ highlightWord()
void KTextEdit::highlightWord | ( | int | length, |
int | pos | ||
) |
Selects the characters at the specified position.
Any previous selection will be lost. The cursor is moved to the first character of the new selection.
- Parameters
-
length The length of the selection, in number of characters pos The position of the first character of the selection
Definition at line 752 of file ktextedit.cpp.
◆ keyPressEvent()
|
overrideprotectedvirtual |
Reimplemented for internal reasons.
Reimplemented from QTextEdit.
Definition at line 1041 of file ktextedit.cpp.
◆ languageChanged
|
signal |
Emitted when the user changes the language in the spellcheck dialog shown by checkSpelling() or when calling setSpellCheckingLanguage().
- Parameters
-
language the new language the user selected
- Since
- 4.1
◆ mousePopupMenu()
|
virtual |
◆ replace
|
slot |
◆ setCheckSpellingEnabled()
|
virtual |
Turns background spell checking for this text edit on or off.
Note that spell checking is only available in read-writable KTextEdits.
Enabling spell checking will set back the current highlighter to the one returned by createHighlighter().
- See also
- checkSpellingEnabled()
- isReadOnly()
- setReadOnly()
Definition at line 649 of file ktextedit.cpp.
◆ setClickMessage()
|
inline |
This makes the text edit display a grayed-out hinting text as long as the user didn't enter any text.
It is often used as indication about the purpose of the text edit.
- Deprecated:
- since 5.0, use QTextEdit::setPlaceholderText instead
Definition at line 192 of file ktextedit.h.
◆ setHighlighter()
void KTextEdit::setHighlighter | ( | Sonnet::Highlighter * | _highLighter | ) |
Sets a custom background spell highlighter for this text edit.
Normally, the highlighter returned by createHighlighter() will be used to detect and highlight incorrectly spelled words, but this function allows to set a custom highlighter.
This has to be called after enabling spell checking with setCheckSpellingEnabled(), otherwise it has no effect.
Ownership is transferred to the KTextEdit
- See also
- highlighter()
- createHighlighter()
- Parameters
-
highLighter the new highlighter which will be used now
Definition at line 636 of file ktextedit.cpp.
◆ setReadOnly()
|
virtual |
Reimplemented to set a proper "deactivated" background color.
Definition at line 698 of file ktextedit.cpp.
◆ setSpellCheckingLanguage
|
slot |
Set the spell check language which will be used for highlighting spelling mistakes and for the spellcheck dialog.
The languageChanged() signal will be emitted when the new language is different from the old one.
- Since
- 4.1
Definition at line 267 of file ktextedit.cpp.
◆ shouldBlockBeSpellChecked()
|
virtual |
Returns true if the given paragraph or block should be spellcheck.
For example, a mail client does not want to check quoted text, and would return false here (by checking whether the block starts with a quote sign).
Always returns true by default.
Definition at line 693 of file ktextedit.cpp.
◆ showAutoCorrectButton()
void KTextEdit::showAutoCorrectButton | ( | bool | show | ) |
- Since
- 4.10
Definition at line 1052 of file ktextedit.cpp.
◆ showSpellConfigDialog
Opens a Sonnet::ConfigDialog for this text edit.
The spellcheck language of the config dialog is set to the current spellcheck language of the textedit. If the user changes the language in that dialog, the languageChanged() signal is emitted.
- Parameters
-
configFileName The file which is used to store and load the config settings windowIcon the icon which is used for the titlebar of the spell dialog window. Can be empty, then no icon is set.
- Since
- 4.2
Definition at line 282 of file ktextedit.cpp.
◆ showTabAction()
void KTextEdit::showTabAction | ( | bool | show | ) |
- Since
- 4.10
Definition at line 984 of file ktextedit.cpp.
◆ slotDoReplace
|
protectedslot |
- Since
- 4.1
Definition at line 778 of file ktextedit.cpp.
◆ slotFindPrevious
|
protectedslot |
- Since
- 5.11
Definition at line 928 of file ktextedit.cpp.
◆ slotSpeakText
|
protectedslot |
- Since
- 4.3
Definition at line 574 of file ktextedit.cpp.
◆ spellCheckerAutoCorrect
|
signal |
- Since
- 4.10
◆ spellCheckingCanceled
|
signal |
signal spellCheckingCanceled is sent when we cancel spell checking.
- Since
- 4.10
◆ spellCheckingFinished
|
signal |
signal spellCheckingFinished is sent when we finish spell check or we click on "Terminate" button in sonnet dialogbox
- Since
- 4.10
◆ spellCheckingLanguage()
const QString& KTextEdit::spellCheckingLanguage | ( | ) | const |
- Returns
- the spell checking language which was set by setSpellCheckingLanguage(), the spellcheck dialog or the spellcheck config dialog, or an empty string if that has never been called.
- Since
- 4.2
◆ spellCheckStatus
|
signal |
Signal sends when spell checking is finished/stopped/completed.
- Since
- 4.1
The documentation for this class was generated from the following files:
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon May 8 2023 03:55:51 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.