Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
QTextEdit Class Reference

The QTextEdit class provides a widget that is used to edit and display both plain and rich text. More...

#include <qtextedit.h>

+ Inheritance diagram for QTextEdit:
+ Collaboration diagram for QTextEdit:

Classes

class  ExtraSelection
 The QTextEdit::ExtraSelection structure provides a way of specifying a character format for a given selection in a document. More...
 

Public Types

enum  LineWrapMode { NoWrap , WidgetWidth , FixedPixelWidth , FixedColumnWidth }
 \value NoWrap \value WidgetWidth \value FixedPixelWidth \value FixedColumnWidth More...
 
enum  AutoFormattingFlag { AutoNone = 0 , AutoBulletList = 0x00000001 , AutoAll = 0xffffffff }
 \value AutoNone Don't do any automatic formatting. More...
 

Public Slots

void setFontPointSize (qreal s)
 Sets the point size of the current format to s.
 
void setFontFamily (const QString &fontFamily)
 Sets the font family of the current format to fontFamily.
 
void setFontWeight (int w)
 Sets the font weight of the current format to the given weight, where the value used is in the range defined by the QFont::Weight enum.
 
void setFontUnderline (bool b)
 If underline is true, sets the current format to underline; otherwise sets the current format to non-underline.
 
void setFontItalic (bool b)
 If italic is true, sets the current format to italic; otherwise sets the current format to non-italic.
 
void setTextColor (const QColor &c)
 Sets the text color of the current format to c.
 
void setTextBackgroundColor (const QColor &c)
 
void setCurrentFont (const QFont &f)
 Sets the font of the current format to f.
 
void setAlignment (Qt::Alignment a)
 Sets the alignment of the current paragraph to a.
 
void setPlainText (const QString &text)
 Changes the text of the text edit to the string text.
 
void setHtml (const QString &text)
 
void setText (const QString &text)
 
void cut ()
 Copies the selected text to the clipboard and deletes it from the text edit.
 
void copy ()
 Copies any selected text to the clipboard.
 
void paste ()
 Pastes the text from the clipboard into the text edit at the current cursor position.
 
void undo ()
 
void redo ()
 
void clear ()
 Deletes all the text in the text edit.
 
void selectAll ()
 Selects all text.
 
void insertPlainText (const QString &text)
 Convenience slot that inserts text at the current cursor position.
 
void insertHtml (const QString &text)
 Convenience slot that inserts text which is assumed to be of html formatting at the current cursor position.
 
void append (const QString &text)
 Appends a new paragraph with text to the end of the text edit.
 
void scrollToAnchor (const QString &name)
 Scrolls the text edit so that the anchor with the given name is visible; does nothing if the name is empty, or is already visible, or isn't found.
 
void zoomIn (int range=1)
 Zooms in on the text by making the base font size range points larger and recalculating all font sizes to be the new size.
 
void zoomOut (int range=1)
 Zooms out on the text by making the base font size range points smaller and recalculating all font sizes to be the new size.
 

Signals

void textChanged ()
 This signal is emitted whenever the document's content changes; for example, when text is inserted or deleted, or when formatting is applied.
 
void undoAvailable (bool b)
 This signal is emitted whenever undo operations become available (available is true) or unavailable (available is false).
 
void redoAvailable (bool b)
 This signal is emitted whenever redo operations become available (available is true) or unavailable (available is false).
 
void currentCharFormatChanged (const QTextCharFormat &format)
 This signal is emitted if the current character format has changed, for example caused by a change of the cursor position.
 
void copyAvailable (bool b)
 This signal is emitted when text is selected or de-selected in the text edit.
 
void selectionChanged ()
 This signal is emitted whenever the selection changes.
 
void cursorPositionChanged ()
 This signal is emitted whenever the position of the cursor changed.
 

Public Member Functions

 QTextEdit (QWidget *parent=nullptr)
 Constructs an empty QTextEdit with parent parent.
 
 QTextEdit (const QString &text, QWidget *parent=nullptr)
 Constructs a QTextEdit with parent parent.
 
virtual ~QTextEdit ()
 Destructor.
 
void setDocument (QTextDocument *document)
 
QTextDocumentdocument () const
 
void setPlaceholderText (const QString &placeholderText)
 
QString placeholderText () const
 
void setTextCursor (const QTextCursor &cursor)
 Sets the visible cursor.
 
QTextCursor textCursor () const
 Returns a copy of the QTextCursor that represents the currently visible cursor.
 
bool isReadOnly () const
 
void setReadOnly (bool ro)
 
void setTextInteractionFlags (Qt::TextInteractionFlags flags)
 
Qt::TextInteractionFlags textInteractionFlags () const
 
qreal fontPointSize () const
 Returns the point size of the font of the current format.
 
QString fontFamily () const
 Returns the font family of the current format.
 
int fontWeight () const
 Returns the font weight of the current format.
 
bool fontUnderline () const
 Returns true if the font of the current format is underlined; otherwise returns false.
 
bool fontItalic () const
 Returns true if the font of the current format is italic; otherwise returns false.
 
QColor textColor () const
 Returns the text color of the current format.
 
QColor textBackgroundColor () const
 
QFont currentFont () const
 Returns the font of the current format.
 
Qt::Alignment alignment () const
 Returns the alignment of the current paragraph.
 
void mergeCurrentCharFormat (const QTextCharFormat &modifier)
 Merges the properties specified in modifier into the current character format by calling QTextCursor::mergeCharFormat on the editor's cursor.
 
void setCurrentCharFormat (const QTextCharFormat &format)
 Sets the char format that is be used when inserting new text to format by calling QTextCursor::setCharFormat() on the editor's cursor.
 
QTextCharFormat currentCharFormat () const
 Returns the char format that is used when inserting new text.
 
AutoFormatting autoFormatting () const
 
void setAutoFormatting (AutoFormatting features)
 
bool tabChangesFocus () const
 
void setTabChangesFocus (bool b)
 
void setDocumentTitle (const QString &title)
 
QString documentTitle () const
 
bool isUndoRedoEnabled () const
 
void setUndoRedoEnabled (bool enable)
 
LineWrapMode lineWrapMode () const
 
void setLineWrapMode (LineWrapMode mode)
 
int lineWrapColumnOrWidth () const
 
void setLineWrapColumnOrWidth (int w)
 
QTextOption::WrapMode wordWrapMode () const
 the mode QTextEdit will use when wrapping text by words
 
void setWordWrapMode (QTextOption::WrapMode policy)
 
bool find (const QString &exp, QTextDocument::FindFlags options=QTextDocument::FindFlags())
 Finds the next occurrence of the string, exp, using the given options.
 
QString toPlainText () const
 QString QTextEdit::toPlainText() const.
 
QString toHtml () const
 
void ensureCursorVisible ()
 Ensures that the cursor is visible by scrolling the text edit if necessary.
 
virtual Q_INVOKABLE QVariant loadResource (int type, const QUrl &name)
 Loads the resource specified by the given type and name.
 
QMenucreateStandardContextMenu ()
 \reimp
 
QMenucreateStandardContextMenu (const QPoint &position)
 
QTextCursor cursorForPosition (const QPoint &pos) const
 returns a QTextCursor at position pos (in viewport coordinates).
 
QRect cursorRect (const QTextCursor &cursor) const
 returns a rectangle (in viewport coordinates) that includes the cursor.
 
QRect cursorRect () const
 returns a rectangle (in viewport coordinates) that includes the cursor of the text edit.
 
QString anchorAt (const QPoint &pos) const
 Returns the reference of the anchor at position pos, or an empty string if no anchor exists at that point.
 
bool overwriteMode () const
 
void setOverwriteMode (bool overwrite)
 
qreal tabStopDistance () const
 
void setTabStopDistance (qreal distance)
 
int cursorWidth () const
 
void setCursorWidth (int width)
 
bool acceptRichText () const
 
void setAcceptRichText (bool accept)
 
void setExtraSelections (const QList< ExtraSelection > &selections)
 \variable QTextEdit::ExtraSelection::cursor A cursor that contains a selection in a QTextDocument
 
QList< ExtraSelectionextraSelections () const
 
void moveCursor (QTextCursor::MoveOperation operation, QTextCursor::MoveMode mode=QTextCursor::MoveAnchor)
 
bool canPaste () const
 
void print (QPagedPaintDevice *printer) const
 
QVariant inputMethodQuery (Qt::InputMethodQuery property) const override
 \reimp
 
Q_INVOKABLE QVariant inputMethodQuery (Qt::InputMethodQuery query, QVariant argument) const
 

Protected Member Functions

virtual bool event (QEvent *e) override
 
virtual void timerEvent (QTimerEvent *e) override
 
virtual void keyPressEvent (QKeyEvent *e) override
 \reimp
 
virtual void keyReleaseEvent (QKeyEvent *e) override
 \reimp
 
virtual void resizeEvent (QResizeEvent *e) override
 \reimp
 
virtual void paintEvent (QPaintEvent *e) override
 This event handler can be reimplemented in a subclass to receive paint events passed in event.
 
virtual void mousePressEvent (QMouseEvent *e) override
 \reimp
 
virtual void mouseMoveEvent (QMouseEvent *e) override
 \reimp
 
virtual void mouseReleaseEvent (QMouseEvent *e) override
 \reimp
 
virtual void mouseDoubleClickEvent (QMouseEvent *e) override
 \reimp
 
virtual bool focusNextPrevChild (bool next) override
 \reimp
 
virtual void contextMenuEvent (QContextMenuEvent *e) override
 Shows the standard context menu created with createStandardContextMenu().
 
virtual void focusInEvent (QFocusEvent *e) override
 \reimp
 
virtual void focusOutEvent (QFocusEvent *e) override
 \reimp
 
virtual void showEvent (QShowEvent *) override
 \reimp
 
virtual void changeEvent (QEvent *e) override
 \reimp
 
virtual QMimeDatacreateMimeDataFromSelection () const
 This function returns a new MIME data object to represent the contents of the text edit's current selection.
 
virtual bool canInsertFromMimeData (const QMimeData *source) const
 This function returns true if the contents of the MIME data object, specified by source, can be decoded and inserted into the document.
 
virtual void insertFromMimeData (const QMimeData *source)
 This function inserts the contents of the MIME data object, specified by source, into the text edit at the current cursor position.
 
virtual void inputMethodEvent (QInputMethodEvent *) override
 \reimp
 
 QTextEdit (QTextEditPrivate &dd, QWidget *parent)
 
virtual void scrollContentsBy (int dx, int dy) override
 \reimp
 
virtual void doSetTextCursor (const QTextCursor &cursor)
 
void zoomInF (float range)
 

Properties

AutoFormatting autoFormatting
 the enabled set of auto formatting features
 
bool tabChangesFocus
 whether \uicontrol Tab changes focus or is accepted as input
 
QString documentTitle
 the title of the document parsed from the text.
 
bool undoRedoEnabled
 whether undo and redo are enabled.
 
LineWrapMode lineWrapMode
 the line wrap mode
 
int lineWrapColumnOrWidth
 the position (in pixels or columns depending on the wrap mode) where text will be wrapped
 
bool readOnly
 whether the text edit is read-only
 
QString html
 This property provides an HTML interface to the text of the text edit.
 
QString plainText
 the text editor's contents as plain text.
 
bool overwriteMode
 whether text entered by the user will overwrite existing text
 
qreal tabStopDistance
 the tab stop distance in pixels
 
bool acceptRichText
 whether the text edit accepts rich text insertions by the user
 
int cursorWidth
 
Qt::TextInteractionFlags textInteractionFlags
 
QTextDocumentdocument
 the underlying document of the text editor.
 
QString placeholderText
 the editor placeholder text
 

Friends

class QTextEditControl
 
class QTextDocument
 
class QWidgetTextControl
 

Detailed Description

The QTextEdit class provides a widget that is used to edit and display both plain and rich text.

\inmodule QtWidgets

Definition at line 26 of file qtextedit.h.

Member Enumeration Documentation

◆ AutoFormattingFlag

\value AutoNone Don't do any automatic formatting.

\value AutoBulletList Automatically create bullet lists (e.g. when the user enters an asterisk ('*') in the left most column, or presses Enter in an existing list item. \value AutoAll Apply all automatic formatting. Currently only automatic bullet lists are supported.

Enumerator
AutoNone 
AutoBulletList 
AutoAll 

Definition at line 62 of file qtextedit.h.

◆ LineWrapMode

\value NoWrap \value WidgetWidth \value FixedPixelWidth \value FixedColumnWidth

Enumerator
NoWrap 
WidgetWidth 
FixedPixelWidth 
FixedColumnWidth 

Definition at line 54 of file qtextedit.h.

Constructor & Destructor Documentation

◆ QTextEdit() [1/3]

QTextEdit::QTextEdit ( QWidget * parent = nullptr)
explicit

Constructs an empty QTextEdit with parent parent.

Definition at line 616 of file qtextedit.cpp.

References d.

◆ QTextEdit() [2/3]

QTextEdit::QTextEdit ( const QString & text,
QWidget * parent = nullptr )
explicit

Constructs a QTextEdit with parent parent.

The text edit will display the text text. The text is interpreted as html.

Definition at line 637 of file qtextedit.cpp.

References d, and text.

◆ ~QTextEdit()

QTextEdit::~QTextEdit ( )
virtual

Destructor.

Definition at line 649 of file qtextedit.cpp.

◆ QTextEdit() [3/3]

QTextEdit::QTextEdit ( QTextEditPrivate & dd,
QWidget * parent )
protected

Definition at line 626 of file qtextedit.cpp.

References d.

Member Function Documentation

◆ acceptRichText()

bool QTextEdit::acceptRichText ( ) const

Definition at line 2114 of file qtextedit.cpp.

References d.

◆ alignment()

Qt::Alignment QTextEdit::alignment ( ) const

Returns the alignment of the current paragraph.

See also
setAlignment()

Definition at line 768 of file qtextedit.cpp.

References d.

◆ anchorAt()

QString QTextEdit::anchorAt ( const QPoint & pos) const

Returns the reference of the anchor at position pos, or an empty string if no anchor exists at that point.

Definition at line 2022 of file qtextedit.cpp.

References d, and pos.

◆ append

void QTextEdit::append ( const QString & text)
slot

Appends a new paragraph with text to the end of the text edit.

Note
The new paragraph appended will have the same character format and block format as the current paragraph, determined by the position of the cursor.
See also
currentCharFormat(), QTextCursor::blockFormat()

Definition at line 2695 of file qtextedit.cpp.

References d, isReadOnly(), and text.

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ autoFormatting()

QTextEdit::AutoFormatting QTextEdit::autoFormatting ( ) const

Definition at line 2323 of file qtextedit.cpp.

References d.

◆ canInsertFromMimeData()

bool QTextEdit::canInsertFromMimeData ( const QMimeData * source) const
protectedvirtual

This function returns true if the contents of the MIME data object, specified by source, can be decoded and inserted into the document.

It is called for example when during a drag operation the mouse enters this widget and it is necessary to determine whether it is possible to accept the drag and drop operation.

Reimplement this function to enable drag and drop support for additional MIME types.

Reimplemented in TextEdit.

Definition at line 2198 of file qtextedit.cpp.

References d.

Referenced by TextEdit::canInsertFromMimeData().

+ Here is the caller graph for this function:

◆ canPaste()

bool QTextEdit::canPaste ( ) const
Since
4.2 Returns whether text can be pasted from the clipboard into the textedit.

Definition at line 2452 of file qtextedit.cpp.

References d.

◆ changeEvent()

void QTextEdit::changeEvent ( QEvent * e)
overrideprotectedvirtual

\reimp

Definition at line 1909 of file qtextedit.cpp.

References QEvent::ActivationChange, QEvent::ApplicationFontChange, d, QEvent::EnabledChange, font, QEvent::FontChange, QEvent::LayoutDirectionChange, palette, QEvent::PaletteChange, QEvent::setAccepted(), and QEvent::type().

+ Here is the call graph for this function:

◆ clear

void QTextEdit::clear ( )
slot

Deletes all the text in the text edit.

Notes: \list

See also
cut(), setPlainText(), setHtml()

Definition at line 1059 of file qtextedit.cpp.

References d.

Referenced by timerEvent().

+ Here is the caller graph for this function:

◆ contextMenuEvent()

void QTextEdit::contextMenuEvent ( QContextMenuEvent * event)
overrideprotectedvirtual

Shows the standard context menu created with createStandardContextMenu().

If you do not want the text edit to have a context menu, you can set its \l contextMenuPolicy to Qt::NoContextMenu. If you want to customize the context menu, reimplement this function. If you want to extend the standard context menu, reimplement this function, call createStandardContextMenu() and extend the menu returned.

Information about the event is passed in the event object.

void MyTextEdit::contextMenuEvent(QContextMenuEvent *event)
{
QMenu *menu = createStandardContextMenu();
menu->addAction(tr("My Menu Item"));
//...
menu->exec(event->globalPos());
delete menu;
}

Definition at line 1733 of file qtextedit.cpp.

References d.

◆ copy

void QTextEdit::copy ( )
slot

Copies any selected text to the clipboard.

See also
copyAvailable()

Definition at line 1020 of file qtextedit.cpp.

References d.

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

Referenced by QTextEditPrivate::init().

+ Here is the caller graph for this function:

◆ createMimeDataFromSelection()

QMimeData * QTextEdit::createMimeDataFromSelection ( ) const
protectedvirtual

This function returns a new MIME data object to represent the contents of the text edit's current selection.

It is called when the selection needs to be encapsulated into a new QMimeData object; for example, when a drag and drop operation is started, or when data is copied to the clipboard.

If you reimplement this function, note that the ownership of the returned QMimeData object is passed to the caller. The selection can be retrieved by using the textCursor() function.

Definition at line 2183 of file qtextedit.cpp.

References d.

◆ createStandardContextMenu() [1/2]

QMenu * QTextEdit::createStandardContextMenu ( )

\reimp

This function creates the standard context menu which is shown when the user clicks on the text edit with the right mouse button. It is called from the default contextMenuEvent() handler. The popup menu's ownership is transferred to the caller.

We recommend that you use the createStandardContextMenu(QPoint) version instead which will enable the actions that are sensitive to where the user clicked.

Definition at line 1958 of file qtextedit.cpp.

References d.

◆ createStandardContextMenu() [2/2]

QMenu * QTextEdit::createStandardContextMenu ( const QPoint & position)
Since
4.4 This function creates the standard context menu which is shown when the user clicks on the text edit with the right mouse button. It is called from the default contextMenuEvent() handler and it takes the position in document coordinates where the mouse click was. This can enable actions that are sensitive to the position where the user clicked. The popup menu's ownership is transferred to the caller.

Definition at line 1974 of file qtextedit.cpp.

References d, and position().

+ Here is the call graph for this function:

◆ currentCharFormat()

QTextCharFormat QTextEdit::currentCharFormat ( ) const

Returns the char format that is used when inserting new text.

Definition at line 2305 of file qtextedit.cpp.

References d.

◆ currentCharFormatChanged

void QTextEdit::currentCharFormatChanged ( const QTextCharFormat & f)
signal

This signal is emitted if the current character format has changed, for example caused by a change of the cursor position.

The new format is f.

See also
setCurrentCharFormat()

Referenced by QTextEditPrivate::init().

+ Here is the caller graph for this function:

◆ currentFont()

QFont QTextEdit::currentFont ( ) const

Returns the font of the current format.

See also
setCurrentFont(), setFontFamily(), setFontPointSize()

Definition at line 740 of file qtextedit.cpp.

References d.

◆ cursorForPosition()

QTextCursor QTextEdit::cursorForPosition ( const QPoint & pos) const

returns a QTextCursor at position pos (in viewport coordinates).

Definition at line 1984 of file qtextedit.cpp.

References d, and pos.

◆ cursorPositionChanged

void QTextEdit::cursorPositionChanged ( )
signal

This signal is emitted whenever the position of the cursor changed.

◆ cursorRect() [1/2]

QRect QTextEdit::cursorRect ( ) const

returns a rectangle (in viewport coordinates) that includes the cursor of the text edit.

Definition at line 2009 of file qtextedit.cpp.

References d, and QRect::translate().

Referenced by event().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cursorRect() [2/2]

QRect QTextEdit::cursorRect ( const QTextCursor & cursor) const

returns a rectangle (in viewport coordinates) that includes the cursor.

Definition at line 1994 of file qtextedit.cpp.

References cursor, d, and QRect::translate().

+ Here is the call graph for this function:

◆ cursorWidth()

int QTextEdit::cursorWidth ( ) const

Definition at line 2091 of file qtextedit.cpp.

References d.

◆ cut

void QTextEdit::cut ( )
slot

Copies the selected text to the clipboard and deletes it from the text edit.

If there is no selected text nothing happens.

See also
copy(), paste()

Definition at line 1008 of file qtextedit.cpp.

References d.

◆ document()

QTextDocument * QTextEdit::document ( ) const

Definition at line 791 of file qtextedit.cpp.

References d.

◆ documentTitle()

QString QTextEdit::documentTitle ( ) const
inline

Definition at line 113 of file qtextedit.h.

References QTextDocument::DocumentTitle.

◆ doSetTextCursor()

void QTextEdit::doSetTextCursor ( const QTextCursor & cursor)
protectedvirtual

This provides a hook for subclasses to intercept cursor changes.

Definition at line 840 of file qtextedit.cpp.

References cursor, and d.

Referenced by setTextCursor().

+ Here is the caller graph for this function:

◆ ensureCursorVisible()

void QTextEdit::ensureCursorVisible ( )

Ensures that the cursor is visible by scrolling the text edit if necessary.

Definition at line 2709 of file qtextedit.cpp.

References d.

Referenced by event(), inputMethodEvent(), mouseReleaseEvent(), and showEvent().

+ Here is the caller graph for this function:

◆ event()

bool QTextEdit::event ( QEvent * e)
overrideprotectedvirtual

Reimplemented in QTextBrowser.

Definition at line 1080 of file qtextedit.cpp.

References QRect::center(), QEvent::ContextMenu, cursorRect(), d, ensureCursorVisible(), QEvent::isAccepted(), QContextMenuEvent::Keyboard, palette, QEvent::setAccepted(), QEvent::ShortcutOverride, QEvent::ToolTip, QEvent::type(), QEvent::WindowActivate, and QEvent::WindowDeactivate.

Referenced by QTextBrowser::event().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ extraSelections()

QList< QTextEdit::ExtraSelection > QTextEdit::extraSelections ( ) const
Since
4.2 Returns previously set extra selections.
See also
setExtraSelections()

Definition at line 2167 of file qtextedit.cpp.

References d.

◆ find()

bool QTextEdit::find ( const QString & exp,
QTextDocument::FindFlags options = QTextDocument::FindFlags() )

Finds the next occurrence of the string, exp, using the given options.

Returns true if exp was found and changes the cursor to select the match; otherwise returns false.

Since
5.13 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Finds the next occurrence, matching the regular expression, exp, using the given options.

Returns true if a match was found and changes the cursor to select the match; otherwise returns false.

Warning
For historical reasons, the case sensitivity option set on exp is ignored. Instead, the options are used to determine if the search is case sensitive or not.

Definition at line 2590 of file qtextedit.cpp.

References d.

◆ focusInEvent()

void QTextEdit::focusInEvent ( QFocusEvent * e)
overrideprotectedvirtual

\reimp

Definition at line 1873 of file qtextedit.cpp.

References d, Qt::MouseFocusReason, and QFocusEvent::reason().

+ Here is the call graph for this function:

◆ focusNextPrevChild()

bool QTextEdit::focusNextPrevChild ( bool next)
overrideprotectedvirtual

\reimp

Reimplemented in QTextBrowser.

Definition at line 1709 of file qtextedit.cpp.

References d, next, and Qt::TextEditable.

Referenced by QTextBrowser::focusNextPrevChild().

+ Here is the caller graph for this function:

◆ focusOutEvent()

void QTextEdit::focusOutEvent ( QFocusEvent * e)
overrideprotectedvirtual

\reimp

Reimplemented in QTextBrowser.

Definition at line 1885 of file qtextedit.cpp.

References d.

Referenced by QTextBrowser::focusOutEvent().

+ Here is the caller graph for this function:

◆ fontFamily()

QString QTextEdit::fontFamily ( ) const

Returns the font family of the current format.

See also
setFontFamily(), setCurrentFont(), setFontPointSize()

Definition at line 669 of file qtextedit.cpp.

References d.

Referenced by setFontFamily().

+ Here is the caller graph for this function:

◆ fontItalic()

bool QTextEdit::fontItalic ( ) const

Returns true if the font of the current format is italic; otherwise returns false.

See also
setFontItalic()

Definition at line 704 of file qtextedit.cpp.

References d.

◆ fontPointSize()

qreal QTextEdit::fontPointSize ( ) const

Returns the point size of the font of the current format.

See also
setFontFamily(), setCurrentFont(), setFontPointSize()

Definition at line 658 of file qtextedit.cpp.

References d.

◆ fontUnderline()

bool QTextEdit::fontUnderline ( ) const

Returns true if the font of the current format is underlined; otherwise returns false.

See also
setFontUnderline()

Definition at line 692 of file qtextedit.cpp.

References d.

◆ fontWeight()

int QTextEdit::fontWeight ( ) const

Returns the font weight of the current format.

See also
setFontWeight(), setCurrentFont(), setFontPointSize(), QFont::Weight

Definition at line 680 of file qtextedit.cpp.

References d.

◆ inputMethodEvent()

void QTextEdit::inputMethodEvent ( QInputMethodEvent * e)
overrideprotectedvirtual

\reimp

Definition at line 1785 of file qtextedit.cpp.

References QInputMethodEvent::attributes(), QInputMethodEvent::commitString(), d, ensureCursorVisible(), QString::isEmpty(), QInputMethodEvent::preeditString(), and Qt::TextEditable.

+ Here is the call graph for this function:

◆ inputMethodQuery() [1/2]

QVariant QTextEdit::inputMethodQuery ( Qt::InputMethodQuery property) const
override

\reimp

Definition at line 1815 of file qtextedit.cpp.

References inputMethodQuery(), and property.

Referenced by inputMethodQuery().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ inputMethodQuery() [2/2]

QVariant QTextEdit::inputMethodQuery ( Qt::InputMethodQuery query,
QVariant argument ) const

Definition at line 1822 of file qtextedit.cpp.

References argument, d, Qt::ImEnabled, Qt::ImHints, Qt::ImInputItemClipRectangle, Qt::ImReadOnly, QWidget::inputMethodQuery(), isReadOnly(), QVariant::toRectF(), and QRectF::translated().

+ Here is the call graph for this function:

◆ insertFromMimeData()

void QTextEdit::insertFromMimeData ( const QMimeData * source)
protectedvirtual

This function inserts the contents of the MIME data object, specified by source, into the text edit at the current cursor position.

It is called whenever text is inserted as the result of a clipboard paste operation, or when the text edit accepts data from a drag and drop operation.

Reimplement this function to enable drag and drop support for additional MIME types.

Reimplemented in TextEdit.

Definition at line 2213 of file qtextedit.cpp.

References d.

◆ insertHtml

void QTextEdit::insertHtml ( const QString & text)
slot

Convenience slot that inserts text which is assumed to be of html formatting at the current cursor position.

It is equivalent to:

Note
When using this function with a style sheet, the style sheet will only apply to the current block in the document. In order to apply a style sheet throughout a document, use QTextDocument::setDefaultStyleSheet() instead.

Definition at line 2363 of file qtextedit.cpp.

References d, and text.

◆ insertPlainText

void QTextEdit::insertPlainText ( const QString & text)
slot

Convenience slot that inserts text at the current cursor position.

It is equivalent to

Definition at line 2343 of file qtextedit.cpp.

References d, and text.

◆ isReadOnly()

bool QTextEdit::isReadOnly ( ) const

Definition at line 2229 of file qtextedit.cpp.

References d, and Qt::TextEditable.

Referenced by append(), inputMethodQuery(), keyReleaseEvent(), and mouseReleaseEvent().

+ Here is the caller graph for this function:

◆ isUndoRedoEnabled()

bool QTextEdit::isUndoRedoEnabled ( ) const
inline

Definition at line 116 of file qtextedit.h.

◆ keyPressEvent()

◆ keyReleaseEvent()

void QTextEdit::keyReleaseEvent ( QKeyEvent * e)
overrideprotectedvirtual

\reimp

Definition at line 1445 of file qtextedit.cpp.

References QEvent::accept(), cursor, d, QEvent::ignore(), QKeyEvent::isAutoRepeat(), isReadOnly(), QKeyEvent::key(), Qt::Key_Back, list, QList< T >::remove(), and setTextCursor().

+ Here is the call graph for this function:

◆ lineWrapColumnOrWidth()

int QTextEdit::lineWrapColumnOrWidth ( ) const

Definition at line 2548 of file qtextedit.cpp.

References d.

◆ lineWrapMode()

QTextEdit::LineWrapMode QTextEdit::lineWrapMode ( ) const

Definition at line 2517 of file qtextedit.cpp.

References d.

◆ loadResource()

QVariant QTextEdit::loadResource ( int type,
const QUrl & name )
virtual

Loads the resource specified by the given type and name.

This function is an extension of QTextDocument::loadResource().

See also
QTextDocument::loadResource()

Reimplemented in QTextBrowser.

Definition at line 1483 of file qtextedit.cpp.

References Q_UNUSED.

◆ mergeCurrentCharFormat()

void QTextEdit::mergeCurrentCharFormat ( const QTextCharFormat & modifier)

Merges the properties specified in modifier into the current character format by calling QTextCursor::mergeCharFormat on the editor's cursor.

If the editor has a selection then the properties of modifier are directly applied to the selection.

See also
QTextCursor::mergeCharFormat()

Definition at line 2284 of file qtextedit.cpp.

References d.

Referenced by setCurrentFont(), setFontFamily(), setFontItalic(), setFontPointSize(), setFontUnderline(), setFontWeight(), setTextBackgroundColor(), and setTextColor().

+ Here is the caller graph for this function:

◆ mouseDoubleClickEvent()

void QTextEdit::mouseDoubleClickEvent ( QMouseEvent * e)
overrideprotectedvirtual

\reimp

Definition at line 1701 of file qtextedit.cpp.

References d.

◆ mouseMoveEvent()

void QTextEdit::mouseMoveEvent ( QMouseEvent * e)
overrideprotectedvirtual

\reimp

Reimplemented in QTextBrowser.

Definition at line 1667 of file qtextedit.cpp.

References QSinglePointEvent::buttons(), QRect::contains(), d, Qt::LeftButton, Qt::MouseEventNotSynthesized, pos, QSinglePointEvent::position(), QMouseEvent::source(), and QPointF::toPoint().

Referenced by QTextBrowser::mouseMoveEvent(), and timerEvent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mousePressEvent()

void QTextEdit::mousePressEvent ( QMouseEvent * e)
overrideprotectedvirtual

\reimp

Reimplemented in QTextBrowser.

Definition at line 1655 of file qtextedit.cpp.

References d.

Referenced by QTextBrowser::mousePressEvent().

+ Here is the caller graph for this function:

◆ mouseReleaseEvent()

void QTextEdit::mouseReleaseEvent ( QMouseEvent * e)
overrideprotectedvirtual

\reimp

Reimplemented in QTextBrowser.

Definition at line 1686 of file qtextedit.cpp.

References QSinglePointEvent::button(), contains(), d, ensureCursorVisible(), isReadOnly(), Qt::MouseEventNotSynthesized, QSinglePointEvent::position(), rect, QMouseEvent::source(), and QPointF::toPoint().

Referenced by QTextBrowser::mouseReleaseEvent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ moveCursor()

void QTextEdit::moveCursor ( QTextCursor::MoveOperation operation,
QTextCursor::MoveMode mode = QTextCursor::MoveAnchor )
Since
4.2 Moves the cursor by performing the given operation.

If mode is QTextCursor::KeepAnchor, the cursor selects the text it moves over. This is the same effect that the user achieves when they hold down the Shift key and move the cursor with the cursor keys.

See also
QTextCursor::movePosition()

Definition at line 2442 of file qtextedit.cpp.

References d.

◆ overwriteMode()

bool QTextEdit::overwriteMode ( ) const

Definition at line 2043 of file qtextedit.cpp.

References d.

◆ paintEvent()

void QTextEdit::paintEvent ( QPaintEvent * event)
overrideprotectedvirtual

This event handler can be reimplemented in a subclass to receive paint events passed in event.

It is usually unnecessary to reimplement this function in a subclass of QTextEdit.

Note
If you create a QPainter, it must operate on the \l{QAbstractScrollArea::}{viewport()}.
Warning
The underlying text document must not be modified from within a reimplementation of this function.

Reimplemented in QTextBrowser.

Definition at line 1630 of file qtextedit.cpp.

References d.

◆ paste

void QTextEdit::paste ( )
slot

Pastes the text from the clipboard into the text edit at the current cursor position.

If there is no text in the clipboard nothing happens.

To change the behavior of this function, i.e. to modify what QTextEdit can paste and how it is being pasted, reimplement the virtual canInsertFromMimeData() and insertFromMimeData() functions.

See also
cut(), copy()

Definition at line 1040 of file qtextedit.cpp.

References d.

◆ placeholderText()

QString QTextEdit::placeholderText ( ) const

Definition at line 810 of file qtextedit.cpp.

References d.

◆ print()

void QTextEdit::print ( QPagedPaintDevice * printer) const
Since
4.3 Convenience function to print the text edit's document to the given printer. This is equivalent to calling the print method on the document directly except that this function also supports QPrinter::Selection as print range.
See also
QTextDocument::print()

Definition at line 2467 of file qtextedit.cpp.

References d.

◆ redo

void QTextEdit::redo ( )
slot
Since
4.2

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.

See also
undo()

Definition at line 980 of file qtextedit.cpp.

References d.

◆ redoAvailable

void QTextEdit::redoAvailable ( bool b)
signal

This signal is emitted whenever redo operations become available (available is true) or unavailable (available is false).

Referenced by QTextEditPrivate::init().

+ Here is the caller graph for this function:

◆ resizeEvent()

void QTextEdit::resizeEvent ( QResizeEvent * e)
overrideprotectedvirtual

\reimp

Definition at line 1492 of file qtextedit.cpp.

References d, QTextDocument::documentLayout(), FixedPixelWidth, QSizeF::isNull(), NoWrap, QResizeEvent::oldSize(), QTextDocument::pageSize, QObject::property(), QResizeEvent::size(), and QSize::width().

+ Here is the call graph for this function:

◆ scrollContentsBy()

void QTextEdit::scrollContentsBy ( int dx,
int dy )
overrideprotectedvirtual

\reimp

Definition at line 1804 of file qtextedit.cpp.

References d, Qt::ImAnchorRectangle, Qt::ImCursorRectangle, and QGuiApplication::inputMethod().

+ Here is the call graph for this function:

◆ scrollToAnchor

void QTextEdit::scrollToAnchor ( const QString & name)
slot

Scrolls the text edit so that the anchor with the given name is visible; does nothing if the name is empty, or is already visible, or isn't found.

Definition at line 2375 of file qtextedit.cpp.

References d, isVisible(), and qRound().

Referenced by showEvent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ selectAll

void QTextEdit::selectAll ( )
slot

Selects all text.

See also
copy(), cut(), textCursor()

Definition at line 1072 of file qtextedit.cpp.

References d.

◆ selectionChanged

void QTextEdit::selectionChanged ( )
signal

This signal is emitted whenever the selection changes.

See also
copyAvailable()

Referenced by QTextEditPrivate::init().

+ Here is the caller graph for this function:

◆ setAcceptRichText()

void QTextEdit::setAcceptRichText ( bool accept)

Definition at line 2120 of file qtextedit.cpp.

References d.

◆ setAlignment

void QTextEdit::setAlignment ( Qt::Alignment a)
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).

