• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.14.38 API Reference
  • KDE Home
  • Contact Us
 

KDEUI

Public Slots | Signals | Public Member Functions | Protected Slots | Protected Member Functions | Properties | List of all members
KTextEdit Class Reference

#include <ktextedit.h>

Inheritance diagram for KTextEdit:
QTextEdit KRichTextEdit KRichTextWidget

Public Slots

void checkSpelling ()
 
void mousePopupMenuImplementation (const QPoint &pos)
 
void replace ()
 
void setSpellCheckingLanguage (const QString &language)
 
void showSpellConfigDialog (const QString &configFileName, const QString &windowIcon=QString())
 

Signals

void aboutToShowContextMenu (QMenu *menu)
 
void checkSpellingChanged (bool)
 
void languageChanged (const QString &language)
 
void spellCheckerAutoCorrect (const QString &currentWord, const QString &autoCorrectWord)
 
void spellCheckingCanceled ()
 
void spellCheckingFinished ()
 
void spellCheckStatus (const QString &)
 

Public Member Functions

 KTextEdit (const QString &text, QWidget *parent=0)
 
 KTextEdit (QWidget *parent=0)
 
 ~KTextEdit ()
 
bool checkSpellingEnabled () const
 
QString clickMessage () const
 
virtual void createHighlighter ()
 
void enableFindReplace (bool enabled)
 
void forceSpellChecking ()
 
Sonnet::Highlighter * highlighter () const
 
void highlightWord (int length, int pos)
 
QMenu * mousePopupMenu ()
 
void setCheckSpellingEnabled (bool check)
 
void setClickMessage (const QString &msg)
 
void setHighlighter (Sonnet::Highlighter *_highLighter)
 
virtual void setReadOnly (bool readOnly)
 
void setSpellCheckingConfigFileName (const QString &fileName)
 
void setSpellInterface (KTextEditSpellInterface *spellInterface)
 
void showAutoCorrectButton (bool show)
 
void showTabAction (bool show)
 
const QString & spellCheckingLanguage () const
 

Protected Slots

void slotDoFind ()
 
void slotDoReplace ()
 
void slotFind ()
 
void slotFindNext ()
 
void slotFindPrevious ()
 
void slotReplace ()
 
void slotReplaceNext ()
 
void slotSpeakText ()
 

Protected Member Functions

bool checkSpellingEnabledInternal () const
 
virtual void contextMenuEvent (QContextMenuEvent *)
 
virtual void deleteWordBack ()
 
virtual void deleteWordForward ()
 
virtual bool event (QEvent *)
 
virtual void focusInEvent (QFocusEvent *)
 
virtual void focusOutEvent (QFocusEvent *)
 
virtual void keyPressEvent (QKeyEvent *)
 
virtual void paintEvent (QPaintEvent *)
 
void setCheckSpellingEnabledInternal (bool check)
 
virtual void wheelEvent (QWheelEvent *)
 

Properties

bool checkSpellingEnabled
 
QString clickMessage
 
QString spellCheckingLanguage
 

Detailed Description

A KDE'ified QTextEdit.

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!

KDE Text Edit Widget
See also
QTextEdit
Author
Carsten Pfeiffer pfeif.nosp@m.fer@.nosp@m.kde.o.nosp@m.rg

Definition at line 90 of file ktextedit.h.

Constructor & Destructor Documentation

◆ KTextEdit() [1/2]

KTextEdit::KTextEdit ( const QString &  text,
QWidget *  parent = 0 
)
explicit

Constructs a KTextEdit object.

See QTextEdit::QTextEdit for details.

Definition at line 317 of file ktextedit.cpp.

◆ KTextEdit() [2/2]

KTextEdit::KTextEdit ( QWidget *  parent = 0)
explicit

Constructs a KTextEdit object.

See QTextEdit::QTextEdit for details.

Definition at line 323 of file ktextedit.cpp.

◆ ~KTextEdit()

KTextEdit::~KTextEdit ( )

Destroys the KTextEdit object.

Definition at line 329 of file ktextedit.cpp.

Member Function Documentation

◆ aboutToShowContextMenu

void KTextEdit::aboutToShowContextMenu ( QMenu *  menu)
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
pthe context menu about to be displayed
Since
4.5

◆ checkSpelling

void KTextEdit::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 839 of file ktextedit.cpp.

◆ checkSpellingChanged

void KTextEdit::checkSpellingChanged ( bool  )
signal

emit signal when we activate or not autospellchecking

Since
4.1

◆ checkSpellingEnabled()

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.

If a spell interface is set by setSpellInterface(), the call will be delegated to there instead.

See also
setCheckSpellingEnabled()

Definition at line 794 of file ktextedit.cpp.

◆ checkSpellingEnabledInternal()

bool KTextEdit::checkSpellingEnabledInternal ( ) const
protected

Checks whether spellchecking is enabled or disabled.

This is what checkSpellingEnabled calls if there is no spell interface.

Since
4.2

Definition at line 802 of file ktextedit.cpp.

◆ clickMessage()

QString KTextEdit::clickMessage ( ) const
Returns
the message set with setClickMessage
Since
4.4

Definition at line 1147 of file ktextedit.cpp.

◆ contextMenuEvent()

void KTextEdit::contextMenuEvent ( QContextMenuEvent *  event)
protectedvirtual

Reimplemented from QTextEdit to add spelling related items when appropriate.

Definition at line 617 of file ktextedit.cpp.

◆ createHighlighter()

void KTextEdit::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 736 of file ktextedit.cpp.

◆ deleteWordBack()

void KTextEdit::deleteWordBack ( )
protectedvirtual

Deletes a word backwards from the current cursor position, if available.

Definition at line 507 of file ktextedit.cpp.

◆ deleteWordForward()

void KTextEdit::deleteWordForward ( )
protectedvirtual

Deletes a word forwards from the current cursor position, if available.

Definition at line 512 of file ktextedit.cpp.

◆ enableFindReplace()

void KTextEdit::enableFindReplace ( bool  enabled)

Enable find replace action.

Since
4.1

Definition at line 1051 of file ktextedit.cpp.

◆ event()

bool KTextEdit::event ( QEvent *  ev)
protectedvirtual

Reimplemented to catch "delete word" shortcut events.

Definition at line 371 of file ktextedit.cpp.

◆ focusInEvent()

void KTextEdit::focusInEvent ( QFocusEvent *  event)
protectedvirtual

Reimplemented to instantiate a KDictSpellingHighlighter, if spellchecking is enabled.

Definition at line 786 of file ktextedit.cpp.

◆ focusOutEvent()

void KTextEdit::focusOutEvent ( QFocusEvent *  ev)
protectedvirtual

Definition at line 1172 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 844 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 741 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
lengthThe length of the selection, in number of characters
posThe position of the first character of the selection

Definition at line 849 of file ktextedit.cpp.

◆ keyPressEvent()

void KTextEdit::keyPressEvent ( QKeyEvent *  event)
protectedvirtual

Reimplemented for internal reasons.

Reimplemented in KRichTextEdit.

Definition at line 1121 of file ktextedit.cpp.

◆ languageChanged

void KTextEdit::languageChanged ( const QString &  language)
signal

Emitted when the user changes the language in the spellcheck dialog shown by checkSpelling() or when calling setSpellCheckingLanguage().

Parameters
languagethe new language the user selected
Since
4.1

◆ mousePopupMenu()

QMenu * KTextEdit::mousePopupMenu ( )

Return standard KTextEdit popupMenu.

Since
4.1

Definition at line 517 of file ktextedit.cpp.

◆ mousePopupMenuImplementation

void KTextEdit::mousePopupMenuImplementation ( const QPoint &  pos)
slot
Since
4.10 Because of binary compatibility constraints, mousePopupMenu() is not virtual. Therefore it must dynamically detect and call this slot.

Definition at line 1182 of file ktextedit.cpp.

◆ paintEvent()

void KTextEdit::paintEvent ( QPaintEvent *  ev)
protectedvirtual

Reimplemented to paint clickMessage.

Definition at line 1152 of file ktextedit.cpp.

◆ replace

void KTextEdit::replace ( )
slot

Create replace dialogbox.

Since
4.1

Definition at line 858 of file ktextedit.cpp.

◆ setCheckSpellingEnabled()

void KTextEdit::setCheckSpellingEnabled ( bool  check)

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().

If a spell interface is set by setSpellInterface(), the call will be delegated to there instead.

See also
checkSpellingEnabled()
isReadOnly()
setReadOnly()

Definition at line 752 of file ktextedit.cpp.

◆ setCheckSpellingEnabledInternal()

void KTextEdit::setCheckSpellingEnabledInternal ( bool  check)
protected

Enable or disable the spellchecking.

This is what setCheckSpellingEnabled() calls if there is no spell interface.

Since
4.2

Definition at line 760 of file ktextedit.cpp.

◆ setClickMessage()

void KTextEdit::setClickMessage ( const QString &  msg)

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.

Since
4.4

Definition at line 1134 of file ktextedit.cpp.

◆ setHighlighter()

void KTextEdit::setHighlighter ( Sonnet::Highlighter *  _highLighter)

Sets a custom backgound 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.

See also
highlighter()
createHighlighter()
Parameters
highLighterthe new highlighter which will be used now

