QTextEdit

Section: Misc. Reference Manual Pages (3qt)
Updated: 2 February 2007
Index Return to Main Contents
 

NAME

QTextEdit - Powerful single-page rich text editor  

SYNOPSIS

#include <qtextedit.h>

Inherits QScrollView.

Inherited by QMultiLineEdit, QTextBrowser, and QTextView.

 

Public Members


enum WordWrap { NoWrap, WidgetWidth, FixedPixelWidth, FixedColumnWidth }

enum WrapPolicy { AtWordBoundary, AtWhiteSpace = AtWordBoundary, Anywhere, AtWordOrDocumentBoundary }

enum AutoFormatting { AutoNone = 0, AutoBulletList = 0x00000001, AutoAll = 0xffffffff }

enum KeyboardAction { ActionBackspace, ActionDelete, ActionReturn, ActionKill, ActionWordBackspace, ActionWordDelete }

enum CursorAction { MoveBackward, MoveForward, MoveWordBackward, MoveWordForward, MoveUp, MoveDown, MoveLineStart, MoveLineEnd, MoveHome, MoveEnd, MovePgUp, MovePgDown }

enum VerticalAlignment { AlignNormal, AlignSuperScript, AlignSubScript }

QTextEdit ( const QString & text, const QString & context = QString::null, QWidget * parent = 0, const char * name = 0 )

QTextEdit ( QWidget * parent = 0, const char * name = 0 )

QString text () const

QString text ( int para ) const

TextFormat textFormat () const

QString context () const

QString documentTitle () const

void getSelection ( int * paraFrom, int * indexFrom, int * paraTo, int * indexTo, int selNum = 0 ) const

virtual bool find ( const QString & expr, bool cs, bool wo, bool forward = TRUE, int * para = 0, int * index = 0 )

int paragraphs () const

int lines () const

int linesOfParagraph ( int para ) const

int lineOfChar ( int para, int index )

int length () const

QRect paragraphRect ( int para ) const

int paragraphAt ( const QPoint & pos ) const

int charAt ( const QPoint & pos, int * para ) const

int paragraphLength ( int para ) const

QStyleSheet * styleSheet () const

QMimeSourceFactory * mimeSourceFactory () const

QBrush paper () const

bool linkUnderline () const

virtual int heightForWidth ( int w ) const

bool hasSelectedText () const

QString selectedText () const

bool isUndoAvailable () const

bool isRedoAvailable () const

WordWrap wordWrap () const

int wrapColumnOrWidth () const

WrapPolicy wrapPolicy () const

int tabStopWidth () const

QString anchorAt ( const QPoint & pos )

QString anchorAt ( const QPoint & pos, AnchorAttribute attr )

bool isReadOnly () const

void getCursorPosition ( int * para, int * index ) const

bool isModified () const

bool italic () const

bool bold () const

bool underline () const

QString family () const

int pointSize () const

QColor color () const

QFont font () const (obsolete)

QFont currentFont () const

int alignment () const

int undoDepth () const

bool isOverwriteMode () const

QColor paragraphBackgroundColor ( int para ) const

bool isUndoRedoEnabled () const

bool tabChangesFocus () const

void setAutoFormatting ( uint features )

uint autoFormatting () const

QSyntaxHighlighter * syntaxHighlighter () const
 

Public Slots


virtual void setMimeSourceFactory ( QMimeSourceFactory * factory )

virtual void setStyleSheet ( QStyleSheet * styleSheet )

virtual void scrollToAnchor ( const QString & name )

virtual void setPaper ( const QBrush & pap )

virtual void setLinkUnderline ( bool )

virtual void setWordWrap ( WordWrap mode )

virtual void setWrapColumnOrWidth ( int )

virtual void setWrapPolicy ( WrapPolicy policy )

virtual void copy ()

virtual void append ( const QString & text )

void setText ( const QString & txt )

virtual void setText ( const QString & text, const QString & context )

virtual void setTextFormat ( TextFormat f )

virtual void selectAll ( bool select = TRUE )

virtual void setTabStopWidth ( int ts )

virtual void zoomIn ( int range )

virtual void zoomIn ()

virtual void zoomOut ( int range )

virtual void zoomOut ()

virtual void zoomTo ( int size )

virtual void sync ()

virtual void setReadOnly ( bool b )

virtual void undo ()

virtual void redo ()

virtual void cut ()

virtual void paste ()