Definition at line 752 of file qtextedit.cpp.

References cursor, d, fmt, and QTextBlockFormat::setAlignment().

+ Here is the call graph for this function:

◆ setAutoFormatting()

void QTextEdit::setAutoFormatting ( AutoFormatting features)

Definition at line 2329 of file qtextedit.cpp.

References d.

◆ setCurrentCharFormat()

void QTextEdit::setCurrentCharFormat ( const QTextCharFormat & format)

Sets the char format that is be used when inserting new text to format by calling QTextCursor::setCharFormat() on the editor's cursor.

If the editor has a selection then the char format is directly applied to the selection.

Definition at line 2296 of file qtextedit.cpp.

References d.

◆ setCurrentFont

void QTextEdit::setCurrentFont ( const QFont & f)
slot

Sets the font of the current format to f.

See also
currentFont(), setFontPointSize(), setFontFamily()

Definition at line 957 of file qtextedit.cpp.

References fmt, mergeCurrentCharFormat(), and QTextCharFormat::setFont().

+ Here is the call graph for this function:

◆ setCursorWidth()

void QTextEdit::setCursorWidth ( int width)

Definition at line 2097 of file qtextedit.cpp.

References d.

◆ setDocument()

void QTextEdit::setDocument ( QTextDocument * document)

Definition at line 783 of file qtextedit.cpp.

References d, and document.

Referenced by main().

+ Here is the caller graph for this function:

◆ setDocumentTitle()

void QTextEdit::setDocumentTitle ( const QString & title)
inline

Definition at line 111 of file qtextedit.h.

References QTextDocument::DocumentTitle, and title.

◆ setExtraSelections()

void QTextEdit::setExtraSelections ( const QList< ExtraSelection > & selections)

\variable QTextEdit::ExtraSelection::cursor A cursor that contains a selection in a QTextDocument

\variable QTextEdit::ExtraSelection::format A format that is used to specify a foreground or background brush/color for the selection.

Since
4.2 This function allows temporarily marking certain regions in the document with a given color, specified as selections. This can be useful for example in a programming editor to mark a whole line of text with a given background color to indicate the existence of a breakpoint.
See also
QTextEdit::ExtraSelection, extraSelections()

Definition at line 2155 of file qtextedit.cpp.

References d.

◆ setFontFamily

void QTextEdit::setFontFamily ( const QString & fontFamily)
slot

Sets the font family of the current format to fontFamily.

See also
fontFamily(), setCurrentFont()

Definition at line 862 of file qtextedit.cpp.

References fmt, fontFamily(), mergeCurrentCharFormat(), and QTextCharFormat::setFontFamilies().