Definition at line 746 of file ktextedit.cpp.

◆ setReadOnly()

void KTextEdit::setReadOnly ( bool  readOnly)
virtual

Reimplemented to set a proper "deactivated" background color.

Definition at line 807 of file ktextedit.cpp.

◆ setSpellCheckingConfigFileName()

void KTextEdit::setSpellCheckingConfigFileName ( const QString &  fileName)

Allows to override the config file where the settings for spell checking, like the current language or encoding, are stored.

By default, the global config file (kdeglobals) is used, to share spell check settings between all applications.

This has to be called before any spell checking is initiated.

Parameters
fileNamethe URL of the config file which will be used to read spell settings
Bug:
this has no effect for the spell dialog, only for the background check

Definition at line 334 of file ktextedit.cpp.

◆ setSpellCheckingLanguage

void KTextEdit::setSpellCheckingLanguage ( const QString &  language)
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 344 of file ktextedit.cpp.

◆ setSpellInterface()

void KTextEdit::setSpellInterface ( KTextEditSpellInterface *  spellInterface)

Sets the spell interface, which is used to delegate certain function calls to the interface.

This is a workaround for binary compatibility and should be removed in KDE5.

Since
4.2

Definition at line 1061 of file ktextedit.cpp.

◆ showAutoCorrectButton()

void KTextEdit::showAutoCorrectButton ( bool  show)
Since
4.10

Definition at line 1177 of file ktextedit.cpp.

◆ showSpellConfigDialog

void KTextEdit::showSpellConfigDialog ( const QString &  configFileName,
const QString &  windowIcon = QString() 
)
slot

Opens a Sonnet::ConfigDialog for this text edit.

The config settings the user makes are read from and stored to the given config file. 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
configFileNameThe file which is used to store and load the config settings
windowIconthe 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 357 of file ktextedit.cpp.

◆ showTabAction()

void KTextEdit::showTabAction ( bool  show)
Since
4.10

Definition at line 1056 of file ktextedit.cpp.

◆ slotDoFind

void KTextEdit::slotDoFind ( )
protectedslot

Definition at line 949 of file ktextedit.cpp.

◆ slotDoReplace

void KTextEdit::slotDoReplace ( )
protectedslot
Since
4.1

Definition at line 873 of file ktextedit.cpp.

◆ slotFind

void KTextEdit::slotFind ( )
protectedslot

Definition at line 1021 of file ktextedit.cpp.

◆ slotFindNext

void KTextEdit::slotFindNext ( )
protectedslot

Definition at line 992 of file ktextedit.cpp.

◆ slotFindPrevious

void KTextEdit::slotFindPrevious ( )
protectedslot
Since
4.14.8

Definition at line 979 of file ktextedit.cpp.

◆ slotReplace

void KTextEdit::slotReplace ( )
protectedslot

Definition at line 1036 of file ktextedit.cpp.

◆ slotReplaceNext

void KTextEdit::slotReplaceNext ( )
protectedslot

Definition at line 907 of file ktextedit.cpp.

◆ slotSpeakText

void KTextEdit::slotSpeakText ( )
protectedslot
Since
4.3

Definition at line 596 of file ktextedit.cpp.

◆ spellCheckerAutoCorrect

void KTextEdit::spellCheckerAutoCorrect ( const QString &  currentWord,
const QString &  autoCorrectWord 
)
signal
Since
4.10

◆ spellCheckingCanceled

void KTextEdit::spellCheckingCanceled ( )
signal

signal spellCheckingCanceled is sent when we cancel spell checking.

Since
4.10

◆ spellCheckingFinished

void KTextEdit::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

Definition at line 339 of file ktextedit.cpp.

◆ spellCheckStatus

void KTextEdit::spellCheckStatus ( const QString &  )
signal

Signal sends when spell checking is finished/stopped/completed.

Since
4.1

◆ wheelEvent()

void KTextEdit::wheelEvent ( QWheelEvent *  event)
protectedvirtual

Reimplemented to allow fast-wheelscrolling with Ctrl-Wheel or zoom.

Definition at line 728 of file ktextedit.cpp.

Property Documentation

◆ checkSpellingEnabled

bool KTextEdit::checkSpellingEnabled
readwrite

Definition at line 68 of file ktextedit.h.

◆ clickMessage

QString KTextEdit::clickMessage
readwrite

Definition at line 68 of file ktextedit.h.

◆ spellCheckingLanguage

QString KTextEdit::spellCheckingLanguage
readwrite

Definition at line 68 of file ktextedit.h.


The documentation for this class was generated from the following files:
  • ktextedit.h
  • ktextedit.cpp
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDEUI

Skip menu "KDEUI"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdelibs-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal