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
TextEdit Class Reference

#include <textedit.h>

+ Inheritance diagram for TextEdit:
+ Collaboration diagram for TextEdit:

Public Member Functions

 TextEdit (QWidget *parent=nullptr)
 
bool canInsertFromMimeData (const QMimeData *source) const override
 [0]
 
void insertFromMimeData (const QMimeData *source) override
 [0]
 
- Public Member Functions inherited from QTextEdit
 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
 

Additional Inherited Members

- Public Types inherited from QTextEdit
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 inherited from QTextEdit
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 inherited from QTextEdit
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.
 
- Protected Member Functions inherited from QTextEdit
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 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 inherited from QTextEdit
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
 

Detailed Description

Definition at line 9 of file textedit.h.

Constructor & Destructor Documentation

◆ TextEdit()

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

Definition at line 7 of file textedit.cpp.

Member Function Documentation

◆ canInsertFromMimeData()

bool TextEdit::canInsertFromMimeData ( const QMimeData * source) const
overridevirtual

[0]

Reimplemented from QTextEdit.

Definition at line 13 of file textedit.cpp.

References QTextEdit::canInsertFromMimeData().

+ Here is the call graph for this function:

◆ insertFromMimeData()

void TextEdit::insertFromMimeData ( const QMimeData * source)
overridevirtual

[0]

[1]

Reimplemented from QTextEdit.

Definition at line 23 of file textedit.cpp.

References QTextDocument::addResource(), cursor, QTextEdit::document, QTextDocument::ImageResource, and QTextEdit::textCursor().

+ Here is the call graph for this function:

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