+ Here is the call graph for this function:

◆ setFontItalic

void QTextEdit::setFontItalic ( bool italic)
slot

If italic is true, sets the current format to italic; otherwise sets the current format to non-italic.

See also
fontItalic()

Definition at line 919 of file qtextedit.cpp.

References fmt, mergeCurrentCharFormat(), and QTextCharFormat::setFontItalic().

+ Here is the call graph for this function:

◆ setFontPointSize

void QTextEdit::setFontPointSize ( qreal s)
slot

Sets the point size of the current format to s.

Note that if s is zero or negative, the behavior of this function is not defined.

See also
fontPointSize(), setCurrentFont(), setFontFamily()

Definition at line 877 of file qtextedit.cpp.

References fmt, mergeCurrentCharFormat(), and QTextCharFormat::setFontPointSize().

+ Here is the call graph for this function:

◆ setFontUnderline

void QTextEdit::setFontUnderline ( bool underline)
slot

If underline is true, sets the current format to underline; otherwise sets the current format to non-underline.

See also
fontUnderline()

Definition at line 906 of file qtextedit.cpp.

References fmt, mergeCurrentCharFormat(), and QTextCharFormat::setFontUnderline().

+ Here is the call graph for this function:

◆ setFontWeight

void QTextEdit::setFontWeight ( int weight)
slot

Sets the font weight of the current format to the given weight, where the value used is in the range defined by the QFont::Weight enum.

See also
fontWeight(), setCurrentFont(), setFontFamily()

Definition at line 893 of file qtextedit.cpp.

References fmt, mergeCurrentCharFormat(), and QTextCharFormat::setFontWeight().

+ Here is the call graph for this function:

◆ setHtml

void QTextEdit::setHtml ( const QString & text)
slot

Definition at line 1222 of file qtextedit.cpp.

References d, and text.

Referenced by main(), QErrorMessagePrivate::nextPending(), MainWindow::openFile(), setText(), and doc_src_richtext::wrapper2().

+ Here is the caller graph for this function:

◆ setLineWrapColumnOrWidth()

void QTextEdit::setLineWrapColumnOrWidth ( int w)

Definition at line 2554 of file qtextedit.cpp.

References d.

◆ setLineWrapMode()

void QTextEdit::setLineWrapMode ( LineWrapMode mode)

Definition at line 2523 of file qtextedit.cpp.

References d, and wrap().

+ Here is the call graph for this function:

◆ setOverwriteMode()

void QTextEdit::setOverwriteMode ( bool overwrite)

Definition at line 2049 of file qtextedit.cpp.

References d.

◆ setPlaceholderText()

void QTextEdit::setPlaceholderText ( const QString & placeholderText)

Definition at line 816 of file qtextedit.cpp.

References d, and placeholderText.

◆ setPlainText

void QTextEdit::setPlainText ( const QString & text)
slot

Changes the text of the text edit to the string text.

Any previous text is removed.

Notes: \list

  • text is interpreted as plain text.
  • The undo/redo history is also cleared.
  • currentCharFormat() is reset, unless textCursor() is already at the beginning of the document. \endlist
See also
toPlainText()

Definition at line 1179 of file qtextedit.cpp.

References d, and text.

Referenced by dropevents::Window::dropEvent(), QErrorMessagePrivate::nextPending(), MainWindow::openFile(), and setText().

+ Here is the caller graph for this function:

◆ setReadOnly()

void QTextEdit::setReadOnly ( bool ro)

Definition at line 2235 of file qtextedit.cpp.

References d, Qt::NoTextInteraction, QEvent::ReadOnlyChange, QCoreApplication::sendEvent(), setAttribute(), shouldEnableInputMethod(), Qt::TextBrowserInteraction, Qt::TextEditorInteraction, Qt::TextSelectableByMouse, and Qt::WA_InputMethodEnabled.

+ Here is the call graph for this function:

◆ setTabChangesFocus()

void QTextEdit::setTabChangesFocus ( bool b)

Definition at line 2489 of file qtextedit.cpp.

References d.

◆ setTabStopDistance()

void QTextEdit::setTabStopDistance ( qreal distance)

Definition at line 2075 of file qtextedit.cpp.

References d, and opt.

◆ setText

void QTextEdit::setText ( const QString & text)
slot
Since
4.2

Sets the text edit's text. The text can be plain text or HTML and the text edit will try to guess the right format.

Use setHtml() or setPlainText() directly to avoid text edit's guessing.

See also
toPlainText(), toHtml()

Definition at line 2672 of file qtextedit.cpp.

References Qt::mightBeRichText(), Qt::PlainText, Q_UNUSED, Qt::RichText, setHtml(), setPlainText(), and text.

+ Here is the call graph for this function:

◆ setTextBackgroundColor

void QTextEdit::setTextBackgroundColor ( const QColor & c)
slot
Since
4.4

Sets the text background color of the current format to c.

See also
textBackgroundColor()

Definition at line 945 of file qtextedit.cpp.

References fmt, mergeCurrentCharFormat(), and QTextFormat::setBackground().

+ Here is the call graph for this function:

◆ setTextColor

void QTextEdit::setTextColor ( const QColor & c)
slot

Sets the text color of the current format to c.

See also
textColor()

Definition at line 931 of file qtextedit.cpp.

References fmt, mergeCurrentCharFormat(), and QTextFormat::setForeground().

+ Here is the call graph for this function:

◆ setTextCursor()

void QTextEdit::setTextCursor ( const QTextCursor & cursor)

Sets the visible cursor.

Definition at line 829 of file qtextedit.cpp.

References cursor, and doSetTextCursor().

Referenced by keyReleaseEvent(), MainWindow::selectBlock(), MainWindow::selectFrame(), MainWindow::selectLine(), MainWindow::selectWord(), and doc_src_richtext::wrapper2().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setTextInteractionFlags()

void QTextEdit::setTextInteractionFlags ( Qt::TextInteractionFlags flags)

Definition at line 2264 of file qtextedit.cpp.

References d.

◆ setUndoRedoEnabled()

void QTextEdit::setUndoRedoEnabled ( bool enable)
inline

Definition at line 118 of file qtextedit.h.

◆ setWordWrapMode()

void QTextEdit::setWordWrapMode ( QTextOption::WrapMode policy)

Definition at line 2576 of file qtextedit.cpp.

References d.

◆ showEvent()

void QTextEdit::showEvent ( QShowEvent * )
overrideprotectedvirtual

\reimp

Definition at line 1894 of file qtextedit.cpp.

References d, ensureCursorVisible(), and scrollToAnchor().

+ Here is the call graph for this function:

◆ tabChangesFocus()

bool QTextEdit::tabChangesFocus ( ) const

Definition at line 2483 of file qtextedit.cpp.

References d.

◆ tabStopDistance()

qreal QTextEdit::tabStopDistance ( ) const

Definition at line 2069 of file qtextedit.cpp.

References d.

◆ textBackgroundColor()

QColor QTextEdit::textBackgroundColor ( ) const
Since
4.4

Returns the text background color of the current format.

See also
setTextBackgroundColor()

Definition at line 728 of file qtextedit.cpp.

References d, Qt::NoBrush, and Qt::transparent.

◆ textChanged

void QTextEdit::textChanged ( )
signal

This signal is emitted whenever the document's content changes; for example, when text is inserted or deleted, or when formatting is applied.

Referenced by QTextEditPrivate::init().

+ Here is the caller graph for this function:

◆ textColor()

QColor QTextEdit::textColor ( ) const

Returns the text color of the current format.

See also
setTextColor()

Definition at line 715 of file qtextedit.cpp.

References d.

◆ textCursor()

QTextCursor QTextEdit::textCursor ( ) const

Returns a copy of the QTextCursor that represents the currently visible cursor.

Note that changes on the returned cursor do not affect QTextEdit's cursor; use setTextCursor() to update the visible cursor.

Definition at line 851 of file qtextedit.cpp.

References d.

Referenced by MainWindow::copySelection(), MainWindow::cutSelection(), MainWindow::highlightListItems(), MainWindow::insertCalendar(), TextEdit::insertFromMimeData(), MainWindow::insertList(), textdocument_lists::MainWindow::insertList(), main(), main_textblock_formats(), MainWindow::pasteSelection(), MainWindow::selectBlock(), MainWindow::selectFrame(), MainWindow::selectLine(), MainWindow::selectWord(), MainWindow::showList(), MainWindow::showTable(), MainWindow::updateMenus(), and doc_src_richtext::wrapper2().

+ Here is the caller graph for this function:

◆ textInteractionFlags()

Qt::TextInteractionFlags QTextEdit::textInteractionFlags ( ) const

Definition at line 2270 of file qtextedit.cpp.

References d.

◆ timerEvent()

void QTextEdit::timerEvent ( QTimerEvent * e)
overrideprotectedvirtual

Definition at line 1121 of file qtextedit.cpp.

References QRect::adjust(), QRect::bottom(), QRect::center(), clear(), d, QRect::height(), QRect::left(), Qt::LeftButton, QEvent::MouseMove, mouseMoveEvent(), Qt::NoModifier, pos, QCursor::pos(), qMax(), qMin(), QRect::right(), QAbstractSlider::SliderSingleStepAdd, QAbstractSlider::SliderSingleStepSub, QTimerEvent::timerId(), QRect::top(), and QRect::width().

+ Here is the call graph for this function:

◆ toHtml()

QString QTextEdit::toHtml ( ) const

Definition at line 1229 of file qtextedit.cpp.

References d.

◆ toPlainText()

QString QTextEdit::toPlainText ( ) const

QString QTextEdit::toPlainText() const.

Returns the text of the text edit as plain text.

See also
QTextEdit::setPlainText()

Definition at line 1193 of file qtextedit.cpp.

References d.

Referenced by MainWindow::mousePressEvent().

+ Here is the caller graph for this function:

◆ undo

void QTextEdit::undo ( )
slot
Since
4.2

Undoes the last operation.

If there is no operation to undo, i.e. there is no undo step in the undo/redo history, nothing happens.

See also
redo()

Definition at line 974 of file qtextedit.cpp.

References d.

◆ undoAvailable

void QTextEdit::undoAvailable ( bool b)
signal

This signal is emitted whenever undo operations become available (available is true) or unavailable (available is false).

