QTextEdit(3qt)
QTextEdit(3qt) π β¨
okay bestie, welcome to the QTextEdit(3qt) manual page. this is the whole vibe: a powerful single-page rich text editor. no cap. let's get into it.
NAME π
QTextEdit β Powerful single-page rich text editor.
SYNOPSIS π¦
#include <qtextedit.h>
Inherits QScrollView.
Inherited by QMultiLineEdit, QTextBrowser, and QTextView.
lowkey, here's every single member, slot, signal, property, and protected member. we're not skipping anything, fr fr.
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 () constQString text ( int para ) constTextFormat textFormat () constQString context () constQString documentTitle () constvoid getSelection ( int * paraFrom, int * indexFrom, int * paraTo, int * indexTo, int selNum = 0 ) constvirtual bool find ( const QString & expr, bool cs, bool wo, bool forward = TRUE, int * para = 0, int * index = 0 )int paragraphs () constint lines () constint linesOfParagraph ( int para ) constint lineOfChar ( int para, int index )int length () constQRect paragraphRect ( int para ) constint paragraphAt ( const QPoint & pos ) constint charAt ( const QPoint & pos, int * para ) constint paragraphLength ( int para ) constQStyleSheet * styleSheet () constQMimeSourceFactory * mimeSourceFactory () constQBrush paper () constbool linkUnderline () constvirtual int heightForWidth ( int w ) constbool hasSelectedText () constQString selectedText () constbool isUndoAvailable () constbool isRedoAvailable () constWordWrap wordWrap () constint wrapColumnOrWidth () constWrapPolicy wrapPolicy () constint tabStopWidth () constQString anchorAt ( const QPoint & pos )QString anchorAt ( const QPoint & pos, AnchorAttribute attr )bool isReadOnly () constvoid getCursorPosition ( int * para, int * index ) constbool isModified () constbool italic () constbool bold () constbool underline () constQString family () constint pointSize () constQColor color () constQFont font () const (obsolete)QFont currentFont () constint alignment () constint undoDepth () constbool isOverwriteMode () constQColor paragraphBackgroundColor ( int para ) constbool isUndoRedoEnabled () constbool tabChangesFocus () constvoid setAutoFormatting ( uint features )uint autoFormatting () constQSyntaxHighlighter * 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 () constvirtual QPopupMenu * createPopupMenu ( const QPoint & pos )virtual QPopupMenu * createPopupMenu () (obsolete)
DESCRIPTION πΈ
The QTextEdit widget provides a powerful single-page rich text editor. it's giving main character energy, periodt.
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 β¨
okay so bestie, QTextEdit is an advanced WYSIWYG viewer/editor that supports rich text formatting using HTML-style tags. It is optimized to handle large documents and to respond quickly to user input. π
QTextEdit has four modes of operation: <center>.nf </center> β and yes, there's a footnote: a more complete API that supports setting margins, images, etc., is planned for a later Qt release. π
QTextEdit can be used as a syntax highlighting editor when used in conjunction with QSyntaxHighlighter. β¨
We recommend that you always call setTextFormat() to set the mode you want to use. If you use AutoText then setText() and append() will try to determine whether the text they are given is plain text or rich text. If you use RichText then setText() and append() will assume that the text they are given is rich text. insert() simply inserts the text it is given. π
QTextEdit works on paragraphs and characters. A paragraph is a formatted string which is word-wrapped to fit into the width of the widget. By default when reading plain text, one newline signify a paragraph. A document consists of zero or more paragraphs, indexed from 0. Characters are indexed on a per-paragraph basis, also indexed from 0. The words in the paragraph are aligned in accordance with the paragraph's alignment(). Paragraphs are separated by hard line breaks. Each character within a paragraph has its own attributes, for example, font and color. πΈ
The text edit documentation uses the following concepts:
- current format β this is the format at the current cursor position, and it is the format of the selected text if any.
- current paragraph β the paragraph which contains the cursor.
QTextEdit can display images (using QMimeSourceFactory), lists and tables. If the text is too large to view within the text edit's viewport, scrollbars will appear. The text edit can load both plain text and HTML files (a subset of HTML 3.2 and 4). The rendering style and the set of valid tags are defined by a styleSheet(). Custom tags can be created and placed in a custom style sheet. Change the style sheet with setStyleSheet(); see QStyleSheet for details. The images identified by image tags are displayed if they can be interpreted using the text edit's QMimeSourceFactory; see setMimeSourceFactory(). π¦
If you want a text browser with more navigation use QTextBrowser. If you just need to display a small piece of rich text use QLabel or QSimpleRichText. π
If you create a new QTextEdit, and want to allow the user to edit rich text, call setTextFormat(Qt::RichText) to ensure that the text is treated as rich text. (Rich text uses HTML tags to set text formatting attributes. See QStyleSheet for information on the HTML tags that are supported.). If you don't call setTextFormat() explicitly the text edit will guess from the text itself whether it is rich text or plain text. This means that if the text looks like HTML or XML it will probably be interpreted as rich text, so you should call setTextFormat(Qt::PlainText) to preserve such text. π
Note that we do not intend to add a full-featured web browser widget to Qt (because that would easily double Qt's size and only a few applications would benefit from it). The rich text support in Qt is designed to provide a fast, portable and efficient way to add reasonable online help facilities to applications, and to provide a basis for rich text editors. π«Ά
π Using QTextEdit as a Display Widget π
QTextEdit can display a large HTML subset, including tables and images. π
The text is set or replaced using setText() which deletes any existing text and replaces it with the text passed in the setText() call. If you call setText() with legacy HTML (with setTextFormat(RichText) in force), and then call text(), the text that is returned may have different markup, but will render the same. Text can be inserted with insert(), paste(), pasteSubType() and append(). Text that is appended does not go into the undo history; this makes append() faster and consumes less memory. Text can also be cut(). The entire text is deleted with clear() and the selected text is deleted with removeSelectedText(). Selected (marked) text can also be deleted with del() (which will delete the character to the right of the cursor if no text is selected). β¨
Loading and saving text is achieved using setText() and text(), for example:
QFile file( fileName ); // Read the text from a file
if ( file.open( IO_ReadOnly ) ) {
QTextStream stream( &file );
textEdit->setText( stream.read() );
}
QFile file( fileName ); // Write the text to a file
if ( file.open( IO_WriteOnly ) ) {
QTextStream stream( &file );
stream << textEdit->text();
textEdit->setModified( FALSE );
}
By default the text edit wraps words at whitespace to fit within the text edit widget. The setWordWrap() function is used to specify the kind of word wrap you want, or NoWrap if you don't want any wrapping. Call setWordWrap() to set a fixed pixel width FixedPixelWidth, or character column (e.g. 80 column) FixedColumnWidth with the pixels or columns specified with setWrapColumnOrWidth(). If you use word wrap to the widget's width WidgetWidth, you can specify whether to break on whitespace or anywhere with setWrapPolicy(). π
The background color is set differently than other widgets, using setPaper(). You specify a brush style which could be a plain color or a complex pixmap. π¨
Hypertext links are automatically underlined; this can be changed with setLinkUnderline(). The tab stop width is set with setTabStopWidth(). π
The zoomIn() and zoomOut() functions can be used to resize the text by increasing (decreasing for zoomOut()) the point size used. Images are not affected by the zoom functions. π
The lines() function returns the number of lines in the text and paragraphs() returns the number of paragraphs. The number of lines within a particular paragraph is returned by linesOfParagraph(). The length of the entire text in characters is returned by length(). π
You can scroll to an anchor in the text, e.g. <a name="anchor"> with scrollToAnchor(). The find() function can be used to find and select a given string within the text. π
A read-only QTextEdit provides the same functionality as the (obsolete) QTextView. (QTextView is still supplied for compatibility with old code.) π
π Read-only key bindings π
When QTextEdit is used read-only the key-bindings are limited to navigation, and text may only be selected with the mouse: <center>.nf </center> π±οΈ
The text edit may be able to provide some meta-information. For example, the documentTitle() function will return the text from within HTML <title> tags. π
The text displayed in a text edit has a context. The context is a path which the text edit's QMimeSourceFactory uses to resolve the locations of files and images. It is passed to the mimeSourceFactory() when querying data. (See QTextEdit() and context().) π
πͺ΅ Using QTextEdit in LogText Mode πͺ΅
Setting the text format to LogText puts the widget in a special mode which is optimized for very large texts. Editing, word wrap, and rich text support are disabled in this mode (the widget is explicitly made read-only). This allows the text to be stored in a different, more memory efficient manner. However, a certain degree of text formatting is supported through the use of formatting tags. A tag is delimited by < and >. The characters <, > and & are escaped by using <, > and &. A tag pair consists of a left and a right tag (or open/close tags). Left-tags mark the starting point for formatting, while right-tags mark the ending point. A right-tag always starts with a / before the tag keyword. For example <b> and </b> are a tag pair. Tags can be nested, but they have to be closed in the same order as they are opened. For example, <b><u></u></b> is valid, while <b><u></b></u> will output an error message. β οΈ
By using tags it is possible to change the color, bold, italic and underline settings for a piece of text. A color can be specified by using the HTML font tag <font color=colorname>. The color name can be one of the color names from the X11 color database, or a RGB hex value (e.g #00ff00). Example of valid color tags: <font color=red>, <font color="light blue">, <font color="#223344">. Bold, italic and underline settings can be specified by the tags <b>, <i> and <u>. Note that a tag does not necessarily have to be closed. A valid example:
This is <font color=red>red</font> while <b>this</b> is <font color=blue>blue</font>.
<font color=green><font color=yellow>Yellow,</font> and <u>green</u>.
Stylesheets can also be used in LogText mode. To create and use a custom tag, you could do the following:
QTextEdit * log = new QTextEdit( this );
log->setTextFormat( Qt::LogText );
QStyleSheetItem * item = new QStyleSheetItem( log->styleSheet(), "mytag" );
item->setColor( "red" );
item->setFontWeight( QFont::Bold );
item->setFontUnderline( TRUE );
log->append( "This is a <mytag>custom tag</mytag>!" );
Note that only the color, bold, underline and italic attributes of a QStyleSheetItem is used in LogText mode. π
Note that you can use setMaxLogLines() to limit the number of lines the widget can hold in LogText mode. π
There are a few things that you need to be aware of when the widget is in this mode:
- Functions that deal with rich text formatting and cursor movement will not work or return anything valid. π«
- Lines are equivalent to paragraphs. π
β¨ Using QTextEdit as an Editor β¨
Okay so literally every single thing we just said about using QTextEdit as a display widget? Still applies here bestie. All of it. No cap. π
You set the current format's attributes with setItalic(), setBold(), setUnderline(), setFamily() (that's font family obvi), setPointSize(), setColor() and setCurrentFont(). And the current paragraph's alignment? That's setAlignment(). Slay. π
Use setSelection() to select text. The setSelectionAttributes() function is what you use to indicate how selected text should be displayed. Use hasSelectedText() to find out if any text is selected at all. The currently selected text's position is available using getSelection(), and the selected text itself is returned by selectedText(). The selection can be copied to the clipboard with copy(), or cut to the clipboard with cut(). It can be deleted with removeSelectedText(). The entire text can be selected (or unselected) using selectAll(). QTextEdit supports multiple selections β iconique β and most of the selection functions operate on the default selection, selection 0. If the user presses a non-selecting key, e.g. a cursor key without also holding down Shift, all selections are cleared. π
Set and get the position of the cursor with setCursorPosition() and getCursorPosition() respectively. When the cursor is moved, the signals currentFontChanged(), currentColorChanged() and currentAlignmentChanged() are emitted to reflect the font, color and alignment at the new cursor position. The widget is literally telling you what vibe the cursor is in. π¦
If the text changes, the textChanged() signal is emitted, and if the user inserts a new line by pressing Return or Enter, returnPressed() is emitted. The isModified() function will return TRUE if the text has been modified.
QTextEdit provides command-based undo and redo. To set the depth of the command history use setUndoDepth(), which defaults to 100 steps. To undo or redo the last operation call undo() or redo(). The signals undoAvailable() and redoAvailable() indicate whether the undo and redo operations can be executed. π«Ά
The indent() function is used to reindent a paragraph. It is useful for code editors β for example, in Qt Designer's code editor, Ctrl+I invokes the indent() function. Main character behaviour fr fr.
Editing key bindings πΈ
The list of key-bindings which are implemented for editing: <center>.nf </center> β yeah bestie, that's the raw markup the docs dropped in place of a table, and it renders empty. The list lives right here, promise. π
To select (mark) text, hold down the Shift key whilst pressing one of the movement keystrokes β for example, Shift+Right Arrow will select the character to the right, and Shift+Ctrl+Right Arrow will select the word to the right, etc.
By default the text edit widget operates in insert mode, so all text that the user enters is inserted into the text edit and any text to the right of the cursor is moved out of the way. The mode can be changed to overwrite, where new text overwrites any text to the right of the cursor, using setOverwriteMode().
See also Basic Widgets and Text Related Classes.
π§ Member Type Documentation π§
QTextEdit::AutoFormatting
QTextEdit::AutoNoneβ Do not perform any automatic formattingQTextEdit::AutoBulletListβ Only automatically format bulletted listsQTextEdit::AutoAllβ Apply all available autoformatting
QTextEdit::CursorAction
This enum is used by moveCursor() to specify in which direction the cursor should be moved:
QTextEdit::MoveBackwardβ Moves the cursor one character backwardQTextEdit::MoveWordBackwardβ Moves the cursor one word backwardQTextEdit::MoveForwardβ Moves the cursor one character forwardQTextEdit::MoveWordForwardβ Moves the cursor one word forwardQTextEdit::MoveUpβ Moves the cursor up one lineQTextEdit::MoveDownβ Moves the cursor down one lineQTextEdit::MoveLineStartβ Moves the cursor to the beginning of the lineQTextEdit::MoveLineEndβ Moves the cursor to the end of the lineQTextEdit::MoveHomeβ Moves the cursor to the beginning of the documentQTextEdit::MoveEndβ Moves the cursor to the end of the documentQTextEdit::MovePgUpβ Moves the cursor one viewport page upQTextEdit::MovePgDownβ Moves the cursor one viewport page down
QTextEdit::KeyboardAction
This enum is used by doKeyboardAction() to specify which action should be executed:
QTextEdit::ActionBackspaceβ Delete the character to the left of the cursor.QTextEdit::ActionDeleteβ Delete the character to the right of the cursor.QTextEdit::ActionReturnβ Split the paragraph at the cursor position.QTextEdit::ActionKillβ If the cursor is not at the end of the paragraph, delete the text from the cursor position until the end of the paragraph. If the cursor is at the end of the paragraph, delete the hard line break at the end of the paragraph: this will cause this paragraph to be joined with the following paragraph.QTextEdit::ActionWordBackspaceβ Delete the word to the left of the cursor position.QTextEdit::ActionWordDeleteβ Delete the word to the right of the cursor position
QTextEdit::VerticalAlignment
This enum is used to set the vertical alignment of the text.
QTextEdit::AlignNormalβ Normal alignmentQTextEdit::AlignSuperScriptβ SuperscriptQTextEdit::AlignSubScriptβ Subscript
QTextEdit::WordWrap
This enum defines the QTextEdit's word wrap modes.
QTextEdit::NoWrapβ Do not wrap the text.QTextEdit::WidgetWidthβ Wrap the text at the current width of the widget (this is the default). Wrapping is at whitespace by default; this can be changed withsetWrapPolicy().QTextEdit::FixedPixelWidthβ Wrap the text at a fixed number of pixels from the widget's left side. The number of pixels is set withwrapColumnOrWidth().QTextEdit::FixedColumnWidthβ Wrap the text at a fixed number of character columns from the widget's left side. The number of characters is set withwrapColumnOrWidth(). This is useful if you need formatted text that can also be displayed gracefully on devices with monospaced fonts β for example a standard VT100 terminal, where you might setwrapColumnOrWidth()to 80.
See also wordWrap and wordWrap.
QTextEdit::WrapPolicy
This enum defines where text can be wrapped in word wrap mode.
QTextEdit::AtWhiteSpaceβ Don't use this deprecated value (it is a synonym for AtWordBoundary which you should use instead).QTextEdit::Anywhereβ Break anywhere, including within words.QTextEdit::AtWordBoundaryβ Break lines at word boundaries, e.g. spaces or newlinesQTextEdit::AtWordOrDocumentBoundaryβ Break lines at whitespace, e.g. spaces or newlines if possible. Break it anywhere otherwise.
See also wrapPolicy.
π¨ Bestie heads up:QTextEdit::AtWhiteSpaceis deprecated. Don't use it, useAtWordBoundaryinstead. Periodt.
π MEMBER FUNCTION DOCUMENTATION π
QTextEdit::QTextEdit ( const QString & text, const QString & context = QString::null, QWidget * parent = 0, const char * name = 0 )
Constructs a QTextEdit called name, with parent parent. The text edit will display the text text using context context.
The context is a path which the text edit's QMimeSourceFactory uses to resolve the locations of files and images. It is passed to the mimeSourceFactory() when quering data.
For example, if the text contains an image tag, <img src="image.png">, and the context is "path/to/look/in", the QMimeSourceFactory will try to load the image from " path/to/look/in/image.png". If the tag was <img src="/image.png">, the context will not be used (because QMimeSourceFactory recognizes that we have used an absolute path) and will try to load "/image.png". The context is applied in exactly the same way to hrefs β for example, <a href="target.html">Target</a>, would resolve to " path/to/look/in/target.html". π
QTextEdit::QTextEdit ( QWidget * parent = 0, const char * name = 0 )
Constructs an empty QTextEdit called name, with parent parent.
int QTextEdit::alignment () const
Returns the alignment of the current paragraph.
See also setAlignment().
QString QTextEdit::anchorAt ( const QPoint & pos, AnchorAttribute attr )
If there is an anchor at position pos (in contents coordinates), the text for attribute attr is returned, otherwise QString::null is returned.
QString QTextEdit::anchorAt ( const QPoint & pos )
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
If there is an anchor at position pos (in contents coordinates), its href is returned, otherwise QString::null is returned.
void QTextEdit::append ( const QString & text ) [virtual slot]
Appends a new paragraph with text to the end of the text edit. Note that the undo/redo history is cleared by this function, and no undo history is kept for appends which makes them faster than insert()s. If you want to append text which is added to the undo/redo history as well, use insertParagraph().
Examples:
uint QTextEdit::autoFormatting () const
Returns the enabled set of auto formatting features. See the "autoFormatting" property for details.
bool QTextEdit::bold () const
Returns TRUE if the current format is bold; otherwise returns FALSE.
See also setBold().
int QTextEdit::charAt ( const QPoint & pos, int * para ) const
Returns the index of the character (relative to its paragraph) at position pos (in contents coordinates). If para is not 0, *para is set to the character's paragraph.
void QTextEdit::clear () [virtual slot]
Deletes all the text in the text edit.
See also cut(), removeSelectedText(), and text.
void QTextEdit::clearParagraphBackground ( int para ) [virtual slot]
Clears the background color of the paragraph para, so that the default color is used again.
void QTextEdit::clicked ( int para, int pos ) [signal]
This signal is emitted when the mouse is clicked on the paragraph para at character position pos.
See also doubleClicked().
QColor QTextEdit::color () const
Returns the color of the current format.
See also setColor() and paper.
QString QTextEdit::context () const
Returns the context of the text edit. The context is a path which the text edit's QMimeSourceFactory uses to resolve the locations of files and images.
See also text.
Examples:
void QTextEdit::copy () [virtual slot]
Copies any selected text (from selection 0) to the clipboard.
See also hasSelectedText and copyAvailable().
void QTextEdit::copyAvailable ( bool yes ) [signal]
This signal is emitted when text is selected or de-selected in the text edit.
When text is selected this signal will be emitted with yes set to TRUE. If no text has been selected or if the selected text is de-selected this signal is emitted with yes set to FALSE.
If yes is TRUE then copy() can be used to copy the selection to the clipboard. If yes is FALSE then copy() does nothing.
See also selectionChanged().
QPopupMenu * QTextEdit::createPopupMenu ( const QPoint & pos ) [virtual protected]
So this one gets called whenever somebody right-clicks, bestie β it's the thing that builds the right mouse button popup menu at the document position pos. π±οΈ
Wanna make your own custom menu? Go off. Reimplement this function and return the popup menu you cooked up. Heads up though: ownership of the popup menu is transferred to the caller, so don't go deleting it yourself later. π
β οΈ Warning: TheQPopupMenuID values0-7are reserved, and they map to the standard operations. So when you're inserting items into your custom popup menu, be sure to specify ID values larger than 7. No cap, if you don't, things get messy. π
QPopupMenu * QTextEdit::createPopupMenu () [virtual protected]
This is an overloaded member function, provided for convenience. It behaves essentially like the above function. π«Ά
π« This function is obsolete. It is provided to keep old source working. We strongly advise against using it in new code.
It's the one that gets called to create a right mouse button popup menu. If you want a custom popup menu, reimplement this function and return the created popup menu. Ownership of the popup menu is transferred to the caller, same as always. β¨
And here's the little quirk: this function is only called if createPopupMenu( const QPoint & ) returns 0. So it's the backup dancer. π
void QTextEdit::currentAlignmentChanged ( int a ) [signal]
This signal fires when the alignment of the current paragraph has changed, bestie. π
The new alignment is a.
See also setAlignment().
void QTextEdit::currentColorChanged ( const QColor & c ) [signal]
Emitted when the color of the current format has changed. π¨β¨
The new color is c.
See also setColor().
QFont QTextEdit::currentFont () const
Hands you back the font of the current format. Simple as that, periodt. π€
See also setCurrentFont(), setFamily(), and setPointSize().
void QTextEdit::currentFontChanged ( const QFont & f ) [signal]
This signal is emitted if the font of the current format has changed. ποΈ
The new font is f.
See also setCurrentFont().
void QTextEdit::currentVerticalAlignmentChanged ( VerticalAlignment a ) [signal]
Emitted when the vertical alignment of the current format has changed. β¬οΈβ¬οΈ
The new vertical alignment is a.
See also setVerticalAlignment().
void QTextEdit::cursorPositionChanged ( int para, int pos ) [signal]
This one fires if the position of the cursor has changed. π para contains the paragraph index and pos contains the character position within the paragraph.
See also setCursorPosition().
void QTextEdit::cut () [virtual slot]
Copies the selected text (from selection 0) to the clipboard and deletes it from the text edit. βοΈπ
If there is no selected text (in selection 0) nothing happens. Yeah, it just vibes. π
See also QTextEdit::copy(), paste(), and pasteSubType().
void QTextEdit::del () [virtual slot]
If there's some selected text (in selection 0) it is deleted. If there's no selected text (in selection 0), the character to the right of the text cursor gets deleted. ποΈ
See also removeSelectedText() and cut().
void QTextEdit::doKeyboardAction ( KeyboardAction action ) [virtual slot]
Executes keyboard action action. Normally this is called by a key event handler, so like, it's the middleman. β¨οΈβ¨
QString QTextEdit::documentTitle () const
Returns the title of the document parsed from the text. See the "documentTitle" property for details. ππ
void QTextEdit::doubleClicked ( int para, int pos ) [signal]
This signal is emitted when the mouse is double-clicked on the paragraph para at character position pos. π±οΈπ±οΈπ₯
See also clicked().
void QTextEdit::ensureCursorVisible () [virtual slot]
Ensures that the cursor is visible by scrolling the text edit if necessary. So your cursor is never lost in the sauce. πβ¨
See also setCursorPosition().
QString QTextEdit::family () const
Returns the font family of the current format. ποΈ
See also setFamily(), setCurrentFont(), and setPointSize().
bool QTextEdit::find ( const QString & expr, bool cs, bool wo, bool forward = TRUE, int * para = 0, int * index = 0 ) [virtual]
Okay bestie, this one's the search function and she does a LOT. ππ
Finds the next occurrence of the string, expr. Returns TRUE if expr was found; otherwise returns FALSE.
If para and index are both 0 the search begins from the current cursor position. If para and index are both not 0, the search begins from the *index character position in the *para paragraph.
If cs is TRUE the search is case sensitive, otherwise it is case insensitive. If wo is TRUE the search looks for whole word matches only; otherwise it searches for any matching text. If forward is TRUE (the default) the search works forward from the starting position to the end of the text, otherwise it works backwards to the beginning of the text. β©βͺ
If expr is found the function returns TRUE. If index and para are not 0, the number of the paragraph in which the first character of the match was found is put into *para, and the index position of that character within the paragraph is put into *index.
If expr is not found the function returns FALSE. If index and para are not 0 and expr is not found, *index and *para are undefined. π
π Please note that this function will make the next occurrence of the string (if found) the current selection, and will thus modify the cursor position.
β οΈ Using theparaandindexparameters will not work correctly in case the document contains tables. Fr fr, just know that.
bool QTextEdit::focusNextPrevChild ( bool n ) [virtual protected]
Reimplemented to allow tabbing through links. πβ¨ If n is TRUE the tab moves the focus to the next child; if n is FALSE the tab moves the focus to the previous child. Returns TRUE if the focus was moved; otherwise returns FALSE.
QFont QTextEdit::font () const
π« This function is obsolete. It is provided to keep old source working. We strongly advise against using it in new code.
Returns QScrollView::font()
β οΈ Warning: In previous versions this function returned the font of the current format. This lead to confusion. Please use currentFont() instead. Like, save yourself the heartbreak, bestie. π
Example: qwerty/qwerty.cpp.
void QTextEdit::getCursorPosition ( int * para, int * index ) const
This function sets the *para and *index parameters to the current cursor position. para and index must not be 0. π
See also setCursorPosition().
void QTextEdit::getSelection ( int * paraFrom, int * indexFrom, int * paraTo, int * indexTo, int selNum = 0 ) const
If there's a selection, *paraFrom is set to the number of the paragraph in which the selection begins and *paraTo is set to the number of the paragraph in which the selection ends. (They could be the same, no drama.) *indexFrom is set to the index at which the selection begins within *paraFrom, and *indexTo is set to the index at which the selection ends within *paraTo. β¨
If there is no selection, *paraFrom, *indexFrom, *paraTo and *indexTo are all set to -1.
If paraFrom, indexFrom, paraTo or indexTo is 0 this function does nothing. Nada. π«₯
The selNum is the number of the selection (multiple selections are supported). It defaults to 0 (the default selection).
See also setSelection() and selectedText.
bool QTextEdit::hasSelectedText () const
Returns TRUE if some text is selected in selection 0; otherwise returns FALSE. See the "hasSelectedText" property for details. π
int QTextEdit::heightForWidth ( int w ) const [virtual]
Returns how many pixels high the text edit needs to be to display all the text if the text edit is w pixels wide. π
Reimplemented from QWidget.
void QTextEdit::insert ( const QString & text, uint insertionFlags = CheckNewLines | RemoveSelected ) [slot]
Inserts text at the current cursor position. β¨οΈβ¨
The insertionFlags define how the text is inserted:
- If
RedoIndentationis set, the paragraph is re-indented. - If
CheckNewLinesis set, newline characters intextresult in hard line breaks (i.e. new paragraphs). - If
checkNewLineis not set, the behaviour of the editor is undefined if the text contains newlines. π (It is not possible to changeQTextEdit's newline handling behavior, but you can useQString::replace()to preprocesstextbefore inserting it.) - If
RemoveSelectedis set, any selected text (in selection0) is removed before the text is inserted.
The default flags are CheckNewLines | RemoveSelected.
If the widget is in LogText mode this function will do nothing. π«₯
See also paste() and pasteSubType().
void QTextEdit::insert ( const QString & text, bool indent, bool checkNewLine = TRUE, bool removeSelected = TRUE ) [virtual slot]
π« This function is obsolete. It is provided to keep old source working. We strongly advise against using it in new code.
void QTextEdit::insertAt ( const QString & text, int para, int index ) [virtual slot]
Inserts text in the paragraph para at position index. π―
void QTextEdit::insertParagraph ( const QString & text, int para ) [virtual slot]
Inserts text as a new paragraph at position para. If para is -1, the text is appended. π
Use append() if the append operation is performance critical β she's the speedier sister. πβοΈπ¨
bool QTextEdit::isModified () const
Returns TRUE if the document has been modified by the user; otherwise returns FALSE. See the "modified" property for details. βοΈ
bool QTextEdit::isOverwriteMode () const
Returns the text edit's overwrite mode. See the "overwriteMode" property for details. β¨οΈ
bool QTextEdit::isReadOnly () const
Returns TRUE if the text edit is read-only; otherwise returns FALSE. See the "readOnly" property for details. π
bool QTextEdit::isRedoAvailable () const
Returns TRUE if redo is available; otherwise returns FALSE. β©οΈ
bool QTextEdit::isUndoAvailable () const
Returns TRUE if undo is available; otherwise returns FALSE. βͺοΈ
bool QTextEdit::isUndoRedoEnabled () const
Returns TRUE if undo/redo is enabled; otherwise returns FALSE. See the "undoRedoEnabled" property for details. π
bool QTextEdit::italic () const
Returns TRUE if the current format is italic; otherwise returns FALSE. slanted vibes β¨
See also setItalic().
void QTextEdit::keyPressEvent ( QKeyEvent * e ) [virtual protected]
Processes the key event, e. By default key events are used to provide keyboard navigation and text editing. β¨οΈπ
Reimplemented from QWidget.
Reimplemented in QTextBrowser.
int QTextEdit::length () const
Returns the number of characters in the text. See the "length" property for details. π’
int QTextEdit::lineOfChar ( int para, int index )
Returns the line number of the line in paragraph para in which the character at position index appears. The index position is relative to the beginning of the paragraph. If there is no such paragraph or no such character at the index position (e.g. the index is out of range) -1 is returned. π
int QTextEdit::lines () const
Returns the number of lines in the text edit; this could be 0. π
β οΈ Warning: This function may be slow. Lines change all the time during word wrapping, so this function has to iterate over all the paragraphs and get the number of lines from each one individually. She's doing her best, okay?? π
int QTextEdit::linesOfParagraph ( int para ) const
Returns the number of lines in paragraph para, or -1 if there is no paragraph with index para. π’
bool QTextEdit::linkUnderline () const
Returns TRUE if hypertext links will be underlined; otherwise returns FALSE. See the "linkUnderline" property for details. πβ¨
πΈ int QTextEdit::maxLogLines () [slot] πΈ
okay so this one is your line-limit check, bestie. It returns the maximum number of lines a QTextEdit can hold in LogText mode. By default the number of lines is unlimited, which is signified by a value of -1. π
β¨ QMimeSourceFactory * QTextEdit::mimeSourceFactory () const β¨
Returns the QMimeSourceFactory which is being used by this text edit. slay.
See also setMimeSourceFactory().
Examples:
(the original just says "Examples:" and then dips. iconic, honestly π)
π void QTextEdit::modificationChanged ( bool m ) [signal] π
This signal is emitted when the modification status of the document has changed. If m is TRUE, the document was modified β otherwise the modification state has been reset to unmodified. periodt.
See also modified.
π¦ void QTextEdit::moveCursor ( CursorAction action, bool select ) [virtual slot] π¦
Moves the text cursor according to action. This is normally used by some key event handler. select specifies whether the text between the current cursor position and the new position should be selected. no cap.
π QBrush QTextEdit::paper () const π
Returns the background (paper) brush. See the "paper" property for details.
π int QTextEdit::paragraphAt ( const QPoint & pos ) const π
Returns the paragraph which is at position pos β and yes, that's in contents coordinates.
π QColor QTextEdit::paragraphBackgroundColor ( int para ) const π
Returns the background color of the paragraph para, or an invalid color if para is out of range or the paragraph has no background set. literally.
β int QTextEdit::paragraphLength ( int para ) const β
Returns the length of the paragraph para β i.e. the number of characters β or -1 if there is no paragraph with index para.
This function ignores newlines. periodt.
π QRect QTextEdit::paragraphRect ( int para ) const π
Returns the rectangle of the paragraph para in contents coordinates, or an invalid rectangle if para is out of range.
π§ int QTextEdit::paragraphs () const π§
Returns the number of paragraphs in the text. tiny plot twist: an empty textedit is always considered to have one paragraph, so 1 is returned in this case. π
π void QTextEdit::paste () [virtual slot] π
Pastes the text from the clipboard into the text edit at the current cursor position. Only plain text is pasted, bestie.
If there is no text in the clipboard nothing happens. no drama.
See also pasteSubType(), cut(), and QTextEdit::copy().
π
void QTextEdit::pasteSubType ( const QCString & subtype ) [virtual slot] π
Pastes the text with format subtype from the clipboard into the text edit at the current cursor position. The subtype can be "plain" or "html".
If there is no text with format subtype in the clipboard nothing happens.
See also paste(), cut(), and QTextEdit::copy().
π«Ά void QTextEdit::placeCursor ( const QPoint & pos, QTextCursor * c = 0 ) [virtual slot] π«Ά
Places the cursor c at the character which is closest to position pos (in contents coordinates). If c is 0, the default text cursor is used.
See also setCursorPosition().
β¨ int QTextEdit::pointSize () const β¨
Returns the point size of the font of the current format.
See also setFamily(), setCurrentFont(), and setPointSize().
π₯ void QTextEdit::redo () [virtual slot] π₯
Redoes the last operation.
If there is no operation to redo, i.e. there is no redo step in the undo/redo history, nothing happens. lowkey tragic but okay.
See also redoAvailable(), undo(), and undoDepth.
π void QTextEdit::redoAvailable ( bool yes ) [signal] π
This signal is emitted when the availability of redo changes. If yes is TRUE, then redo() will work until redoAvailable( FALSE ) is next emitted.
See also redo() and undoDepth.
πΈ void QTextEdit::removeParagraph ( int para ) [virtual slot] πΈ
Removes the paragraph para. yeeted. π
π void QTextEdit::removeSelectedText ( int selNum = 0 ) [virtual slot] π
Deletes the text of selection selNum (by default, the default selection, 0). If there is no selected text nothing happens.
See also selectedText and removeSelection().
π¦ void QTextEdit::removeSelection ( int selNum = 0 ) [virtual slot] π¦
Removes the selection selNum (by default 0). This does not remove the selected text. important distinction, bestie.
See also removeSelectedText().
π void QTextEdit::repaintChanged () [protected] π
Repaints any paragraphs that have changed.
Although used extensively internally you shouldn't need to call this yourself. periodt.
π void QTextEdit::returnPressed () [signal] π
This signal is emitted if the user pressed the Return or the Enter key.
π void QTextEdit::scrollToAnchor ( const QString & name ) [virtual slot] π
Scrolls the text edit to make the text at the anchor called name visible, if it can be found in the document. If the anchor isn't found no scrolling will occur. An anchor is defined using the HTML anchor tag, e.g. <a name="target">. iconic.
β void QTextEdit::scrollToBottom () [virtual slot] β
Scrolls to the bottom of the document and does formatting if required.
π void QTextEdit::selectAll ( bool select = TRUE ) [virtual slot] π
If select is TRUE (the default), all the text is selected as selection 0. If select is FALSE any selected text is unselected, i.e. the default selection (selection 0) is cleared.
See also selectedText.
π§ QString QTextEdit::selectedText () const π§
Returns the selected text (from selection 0) or an empty string if there is no currently selected text (in selection 0). See the "selectedText" property for details.
π void QTextEdit::selectionChanged () [signal] π
This signal is emitted whenever the selection changes.
See also setSelection() and copyAvailable().
π
void QTextEdit::setAlignment ( int a ) [virtual slot] π
Sets the alignment of the current paragraph to a. Valid alignments are Qt::AlignLeft, Qt::AlignRight, Qt::AlignJustify and Qt::AlignCenter (which centers horizontally).
Reimplemented in QMultiLineEdit.
π«Ά void QTextEdit::setAutoFormatting ( uint features ) π«Ά
Sets the enabled set of auto formatting features to features. See the "autoFormatting" property for details.
β¨ void QTextEdit::setBold ( bool b ) [virtual slot] β¨
If b is TRUE sets the current format to bold; otherwise sets the current format to non-bold.
See also bold().
π₯ void QTextEdit::setColor ( const QColor & c ) [virtual slot] π₯
Sets the color of the current format, i.e. of the text, to c.
See also color() and paper.
π void QTextEdit::setCurrentFont ( const QFont & f ) [virtual slot] π
Sets the font of the current format to f.
If the widget is in LogText mode this function will do nothing. Use setFont() instead.
See also currentFont(), setPointSize(), and setFamily().
πΈ void QTextEdit::setCursorPosition ( int para, int index ) [virtual slot] πΈ
Sets the cursor to position index in paragraph para.
See also getCursorPosition().
π void QTextEdit::setFamily ( const QString & fontFamily ) [virtual slot] π
Sets the font family of the current format to fontFamily.
See also family() and setCurrentFont().
π¦ void QTextEdit::setItalic ( bool b ) [virtual slot] π¦
If b is TRUE sets the current format to italic; otherwise sets the current format to non-italic.
See also italic().
π void QTextEdit::setLinkUnderline ( bool ) [virtual slot] π
Sets whether hypertext links will be underlined. See the "linkUnderline" property for details.
π void QTextEdit::setMaxLogLines ( int limit ) [slot] π
Sets the maximum number of lines a QTextEdit can hold in LogText mode to limit. If limit is -1 (the default), this signifies an unlimited number of lines.
Warning: Never use formatting tags that span more than one line when the maximum log lines is set. When lines are removed from the top of the buffer it could result in an unbalanced tag pair, i.e. the left formatting tag is removed before the right one.
π void QTextEdit::setMimeSourceFactory ( QMimeSourceFactory * factory ) [virtual slot] π
Sets the text edit's mimesource factory to factory. See QMimeSourceFactory for further details.
See also mimeSourceFactory().
β void QTextEdit::setModified ( bool m ) [virtual slot] β
Sets whether the document has been modified by the user to m. See the "modified" property for details.
π void QTextEdit::setOverwriteMode ( bool b ) [virtual slot] π
Sets the text edit's overwrite mode to b. See the "overwriteMode" property for details.
π§ void QTextEdit::setPaper ( const QBrush & pap ) [virtual slot] π§
Sets the background (paper) brush to pap. See the "paper" property for details.
π void QTextEdit::setParagraphBackgroundColor ( int para, const QColor & bg ) [virtual slot] π
Sets the background color of the paragraph para to bg.
π
void QTextEdit::setPointSize ( int s ) [virtual slot] π
Sets the point size of the current format to s.
Note that if s is zero or negative, the behaviour of this function is not defined. so maybe don't do that, bestie.
See also pointSize(), setCurrentFont(), and setFamily().
π«Ά void QTextEdit::setReadOnly ( bool b ) [virtual slot] π«Ά
Sets whether the text edit is read-only to b. See the "readOnly" property for details.
β¨ void QTextEdit::setSelection ( int paraFrom, int indexFrom, int paraTo, int indexTo, int selNum = 0 ) [virtual slot] β¨
Sets a selection which starts at position indexFrom in paragraph paraFrom and ends at position indexTo in paragraph paraTo.
Any existing selections which have a different id (selNum) are left alone, but if an existing selection has the same id as selNum it is removed and replaced by this selection.
Uses the selection settings of selection selNum. If selNum is 0, this is the default selection.
The cursor is moved to the end of the selection if selNum is 0, otherwise the cursor position remains unchanged.
See also getSelection() and selectedText.
π₯ void QTextEdit::setSelectionAttributes ( int selNum, const QColor & back, bool invertText ) [virtual slot] π₯
Sets the background color of selection number selNum to back and specifies whether the text of this selection should be inverted with invertText.
This only works for selNum > 0. The default selection (selNum == 0) gets its attributes from the text edit's colorGroup().
π void QTextEdit::setStyleSheet ( QStyleSheet * styleSheet ) [virtual slot] π
Sets the stylesheet to use with this text edit to styleSheet. Changes will only take effect for new text added with setText() or append().
See also styleSheet().
πΈ void QTextEdit::setTabChangesFocus ( bool b ) [slot] πΈ
Sets whether TAB changes focus or is accepted as input to b. See the "tabChangesFocus" property for details.
π void QTextEdit::setTabStopWidth ( int ts ) [virtual slot] π
Sets the tab stop width in pixels to ts. See the "tabStopWidth" property for details.
π¦ void QTextEdit::setText ( const QString & txt ) [slot] π¦
Sets the text edit's text to txt. See the "text" property for details.
void QTextEdit::setText ( const QString & text, const QString & context ) [virtual slot] π
Okay so this one is an overloaded member function, bestie β provided for convenience, and it behaves essentially like the above function. Same energy, extra arg. β¨
It changes the text of the text edit to the string text and the context to context. Any previous text is removed, like gone gone, no takebacks. π
text may be interpreted either as plain text or as rich text, depending on the textFormat(). The default setting is AutoText, i.e. the text edit auto-detects the format from text. She's perceptive like that. π
For rich text the rendering style and available tags are defined by a styleSheet(); see QStyleSheet for details.
The optional context is a path which the text edit's QMimeSourceFactory uses to resolve the locations of files and images. (See QTextEdit::QTextEdit().) It is passed to the text edit's QMimeSourceFactory when quering data. π«Ά
Note that the undo/redo history is cleared by this function. So likeβ¦ all your little ctrl-Z dreams? Gone. π
See also text and textFormat.
void QTextEdit::setTextFormat ( TextFormat f ) [virtual slot] π
Sets the text format: rich text, plain text, log text or auto text to f. See the textFormat property for details. That's it, that's the whole vibe check. π
void QTextEdit::setUnderline ( bool b ) [virtual slot] β¨
If b is TRUE sets the current format to underline; otherwise sets the current format to non-underline. Underline on, underline off, she's serving both. πΈ
See also underline().
void QTextEdit::setUndoDepth ( int d ) [virtual slot] π¦
Sets the depth of the undo history to d. See the undoDepth property for details. How many steps back can you go? d. That's the number. Periodt. π
void QTextEdit::setUndoRedoEnabled ( bool b ) [virtual slot] π
Sets whether undo/redo is enabled to b. See the undoRedoEnabled property for details.
void QTextEdit::setVerticalAlignment ( VerticalAlignment a ) [virtual slot] π
Sets the vertical alignment of the current format, i.e. of the text, to a. Yes, alignment but make it vertical, she contains multitudes.
See also color() and paper.
void QTextEdit::setWordWrap ( WordWrap mode ) [virtual slot] π
Sets the word wrap mode to mode. See the wordWrap property for details.
void QTextEdit::setWrapColumnOrWidth ( int ) [virtual slot] π
Sets the position (in pixels or columns depending on the wrap mode) where text will be wrapped. See the wrapColumnOrWidth property for details. Pixels or columns, she's flexible, iykyk. β¨
void QTextEdit::setWrapPolicy ( WrapPolicy policy ) [virtual slot] π¦
Sets the word wrap policy, at whitespace or anywhere to policy. See the wrapPolicy property for details.
QStyleSheet * QTextEdit::styleSheet () const π
Returns the QStyleSheet which is being used by this text edit. The moment of truth, the fit check, the whole aesthetic. π
See also setStyleSheet().
Examples:
void QTextEdit::sync () [virtual slot] π₯
QTextEdit is optimized for large amounts text. One of its optimizations is to format only the visible text, formatting the rest on demand, e.g. as the user scrolls, so you don't usually need to call this function. She's lowkey doing the work in the background, minding her business. π§
In some situations you may want to force the whole text to be formatted. For example, if after calling setText(), you wanted to know the height of the document (using contentsHeight()), you would call this function first.
QSyntaxHighlighter * QTextEdit::syntaxHighlighter () const β
Returns the QSyntaxHighlighter set on this QTextEdit. 0 is returned if no syntax highlighter is set. No highlighter, no glow-up, we move. π
bool QTextEdit::tabChangesFocus () const π
Returns TRUE if TAB changes focus or is accepted as input; otherwise returns FALSE. See the tabChangesFocus property for details.
int QTextEdit::tabStopWidth () const β¨
Returns the tab stop width in pixels. See the tabStopWidth property for details.
QString QTextEdit::text () const π
Returns the text edit's text. See the text property for details. The main character herself, the text. π
QString QTextEdit::text ( int para ) const πΈ
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Returns the text of paragraph para.
If textFormat() is RichText the text will contain HTML formatting tags.
void QTextEdit::textChanged () [signal] π¦
This signal is emitted whenever the text in the text edit changes. She's literally always yapping about updates and we love that for her. π
See also text and append().
Examples:
QTextCursor * QTextEdit::textCursor () const [protected] π«Ά
Returns the text edit's text cursor.
Warning: QTextCursor is not in the public API, but in special circumstances you might wish to use it. So like, proceed with caution bestie, she's not for everyone. π
TextFormat QTextEdit::textFormat () const π
Returns the text format: rich text, plain text, log text or auto text. See the textFormat property for details.
bool QTextEdit::underline () const π
Returns TRUE if the current format is underlined; otherwise returns FALSE. The vibe check for underlines specifically. β¨
See also setUnderline().
void QTextEdit::undo () [virtual slot] π
Undoes the last operation. The ctrl-Z of it all, iconic, essential, no notes.
If there is no operation to undo, i.e. there is no undo step in the undo/redo history, nothing happens. She simply cannot go back further, the past is the past. π
See also undoAvailable(), redo(), and undoDepth.
void QTextEdit::undoAvailable ( bool yes ) [signal] π₯
This signal is emitted when the availability of undo changes. If yes is TRUE, then undo() will work until undoAvailable( FALSE ) is next emitted.
See also undo() and undoDepth.
int QTextEdit::undoDepth () const π
Returns the depth of the undo history. See the undoDepth property for details.
WordWrap QTextEdit::wordWrap () const π¦
Returns the word wrap mode. See the wordWrap property for details.
int QTextEdit::wrapColumnOrWidth () const π
Returns the position (in pixels or columns depending on the wrap mode) where text will be wrapped. See the wrapColumnOrWidth property for details.
WrapPolicy QTextEdit::wrapPolicy () const β
Returns the word wrap policy, at whitespace or anywhere. See the wrapPolicy property for details.
void QTextEdit::zoomIn ( int range ) [virtual slot] π
Zooms in on the text by making the base font size range points larger and recalculating all font sizes to be the new size. This does not change the size of any images. Images stay exactly as they are, unbothered, moisturized, in their lane. π
See also zoomOut().
void QTextEdit::zoomIn () [virtual slot] β¨
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Zooms in on the text by making the base font size one point larger and recalculating all font sizes to be the new size. This does not change the size of any images.
See also zoomOut().
void QTextEdit::zoomOut ( int range ) [virtual slot] πΈ
Zooms out on the text by making the base font size range points smaller and recalculating all font sizes to be the new size. This does not change the size of any images.
See also zoomIn().
void QTextEdit::zoomOut () [virtual slot] π¦
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Zooms out on the text by making the base font size one point smaller and recalculating all font sizes to be the new size. This does not change the size of any images.
See also zoomIn().
void QTextEdit::zoomTo ( int size ) [virtual slot] π
Zooms the text by making the base font size size points and recalculating all font sizes to be the new size. This does not change the size of any images.
π Property Documentation π
AutoFormatting autoFormatting β¨
This property holds the enabled set of auto formatting features.
The value can be any combination of the values in the AutoFormatting enum. The default is AutoAll. Choose AutoNone to disable all automatic formatting.
Currently, the only automatic formatting feature provided is AutoBulletList; future versions of Qt may offer more.
Set this property's value with setAutoFormatting() and get this property's value with autoFormatting().
QString documentTitle π
This property holds the title of the document parsed from the text.
For PlainText the title will be an empty string. For RichText the title will be the text between the <title> tags, if present, otherwise an empty string.
Get this property's value with documentTitle().
bool hasSelectedText π
This property holds whether some text is selected in selection 0.
Get this property's value with hasSelectedText().
int length πΈ
This property holds the number of characters in the text.
Get this property's value with length().
bool linkUnderline π¦
This property holds whether hypertext links will be underlined.
If TRUE (the default) hypertext links will be displayed underlined. If FALSE links will not be displayed underlined.
Set this property's value with setLinkUnderline() and get this property's value with linkUnderline().
bool modified π
This property holds whether the document has been modified by the user.
Set this property's value with setModified() and get this property's value with isModified().
bool overwriteMode β
This property holds the text edit's overwrite mode.
If FALSE (the default) characters entered by the user are inserted with any characters to the right being moved out of the way. If TRUE, the editor is in overwrite mode, i.e. characters entered by the user overwrite any characters to the right of the cursor position.
Set this property's value with setOverwriteMode() and get this property's value with isOverwriteMode().
QBrush paper π
This property holds the background (paper) brush.
The brush that is currently used to draw the background of the text edit. The initial setting is an empty brush.
Set this property's value with setPaper() and get this property's value with paper().
bool readOnly π«Ά
This property holds whether the text edit is read-only.
In a read-only text edit the user can only navigate through the text and select text; modifying the text is not possible. Look, don't touch, that's the rule. π
This property's default is FALSE.
Set this property's value with setReadOnly() and get this property's value with isReadOnly().
QString selectedText π
This property holds the selected text (from selection 0) or an empty string if there is no currently selected text (in selection 0).
The text is always returned as PlainText if the textFormat() is PlainText or AutoText, otherwise it is returned as HTML.
See also hasSelectedText.
Get this property's value with selectedText().
bool tabChangesFocus π₯
This property holds whether TAB changes focus or is accepted as input.
In some occasions text edits should not allow the user to input tabulators or change indentation using the TAB key, as this breaks the focus chain. The default is FALSE.
Set this property's value with setTabChangesFocus() and get this property's value with tabChangesFocus().
int tabStopWidth π
This property holds the tab stop width in pixels.
Set this property's value with setTabStopWidth() and get this property's value with tabStopWidth().
QString text
Okay bestie, this property holds the text edit's text. Periodt. π There is no default text β she starts empty, as she should. β¨
On setting, any previous text is deleted. Gone. Poof. Deleted. So don't set it unless you mean it. π
The text may be interpreted either as plain text or as rich text, depending on textFormat(). The default setting is AutoText, i.e. the text edit auto-detects the format of the text. She's smart like that. π§
For richtext, calling text() on an editable QTextEdit will cause the text to be regenerated from the textedit. This may mean that the QString returned may not be exactly the same as the one that was set. iykyk π
See also textFormat.
Set this property's value with setText() and get this property's value with text().
TextFormat textFormat
This property holds the text format: rich text, plain text, log text or auto text. It's giving format buffet. π
The text format is one of the following:
PlainTextβ all characters, except newlines, are displayed verbatim, including spaces. Whenever a newline appears in the text the text edit inserts a hard line break and begins a new paragraph.RichTextβ rich text rendering. The available styles are defined in the default stylesheetQStyleSheet::defaultSheet().LogTextβ optimized mode for very large texts. Supports a very limited set of formatting tags (color, bold, underline and italic settings).AutoTextβ this is the default. The text edit autodetects which rendering style is best,PlainTextorRichText. This is done by using theQStyleSheet::mightBeRichText()function.
Set this property's value with setTextFormat() and get this property's value with textFormat().
int undoDepth
This property holds the depth of the undo history. The maximum number of steps in the undo/redo history. The default is 100.
See also undo() and redo().
Set this property's value with setUndoDepth() and get this property's value with undoDepth().
bool undoRedoEnabled
This property holds whether undo/redo is enabled.
When changing this property, the undo/redo history is cleared. So if you toggle it, say bye to your undo stack. π
The default is TRUE.
Set this property's value with setUndoRedoEnabled() and get this property's value with isUndoRedoEnabled().
WordWrap wordWrap
This property holds the word wrap mode.
The default mode is WidgetWidth which causes words to be wrapped at the right edge of the text edit. Wrapping occurs at whitespace, keeping whole words intact. If you want wrapping to occur within words use setWrapPolicy(). If you set a wrap mode of FixedPixelWidth or FixedColumnWidth you should also call setWrapColumnOrWidth() with the width you want.
See also WordWrap, wrapColumnOrWidth, and wrapPolicy.
Set this property's value with setWordWrap() and get this property's value with wordWrap().
int wrapColumnOrWidth
This property holds the position (in pixels or columns depending on the wrap mode) where text will be wrapped.
If the wrap mode is FixedPixelWidth, the value is the number of pixels from the left edge of the text edit at which text should be wrapped. If the wrap mode is FixedColumnWidth, the value is the column number (in character columns) from the left edge of the text edit at which text should be wrapped.
See also wordWrap.
Set this property's value with setWrapColumnOrWidth() and get this property's value with wrapColumnOrWidth().
WrapPolicy wrapPolicy
This property holds the word wrap policy, at whitespace or anywhere.
Defines where text can be wrapped when word wrap mode is not NoWrap. The choices are AtWordBoundary (the default), Anywhere and AtWordOrDocumentBoundary
See also wordWrap.
Set this property's value with setWrapPolicy() and get this property's value with wrapPolicy().
β¨ SEE ALSO β¨
COPYRIGHT
Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com. See the license file included in the distribution for a complete license statement.
AUTHOR
Generated automatically from the source code.
BUGS
If you find a bug in Qt, please report it as described in http://doc.trolltech.com/bughowto.html. Good bug reports help us to help you. Thank you.
The definitive Qt documentation is provided in HTML format; it is located at $QTDIR/doc/html and can be read using Qt Assistant or with a web browser. This man page is provided as a convenience for those users who prefer man pages, although this format is not officially supported by Trolltech.
If you find errors in this manual page, please report them to qt-bugs@trolltech.com. Please include the name of the manual page (qtextedit.3qt) and the Qt version (3.3.8).
Okay so that's the whole page, bestie. It was generated from the source code, dated 2 February 2007, by Trolltech AS, and the man page is QTextEdit(3qt). Now go forth and text-edit iconically. πβ¨
π¦ where this page comes from
- fedora 43: qt3-devel-docs 3.3.8b-102.fc43 Β· QPL-1.0 OR GPL-2.0-only OR GPL-3.0-only
- fedora 44: qt3-devel-docs 3.3.8b-103.fc44 Β· QPL-1.0 OR GPL-2.0-only OR GPL-3.0-only
- Copyright 1992-2007 Trolltech ASA. All rights reserved. See the
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms