KDE 4.5 PyKDE API Reference
  • KDE's Python API
  • Overview
  • PyKDE Home
  • Sitemap
  • Contact Us
 

KTextEdit Class Reference

from PyKDE4.kdeui import *

Inherits: QTextEdit → QAbstractScrollArea → QFrame → QWidget → QObject
Subclasses: KRichTextEdit

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 <pfeiffer@kde.org>


Signals

 aboutToShowContextMenu (QMenu menu)
 checkSpellingChanged (bool a0)
 languageChanged (QString language)
 spellCheckStatus (QString a0)

Methods

 __init__ (self, QString text, QWidget parent=0)
 __init__ (self, QWidget parent=0)
 checkSpelling (self)
bool checkSpellingEnabled (self)
bool checkSpellingEnabledInternal (self)
QString clickMessage (self)
 contextMenuEvent (self, QContextMenuEvent a0)
 createHighlighter (self)
 deleteWordBack (self)
 deleteWordForward (self)
 enableFindReplace (self, bool enabled)
bool event (self, QEvent a0)
 focusInEvent (self, QFocusEvent a0)
 focusOutEvent (self, QFocusEvent a0)
 highlightWord (self, int length, int pos)
Sonnet.Highlighter highlighter (self)
 keyPressEvent (self, QKeyEvent a0)
QMenu mousePopupMenu (self)
 paintEvent (self, QPaintEvent a0)
 replace (self)
 setCheckSpellingEnabled (self, bool check)
 setCheckSpellingEnabledInternal (self, bool check)
 setClickMessage (self, QString msg)
 setHighlighter (self, Sonnet.Highlighter _highLighter)
 setReadOnly (self, bool readOnly)
 setSpellCheckingConfigFileName (self, QString fileName)
 setSpellCheckingLanguage (self, QString language)
 setSpellInterface (self, KTextEditSpellInterface spellInterface)
 showSpellConfigDialog (self, QString configFileName, QString windowIcon=QString())
 slotDoFind (self)
 slotDoReplace (self)
 slotFind (self)
 slotFindNext (self)
 slotReplace (self)
 slotReplaceNext (self)
 slotSpeakText (self)
QString spellCheckingLanguage (self)
 wheelEvent (self, QWheelEvent a0)

Signal Documentation

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.

Parameters:
p  the context menu about to be displayed

Since:
4.5

Signal syntax:
QObject.connect(source, SIGNAL("aboutToShowContextMenu(QMenu*)"), target_slot)
checkSpellingChanged ( bool  a0
)

emit signal when we activate or not autospellchecking

Since:
4.1

Signal syntax:
QObject.connect(source, SIGNAL("checkSpellingChanged(bool)"), target_slot)
languageChanged ( QString  language
)

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

Signal syntax:
QObject.connect(source, SIGNAL("languageChanged(const QString&)"), target_slot)
spellCheckStatus ( QString  a0
)

Signal sends when spell checking is finished/stopped/completed

Since:
4.1

Signal syntax:
QObject.connect(source, SIGNAL("spellCheckStatus(const QString&)"), target_slot)

Method Documentation

__init__ (  self,
QString  text,
QWidget  parent=0
)

Constructs a KTextEdit object. See QTextEdit.QTextEdit for details.

__init__ (  self,
QWidget  parent=0
)

Constructs a KTextEdit object. See QTextEdit.QTextEdit for details.

checkSpelling (   self )

Show a dialog to check the spelling. The spellCheckStatus() signal will be emitted when the spell checking dialog is closed.

bool checkSpellingEnabled (   self )

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

bool checkSpellingEnabledInternal (   self )

Checks whether spellchecking is enabled or disabled. This is what checkSpellingEnabled calls if there is no spell interface.

Since:
4.2

QString clickMessage (   self )

Returns:
the message set with setClickMessage
Since:
4.4

contextMenuEvent (  self,
QContextMenuEvent  a0
)

Reimplemented from QTextEdit to add spelling related items when appropriate.

createHighlighter (   self )

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()
See also:
highlighter()
See also:
setSpellCheckingConfigFileName()

deleteWordBack (   self )

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

deleteWordForward (   self )

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

enableFindReplace (  self,
bool  enabled
)

Enable find replace action.

Since:
4.1

bool event (  self,
QEvent  a0
)

Reimplemented to catch "delete word" shortcut events.

focusInEvent (  self,
QFocusEvent  a0
)

Reimplemented to instantiate a KDictSpellingHighlighter, if spellchecking is enabled.

focusOutEvent (  self,
QFocusEvent  a0
)
highlightWord (  self,
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

Sonnet.Highlighter highlighter (   self )

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()
See also:
createHighlighter()

keyPressEvent (  self,
QKeyEvent  a0
)

Reimplemented for internal reasons

QMenu mousePopupMenu (   self )

Return standard KTextEdit popupMenu

Since:
4.1

paintEvent (  self,
QPaintEvent  a0
)

Reimplemented to paint clickMessage.

replace (   self )

Create replace dialogbox

Since:
4.1

setCheckSpellingEnabled (  self,
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()
See also:
isReadOnly()
See also:
setReadOnly()

setCheckSpellingEnabledInternal (  self,
bool  check
)

Enable or disable the spellchecking. This is what setCheckSpellingEnabled() calls if there is no spell interface.

Since:
4.2

setClickMessage (  self,
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

setHighlighter (  self,
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()
See also:
createHighlighter()

Parameters:
highLighter  the new highlighter which will be used now

setReadOnly (  self,
bool  readOnly
)

Reimplemented to set a proper "deactivated" background color.

setSpellCheckingConfigFileName (  self,
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:
fileName  the 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

setSpellCheckingLanguage (  self,
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.

Since:
4.1

setSpellInterface (  self,
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

showSpellConfigDialog (  self,
QString  configFileName,
QString  windowIcon=QString()
)

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

slotDoFind (   self )
slotDoReplace (   self )

Since:
4.1

slotFind (   self )
slotFindNext (   self )
slotReplace (   self )
slotReplaceNext (   self )
slotSpeakText (   self )

Since:
4.3

QString spellCheckingLanguage (   self )

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

wheelEvent (  self,
QWheelEvent  a0
)

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

  • Full Index

Modules

  • akonadi
  • dnssd
  • kdecore
  • kdeui
  • khtml
  • kio
  • knewstuff
  • kparts
  • kutils
  • nepomuk
  • phonon
  • plasma
  • polkitqt
  • solid
  • soprano
This documentation is maintained by Simon Edwards.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal