KTextEdit Class
A KDE'ified QTextEdit. More...
Header: | #include <KTextEdit> |
CMake: | find_package(KF6 REQUIRED COMPONENTS TextWidgets) target_link_libraries(mytarget PRIVATE KF6::TextWidgets) |
Inherits: | QTextEdit |
Inherited By: |
Properties
- checkSpellingEnabled : bool
- spellCheckingLanguage : QString
Public Functions
KTextEdit(QWidget *parent = nullptr) | |
KTextEdit(const QString &text, QWidget *parent = nullptr) | |
virtual | ~KTextEdit() override |
virtual bool | checkSpellingEnabled() const |
virtual void | createHighlighter() |
(since 4.1) void | enableFindReplace(bool enabled) |
(since 4.10) void | forceSpellChecking() |
void | highlightWord(int length, int pos) |
Sonnet::Highlighter * | highlighter() const |
(since 4.1) virtual QMenu * | mousePopupMenu() |
virtual void | setCheckSpellingEnabled(bool check) |
void | setHighlighter(Sonnet::Highlighter *_highLighter) |
virtual void | setReadOnly(bool readOnly) |
virtual bool | shouldBlockBeSpellChecked(const QString &block) const |
(since 4.10) void | showAutoCorrectButton(bool show) |
(since 4.10) void | showTabAction(bool show) |
(since 4.2) const QString & | spellCheckingLanguage() const |
Public Slots
(since 5.11) void | addTextDecorator(Sonnet::SpellCheckDecorator *decorator) |
void | checkSpelling() |
(since 5.11) void | clearDecorator() |
(since 4.1) void | replace() |
(since 4.1) void | setSpellCheckingLanguage(const QString &language) |
(since 4.2) void | showSpellConfigDialog(const QString &windowIcon = QString()) |
Signals
(since 4.5) void | aboutToShowContextMenu(QMenu *menu) |
(since 4.1) void | checkSpellingChanged(bool) |
(since 4.1) void | languageChanged(const QString &language) |
(since 4.1) void | spellCheckStatus(const QString &) |
(since 4.10) void | spellCheckerAutoCorrect(const QString ¤tWord, const QString &autoCorrectWord) |
(since 4.10) void | spellCheckingCanceled() |
(since 4.10) void | spellCheckingFinished() |
Protected Functions
virtual void | deleteWordBack() |
virtual void | deleteWordForward() |
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!
Property Documentation
checkSpellingEnabled : bool
Access functions:
virtual bool | checkSpellingEnabled() const |
virtual void | setCheckSpellingEnabled(bool check) |
spellCheckingLanguage : QString
Access functions:
const QString & | spellCheckingLanguage() const |
void | setSpellCheckingLanguage(const QString &language) |
Member Function Documentation
[explicit]
KTextEdit::KTextEdit(QWidget *parent = nullptr)
Constructs a KTextEdit object. See QTextEdit::QTextEdit for details.
[explicit]
KTextEdit::KTextEdit(const QString &text, QWidget *parent = nullptr)
Constructs a KTextEdit object. See QTextEdit::QTextEdit for details.
[override virtual noexcept]
KTextEdit::~KTextEdit()
Destroys the KTextEdit object.
[signal, since 4.5]
void KTextEdit::aboutToShowContextMenu(QMenu *menu)
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.
This function was introduced in 4.5.
[slot, since 5.11]
void KTextEdit::addTextDecorator(Sonnet::SpellCheckDecorator *decorator)
Add custom spell checker decorator
This function was introduced in 5.11.
[slot]
void KTextEdit::checkSpelling()
Show a dialog to check the spelling. The spellCheckStatus() signal will be emitted when the spell checking dialog is closed.
[signal, since 4.1]
void KTextEdit::checkSpellingChanged(bool)
emit signal when we activate or not autospellchecking
This function was introduced in 4.1.
[virtual]
bool KTextEdit::checkSpellingEnabled() const
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.
Note: Getter function for property checkSpellingEnabled.
See also setCheckSpellingEnabled().
[slot, since 5.11]
void KTextEdit::clearDecorator()
clearDecorator clear the spellcheckerdecorator
This function was introduced in 5.11.
[virtual]
void KTextEdit::createHighlighter()
Allows to create a specific highlighter if reimplemented.
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() and highlighter().
[virtual protected]
void KTextEdit::deleteWordBack()
Deletes a word backwards from the current cursor position, if available.
[virtual protected]
void KTextEdit::deleteWordForward()
Deletes a word forwards from the current cursor position, if available.
[since 4.1]
void KTextEdit::enableFindReplace(bool enabled)
Sets the find/replace action to the value of enabled.
This function was introduced in 4.1.
[since 4.10]
void KTextEdit::forceSpellChecking()
create a modal spellcheck dialogbox and spellCheckingFinished signal we sent when we finish spell checking or spellCheckingCanceled signal when we cancel spell checking
This function was introduced in 4.10.
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.
length The length of the selection, in number of characters
pos The position of the first character of the selection
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() and createHighlighter().
[signal, since 4.1]
void KTextEdit::languageChanged(const QString &language)
Emitted when the user changes the language in the spellcheck dialog shown by checkSpelling() or when calling setSpellCheckingLanguage().
language the new language the user selected
This function was introduced in 4.1.
[virtual, since 4.1]
QMenu *KTextEdit::mousePopupMenu()
Returns standard KTextEdit popupMenu
This function was introduced in 4.1.
[slot, since 4.1]
void KTextEdit::replace()
Create replace dialogbox
This function was introduced in 4.1.
[virtual]
void KTextEdit::setCheckSpellingEnabled(bool check)
Turns background spell checking for this text edit to the value of check. 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().
Note: Setter function for property checkSpellingEnabled.
See also checkSpellingEnabled() and setReadOnly().
void KTextEdit::setHighlighter(Sonnet::Highlighter *_highLighter)
Sets a custom background spellcheck 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
_highLighter is the spellcheck highlighter to use
See also highlighter() and createHighlighter().
[virtual]
void KTextEdit::setReadOnly(bool readOnly)
Sets the text edit control to the state of readOnly.
Reimplemented to set a proper "deactivated" background color.
[slot, since 4.1]
void KTextEdit::setSpellCheckingLanguage(const QString &language)
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.
Note: Setter function for property spellCheckingLanguage.
This function was introduced in 4.1.
See also spellCheckingLanguage().
[virtual]
bool KTextEdit::shouldBlockBeSpellChecked(const QString &block) const
Returns true if the given paragraph or block should be spellchecked. 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.
[since 4.10]
void KTextEdit::showAutoCorrectButton(bool show)
Shows the auto-correct button if the value of show is true.
This function was introduced in 4.10.
[slot, since 4.2]
void KTextEdit::showSpellConfigDialog(const QString &windowIcon = QString())
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.
windowIcon the icon which is used for the titlebar of the spell dialog window. Can be empty, then no icon is set.
This function was introduced in 4.2.
[since 4.10]
void KTextEdit::showTabAction(bool show)
Sets the show tab action to the value of show.
This function was introduced in 4.10.
[signal, since 4.1]
void KTextEdit::spellCheckStatus(const QString &)
Signal sends when spell checking is finished/stopped/completed
This function was introduced in 4.1.
[signal, since 4.10]
void KTextEdit::spellCheckerAutoCorrect(const QString ¤tWord, const QString &autoCorrectWord)
This signal is emitted when the spell checker wants the user to decide if currentWord should be replaced with autoCorrectWord.
This function was introduced in 4.10.
[signal, since 4.10]
void KTextEdit::spellCheckingCanceled()
signal spellCheckingCanceled is sent when we cancel spell checking.
This function was introduced in 4.10.
[signal, since 4.10]
void KTextEdit::spellCheckingFinished()
signal spellCheckingFinished is sent when we finish spell check or we click on "Terminate" button in sonnet dialogbox
This function was introduced in 4.10.
[since 4.2]
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.
Note: Getter function for property spellCheckingLanguage.
This function was introduced in 4.2.
See also setSpellCheckingLanguage().