virtual void pasteSubType ( const QCString & subtype )

virtual void clear ()

virtual void del ()

virtual void setItalic ( bool b )

virtual void setBold ( bool b )

virtual void setUnderline ( bool b )

virtual void setFamily ( const QString & fontFamily )

virtual void setPointSize ( int s )

virtual void setColor ( const QColor & c )

virtual void setVerticalAlignment ( VerticalAlignment a )

virtual void setAlignment ( int a )

virtual void setCursorPosition ( int para, int index )

virtual void setSelection ( int paraFrom, int indexFrom, int paraTo, int indexTo, int selNum = 0 )

virtual void setSelectionAttributes ( int selNum, const QColor & back, bool invertText )

virtual void setModified ( bool m )

virtual void setUndoDepth ( int d )

virtual void ensureCursorVisible ()

virtual void placeCursor ( const QPoint & pos, QTextCursor * c = 0 )

virtual void moveCursor ( CursorAction action, bool select )

virtual void doKeyboardAction ( KeyboardAction action )

virtual void removeSelectedText ( int selNum = 0 )

virtual void removeSelection ( int selNum = 0 )

virtual void setCurrentFont ( const QFont & f )

virtual void setOverwriteMode ( bool b )

virtual void scrollToBottom ()

void insert ( const QString & text, uint insertionFlags = CheckNewLines | RemoveSelected )

virtual void insert ( const QString & text, bool indent, bool checkNewLine = TRUE, bool removeSelected = TRUE ) (obsolete)

virtual void insertAt ( const QString & text, int para, int index )

virtual void removeParagraph ( int para )

virtual void insertParagraph ( const QString & text, int para )

virtual void setParagraphBackgroundColor ( int para, const QColor & bg )

virtual void clearParagraphBackground ( int para )

virtual void setUndoRedoEnabled ( bool b )

void setTabChangesFocus ( bool b )

void setMaxLogLines ( int limit )

int maxLogLines ()
 

Signals


void textChanged ()

void selectionChanged ()

void copyAvailable ( bool yes )

void undoAvailable ( bool yes )

void redoAvailable ( bool yes )

void currentFontChanged ( const QFont & f )

void currentColorChanged ( const QColor & c )

void currentAlignmentChanged ( int a )

void currentVerticalAlignmentChanged ( VerticalAlignment a )

void cursorPositionChanged ( int para, int pos )

void returnPressed ()

void modificationChanged ( bool m )

void clicked ( int para, int pos )

void doubleClicked ( int para, int pos )
 

Properties


AutoFormatting autoFormatting - the enabled set of auto formatting features

QString documentTitle - the title of the document parsed from the text (read only)

bool hasSelectedText - whether some text is selected in selection 0 (read only)

int length - the number of characters in the text (read only)

bool linkUnderline - whether hypertext links will be underlined

bool modified - whether the document has been modified by the user

bool overwriteMode - the text edit's overwrite mode

QBrush paper - the background (paper) brush

bool readOnly - whether the text edit is read-only

QString selectedText - the selected text (from selection 0) or an empty string if there is no currently selected text (in selection 0) (read only)

bool tabChangesFocus - whether TAB changes focus or is accepted as input

int tabStopWidth - the tab stop width in pixels

QString text - the text edit's text

TextFormat textFormat - the text format: rich text, plain text, log text or auto text

int undoDepth - the depth of the undo history

bool undoRedoEnabled - whether undo/redo is enabled

WordWrap wordWrap - the word wrap mode

int wrapColumnOrWidth - the position (in pixels or columns depending on the wrap mode) where text will be wrapped

WrapPolicy wrapPolicy - the word wrap policy, at whitespace or anywhere
 

Protected Members


void repaintChanged ()

virtual void keyPressEvent ( QKeyEvent * e )

virtual bool focusNextPrevChild ( bool n )

QTextCursor * textCursor () const

virtual QPopupMenu * createPopupMenu ( const QPoint & pos )

virtual QPopupMenu * createPopupMenu () (obsolete)
 

DESCRIPTION

The QTextEdit widget provides a powerful single-page rich text editor.

Introduction and Concepts
Using QTextEdit as a Display Widget
Read-only key bindings
Using QTextEdit in LogText Mode
Using QTextEdit as an Editor

 Editing key bindings

 

Introduction and Concepts

QTextEdit is an advanced WYSIWYG viewer/editor supporting rich text formatting using HT