Referenced by QTextEditPrivate::init().

+ Here is the caller graph for this function:

◆ wordWrapMode()

QTextOption::WrapMode QTextEdit::wordWrapMode ( ) const

the mode QTextEdit will use when wrapping text by words

By default, this property is set to QTextOption::WrapAtWordBoundaryOrAnywhere.

See also
QTextOption::WrapMode

Definition at line 2570 of file qtextedit.cpp.

References d.

◆ zoomIn

void QTextEdit::zoomIn ( int range = 1)
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.

See also
zoomOut()

Definition at line 2400 of file qtextedit.cpp.

References zoomInF().

+ Here is the call graph for this function:

◆ zoomInF()

void QTextEdit::zoomInF ( float range)
protected

Definition at line 2420 of file qtextedit.cpp.

References font.

Referenced by zoomIn(), and zoomOut().

+ Here is the caller graph for this function:

◆ zoomOut

void QTextEdit::zoomOut ( int range = 1)
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()

Definition at line 2412 of file qtextedit.cpp.

References zoomInF().

+ Here is the call graph for this function:

Friends And Related Symbol Documentation

◆ QTextDocument

friend class QTextDocument
friend

Definition at line 284 of file qtextedit.h.

◆ QTextEditControl

friend class QTextEditControl
friend

Definition at line 283 of file qtextedit.h.

◆ QWidgetTextControl

friend class QWidgetTextControl
friend

Definition at line 285 of file qtextedit.h.

Property Documentation

◆ acceptRichText

QTextEdit::acceptRichText
readwrite

whether the text edit accepts rich text insertions by the user

Since
4.1

When this property is set to false text edit will accept only plain text input from the user. For example through clipboard or drag and drop.

This property's default is true.

Definition at line 47 of file qtextedit.h.

◆ autoFormatting

QTextEdit::autoFormatting
readwrite

the enabled set of auto formatting features

The value can be any combination of the values in the AutoFormattingFlag enum. The default is AutoNone. Choose AutoAll to enable all automatic formatting.

Currently, the only automatic formatting feature provided is AutoBulletList; future versions of Qt may offer more.

Definition at line 30 of file qtextedit.h.

◆ cursorWidth

QTextEdit::cursorWidth
readwrite
Since
4.2

This property specifies the width of the cursor in pixels. The default value is 1.

Definition at line 48 of file qtextedit.h.

◆ document

QTextEdit::document
readwrite

the underlying document of the text editor.

Note
The editor {does not take ownership of the document} unless it is the document's parent object. The parent object of the provided document remains the owner of the object. If the previously assigned document is a child of the editor then it will be deleted.

Definition at line 51 of file qtextedit.h.

Referenced by TextEdit::insertFromMimeData(), keyPressEvent(), main(), MainWindow::printFile(), MainWindow::printPdf(), setDocument(), doc_src_richtext::wrapper(), and doc_src_richtext::wrapper2().

◆ documentTitle

QTextEdit::documentTitle
readwrite

the title of the document parsed from the text.

By default, for a newly-created, empty document, this property contains an empty string.

Definition at line 32 of file qtextedit.h.

Referenced by QTextBrowser::doSetSource().

◆ html

QTextEdit::html
readwrite

This property provides an HTML interface to the text of the text edit.

toHtml() returns the text of the text edit as html.

setHtml() changes the text of the text edit. Any previous text is removed and the undo/redo history is cleared. The input text is interpreted as rich text in html format. currentCharFormat() is also reset, unless textCursor() is already at the beginning of the document.

Note
It is the responsibility of the caller to make sure that the text is correctly decoded when a QString containing HTML is created and passed to setHtml().

By default, for a newly-created, empty document, this property contains text to describe an HTML 4.0 document with no body text.

See also
{Supported HTML Subset}, plainText

Definition at line 42 of file qtextedit.h.

◆ lineWrapColumnOrWidth

QTextEdit::lineWrapColumnOrWidth
readwrite

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.

By default, this property contains a value of 0.

See also
lineWrapMode

Definition at line 36 of file qtextedit.h.

◆ lineWrapMode

QTextEdit::lineWrapMode
readwrite

the line 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 setWordWrapMode(). If you set a wrap mode of FixedPixelWidth or FixedColumnWidth you should also call setLineWrapColumnOrWidth() with the width you want.

See also
lineWrapColumnOrWidth

Definition at line 34 of file qtextedit.h.

◆ overwriteMode

QTextEdit::overwriteMode
readwrite

whether text entered by the user will overwrite existing text

Since
4.1

As with many text editors, the text editor widget can be configured to insert or overwrite existing text with new text entered by the user.

If this property is true, existing text is overwritten, character-for-character by new text; otherwise, text is inserted at the cursor position, displacing existing text.

By default, this property is false (new text does not overwrite existing text).

Definition at line 45 of file qtextedit.h.

◆ placeholderText

QTextEdit::placeholderText
readwrite

the editor placeholder text

Since
5.2

Setting this property makes the editor display a grayed-out placeholder text as long as the document() is empty.

By default, this property contains an empty string.

See also
document()

Definition at line 52 of file qtextedit.h.

Referenced by setPlaceholderText().

◆ plainText

QTextEdit::plainText
readwrite

the text editor's contents as plain text.

Since
4.3

Previous contents are removed and undo/redo history is reset when the property is set. currentCharFormat() is also reset, unless textCursor() is already at the beginning of the document.

If the text edit has another content type, it will not be replaced by plain text if you call toPlainText(). The only exception to this is the non-break space, {nbsp;}, that will be converted into standard space.

By default, for an editor with no contents, this property contains an empty string.

See also
html

Definition at line 44 of file qtextedit.h.

◆ readOnly

QTextEdit::readOnly
readwrite

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.

This property's default is false.

Definition at line 37 of file qtextedit.h.

◆ tabChangesFocus

QTextEdit::tabChangesFocus
readwrite

whether \uicontrol 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 \uicontrol Tab key, as this breaks the focus chain. The default is false.

Definition at line 31 of file qtextedit.h.

◆ tabStopDistance

QTextEdit::tabStopDistance
readwrite

the tab stop distance in pixels

Since
5.10

By default, this property contains a value of 80 pixels.

Do not set a value less than the \l {QFontMetrics::}{horizontalAdvance()} of the QChar::VisualTabCharacter character, otherwise the tab-character will be drawn incompletely.

See also
QTextOption::ShowTabsAndSpaces, QTextDocument::defaultTextOption

Definition at line 46 of file qtextedit.h.

◆ textInteractionFlags

QTextEdit::textInteractionFlags
readwrite
Since
4.2

Specifies how the widget should interact with user input.

The default value depends on whether the QTextEdit is read-only or editable, and whether it is a QTextBrowser or not.

Definition at line 49 of file qtextedit.h.

◆ undoRedoEnabled

QTextEdit::undoRedoEnabled
readwrite

whether undo and redo are enabled.

Users are only able to undo or redo actions if this property is true, and if there is an action that can be undone (or redone).

Definition at line 33 of file qtextedit.h.


The documentation for this class was generated from the following files: