![]() |
Qt 6.x
The Qt SDK
|
The QTextEdit class provides a widget that is used to edit and display both plain and rich text. More...
#include <qtextedit.h>
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) |
QTextDocument * | document () 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. | |
QMenu * | createStandardContextMenu () |
\reimp | |
QMenu * | createStandardContextMenu (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< ExtraSelection > | extraSelections () 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 QMimeData * | createMimeDataFromSelection () 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 |
QTextDocument * | document |
the underlying document of the text editor. | |
QString | placeholderText |
the editor placeholder text | |
Friends | |
class | QTextDocument |
class | QWidgetTextControl |
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.
\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.
\value NoWrap \value WidgetWidth \value FixedPixelWidth \value FixedColumnWidth
Enumerator | |
---|---|
NoWrap | |
WidgetWidth | |
FixedPixelWidth | |
FixedColumnWidth |
Definition at line 54 of file qtextedit.h.
Constructs an empty QTextEdit with parent parent.
Definition at line 601 of file qtextedit.cpp.
References d.
Constructs a QTextEdit with parent parent.
The text edit will display the text text. The text is interpreted as html.
Definition at line 622 of file qtextedit.cpp.
|
virtual |
Destructor.
Definition at line 634 of file qtextedit.cpp.
|
protected |
Definition at line 611 of file qtextedit.cpp.
References d.
bool QTextEdit::acceptRichText | ( | ) | const |
Definition at line 2098 of file qtextedit.cpp.
References d.
Qt::Alignment QTextEdit::alignment | ( | ) | const |
Returns the alignment of the current paragraph.
Definition at line 753 of file qtextedit.cpp.
References d.
Returns the reference of the anchor at position pos, or an empty string if no anchor exists at that point.
Definition at line 2006 of file qtextedit.cpp.
Appends a new paragraph with text to the end of the text edit.
Definition at line 2679 of file qtextedit.cpp.
References d, isReadOnly(), and text.
Referenced by main().
QTextEdit::AutoFormatting QTextEdit::autoFormatting | ( | ) | const |
Definition at line 2307 of file qtextedit.cpp.
References d.
|
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 2182 of file qtextedit.cpp.
References d.
Referenced by TextEdit::canInsertFromMimeData(), and QTextEditControl::canInsertFromMimeData().
bool QTextEdit::canPaste | ( | ) | const |
Definition at line 2436 of file qtextedit.cpp.
References d.
\reimp
Definition at line 1892 of file qtextedit.cpp.
References QEvent::ActivationChange, QEvent::ApplicationFontChange, d, e, QEvent::EnabledChange, font, QEvent::FontChange, QEvent::LayoutDirectionChange, palette, and QEvent::PaletteChange.
|
slot |
Deletes all the text in the text edit.
Notes: \list
Definition at line 1044 of file qtextedit.cpp.
References d.
Referenced by timerEvent().
|
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.
Definition at line 1716 of file qtextedit.cpp.
|
slot |
Copies any selected text to the clipboard.
Definition at line 1005 of file qtextedit.cpp.
References d.
|
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.
|
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 2167 of file qtextedit.cpp.
References d.
Referenced by QTextEditControl::createMimeDataFromSelection().
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 1942 of file qtextedit.cpp.
References d.
Definition at line 1958 of file qtextedit.cpp.
References d, and position().
QTextCharFormat QTextEdit::currentCharFormat | ( | ) | const |
Returns the char format that is used when inserting new text.
Definition at line 2289 of file qtextedit.cpp.
References d.
|
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.
QFont QTextEdit::currentFont | ( | ) | const |
QTextCursor QTextEdit::cursorForPosition | ( | const QPoint & | pos | ) | const |
returns a QTextCursor at position pos (in viewport coordinates).
Definition at line 1968 of file qtextedit.cpp.
|
signal |
This signal is emitted whenever the position of the cursor changed.
QRect QTextEdit::cursorRect | ( | ) | const |
returns a rectangle (in viewport coordinates) that includes the cursor of the text edit.
Definition at line 1993 of file qtextedit.cpp.
References d.
Referenced by event().
QRect QTextEdit::cursorRect | ( | const QTextCursor & | cursor | ) | const |
returns a rectangle (in viewport coordinates) that includes the cursor.
Definition at line 1978 of file qtextedit.cpp.
int QTextEdit::cursorWidth | ( | ) | const |
Definition at line 2075 of file qtextedit.cpp.
References d.
|
slot |
Copies the selected text to the clipboard and deletes it from the text edit.
If there is no selected text nothing happens.
Definition at line 993 of file qtextedit.cpp.
References d.
QTextDocument * QTextEdit::document | ( | ) | const |
Definition at line 776 of file qtextedit.cpp.
References d.
|
inline |
Definition at line 113 of file qtextedit.h.
References QTextDocument::DocumentTitle.
|
protectedvirtual |
This provides a hook for subclasses to intercept cursor changes.
Definition at line 825 of file qtextedit.cpp.
Referenced by setTextCursor().
void QTextEdit::ensureCursorVisible | ( | ) |
Ensures that the cursor is visible by scrolling the text edit if necessary.
Definition at line 2693 of file qtextedit.cpp.
References d.
Referenced by event(), inputMethodEvent(), mouseReleaseEvent(), and showEvent().
|
overrideprotectedvirtual |
Reimplemented in QTextBrowser.
Definition at line 1065 of file qtextedit.cpp.
References QRect::center(), QEvent::ContextMenu, cursorRect(), d, e, ensureCursorVisible(), QEvent::isAccepted(), QContextMenuEvent::Keyboard, Q_UNUSED, QContextMenuEvent::reason(), QEvent::setAccepted(), QEvent::ShortcutOverride, and QEvent::ToolTip.
Referenced by QTextBrowser::event().
QList< QTextEdit::ExtraSelection > QTextEdit::extraSelections | ( | ) | const |
Definition at line 2151 of file qtextedit.cpp.
References d.
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
.
Finds the next occurrence, matching the regular expression, exp, using the given options. The QTextDocument::FindCaseSensitively option is ignored for this overload, use QRegularExpression::CaseInsensitiveOption instead.
Returns true
if a match was found and changes the cursor to select the match; otherwise returns false
.
Definition at line 2574 of file qtextedit.cpp.
References d.
|
overrideprotectedvirtual |
|
overrideprotectedvirtual |
\reimp
Reimplemented in QTextBrowser.
Definition at line 1692 of file qtextedit.cpp.
References d, next, and Qt::TextEditable.
Referenced by QTextBrowser::focusNextPrevChild().
|
overrideprotectedvirtual |
\reimp
Reimplemented in QTextBrowser.
Definition at line 1868 of file qtextedit.cpp.
Referenced by QTextBrowser::focusOutEvent().
QString QTextEdit::fontFamily | ( | ) | const |
Returns the font family of the current format.
Definition at line 654 of file qtextedit.cpp.
References d.
Referenced by setFontFamily().
bool QTextEdit::fontItalic | ( | ) | const |
Returns true
if the font of the current format is italic; otherwise returns false.
Definition at line 689 of file qtextedit.cpp.
References d.
qreal QTextEdit::fontPointSize | ( | ) | const |
Returns the point size of the font of the current format.
Definition at line 643 of file qtextedit.cpp.
References d.
bool QTextEdit::fontUnderline | ( | ) | const |
Returns true
if the font of the current format is underlined; otherwise returns false.
Definition at line 677 of file qtextedit.cpp.
References d.
int QTextEdit::fontWeight | ( | ) | const |
Returns the font weight of the current format.
Definition at line 665 of file qtextedit.cpp.
References d.
|
overrideprotectedvirtual |
\reimp
Definition at line 1768 of file qtextedit.cpp.
References d, e, ensureCursorVisible(), and Qt::TextEditable.
|
override |
\reimp
Definition at line 1798 of file qtextedit.cpp.
References inputMethodQuery(), and property.
Referenced by inputMethodQuery().
QVariant QTextEdit::inputMethodQuery | ( | Qt::InputMethodQuery | query, |
QVariant | argument | ||
) | const |
Definition at line 1805 of file qtextedit.cpp.
References argument, d, Qt::ImEnabled, Qt::ImHints, Qt::ImInputItemClipRectangle, Qt::ImReadOnly, QWidget::inputMethodQuery(), and isReadOnly().
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 2197 of file qtextedit.cpp.
References d.
Referenced by QTextEditControl::insertFromMimeData().
Convenience slot that inserts text which is assumed to be of html formatting at the current cursor position.
It is equivalent to:
Definition at line 2347 of file qtextedit.cpp.
Convenience slot that inserts text at the current cursor position.
It is equivalent to
Definition at line 2327 of file qtextedit.cpp.
bool QTextEdit::isReadOnly | ( | ) | const |
Definition at line 2213 of file qtextedit.cpp.
References d, and Qt::TextEditable.
Referenced by append(), inputMethodQuery(), keyReleaseEvent(), mouseReleaseEvent(), shouldEnableInputMethod(), and shouldEnableInputMethod().
|
inline |
Definition at line 116 of file qtextedit.h.
\reimp
Reimplemented in QTextBrowser.
Definition at line 1267 of file qtextedit.cpp.
References QTextCharFormat::anchorHref(), QString::at(), AutoBulletList, Qt::ControlModifier, cursor, d, document, QTextCursor::Down, e, QString::isEmpty(), QTextCursor::KeepAnchor, Qt::Key_Back, Qt::Key_Down, Qt::Key_End, Qt::Key_Home, Qt::Key_No, Qt::Key_Select, Qt::Key_Space, Qt::Key_Up, Qt::LinksAccessibleByKeyboard, QTextCursor::MoveAnchor, QKeySequence::MoveToNextPage, QKeySequence::MoveToPreviousPage, Qt::NoModifier, QKeySequence::SelectNextPage, QKeySequence::SelectPreviousPage, Qt::ShiftModifier, QString::size(), QAbstractSlider::SliderPageStepAdd, QAbstractSlider::SliderPageStepSub, QAbstractSlider::SliderToMaximum, QAbstractSlider::SliderToMinimum, text, Qt::TextEditable, Qt::TextSelectableByKeyboard, and QTextCursor::Up.
Referenced by QTextBrowser::keyPressEvent().
\reimp
Definition at line 1422 of file qtextedit.cpp.
References cursor, d, e, QTextBlockFormat::indent(), isReadOnly(), Qt::Key_Back, list, QList< T >::remove(), QTextBlockFormat::setIndent(), and setTextCursor().
int QTextEdit::lineWrapColumnOrWidth | ( | ) | const |
Definition at line 2532 of file qtextedit.cpp.
References d.
QTextEdit::LineWrapMode QTextEdit::lineWrapMode | ( | ) | const |
Definition at line 2501 of file qtextedit.cpp.
References d.
Loads the resource specified by the given type and name.
This function is an extension of QTextDocument::loadResource().
Reimplemented in QTextBrowser.
Definition at line 1460 of file qtextedit.cpp.
References Q_UNUSED.
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.
Definition at line 2268 of file qtextedit.cpp.
References d.
Referenced by setCurrentFont(), setFontFamily(), setFontItalic(), setFontPointSize(), setFontUnderline(), setFontWeight(), setTextBackgroundColor(), and setTextColor().
|
overrideprotectedvirtual |
|
overrideprotectedvirtual |
\reimp
Reimplemented in QTextBrowser.
Definition at line 1650 of file qtextedit.cpp.
References QRect::contains(), d, e, Qt::LeftButton, Qt::MouseEventNotSynthesized, and pos.
Referenced by QTextBrowser::mouseMoveEvent(), and timerEvent().
|
overrideprotectedvirtual |
\reimp
Reimplemented in QTextBrowser.
Definition at line 1638 of file qtextedit.cpp.
Referenced by QTextBrowser::mousePressEvent().
|
overrideprotectedvirtual |
\reimp
Reimplemented in QTextBrowser.
Definition at line 1669 of file qtextedit.cpp.
References contains(), d, e, ensureCursorVisible(), isReadOnly(), Qt::MouseEventNotSynthesized, and rect.
Referenced by QTextBrowser::mouseReleaseEvent().
void QTextEdit::moveCursor | ( | QTextCursor::MoveOperation | operation, |
QTextCursor::MoveMode | mode = QTextCursor::MoveAnchor |
||
) |
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.
Definition at line 2426 of file qtextedit.cpp.
References d.
bool QTextEdit::overwriteMode | ( | ) | const |
Definition at line 2027 of file qtextedit.cpp.
References d.
|
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.
Reimplemented in QTextBrowser.
Definition at line 1607 of file qtextedit.cpp.
|
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.
Definition at line 1025 of file qtextedit.cpp.
References d.
QString QTextEdit::placeholderText | ( | ) | const |
Definition at line 795 of file qtextedit.cpp.
References d.
void QTextEdit::print | ( | QPagedPaintDevice * | printer | ) | const |
Definition at line 2451 of file qtextedit.cpp.
References d.
|
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.
Definition at line 965 of file qtextedit.cpp.
References d.
|
signal |
This signal is emitted whenever redo operations become available (available is true) or unavailable (available is false).
|
overrideprotectedvirtual |
\reimp
Definition at line 1469 of file qtextedit.cpp.
References d, QTextDocument::documentLayout(), e, FixedPixelWidth, QSizeF::isNull(), NoWrap, QTextDocument::pageSize, QObject::property(), QVariant::toBool(), and QVariant::userType().
|
overrideprotectedvirtual |
\reimp
Definition at line 1787 of file qtextedit.cpp.
References d, Qt::ImAnchorRectangle, Qt::ImCursorRectangle, QGuiApplication::inputMethod(), and QInputMethod::update().
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 2359 of file qtextedit.cpp.
References d, isVisible(), and qRound().
Referenced by showEvent().
|
slot |
Selects all text.
Definition at line 1057 of file qtextedit.cpp.
References d.
|
signal |
This signal is emitted whenever the selection changes.
void QTextEdit::setAcceptRichText | ( | bool | accept | ) |
Definition at line 2104 of file qtextedit.cpp.
References d.
|
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 737 of file qtextedit.cpp.
void QTextEdit::setAutoFormatting | ( | AutoFormatting | features | ) |
Definition at line 2313 of file qtextedit.cpp.
References d.
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 2280 of file qtextedit.cpp.
References d.
Sets the font of the current format to f.
Definition at line 942 of file qtextedit.cpp.
References fmt, and mergeCurrentCharFormat().
void QTextEdit::setCursorWidth | ( | int | width | ) |
Definition at line 2081 of file qtextedit.cpp.
References d.
void QTextEdit::setDocument | ( | QTextDocument * | document | ) |
Definition at line 768 of file qtextedit.cpp.
Referenced by main().
Definition at line 111 of file qtextedit.h.
References QTextDocument::DocumentTitle, and title.
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.
Definition at line 2139 of file qtextedit.cpp.
References d.
Sets the font family of the current format to fontFamily.
Definition at line 847 of file qtextedit.cpp.
References fmt, fontFamily(), and mergeCurrentCharFormat().
|
slot |
If italic is true, sets the current format to italic; otherwise sets the current format to non-italic.
Definition at line 904 of file qtextedit.cpp.
References fmt, and mergeCurrentCharFormat().
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.
Definition at line 862 of file qtextedit.cpp.
References fmt, and mergeCurrentCharFormat().
|
slot |
If underline is true, sets the current format to underline; otherwise sets the current format to non-underline.
Definition at line 891 of file qtextedit.cpp.
References fmt, and mergeCurrentCharFormat().
|
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.
Definition at line 878 of file qtextedit.cpp.
References fmt, and mergeCurrentCharFormat().
Definition at line 1199 of file qtextedit.cpp.
Referenced by main(), QErrorMessagePrivate::nextPending(), MainWindow::openFile(), setText(), and doc_src_richtext::wrapper2().
void QTextEdit::setLineWrapColumnOrWidth | ( | int | w | ) |
Definition at line 2538 of file qtextedit.cpp.
References d.
void QTextEdit::setLineWrapMode | ( | LineWrapMode | mode | ) |
void QTextEdit::setOverwriteMode | ( | bool | overwrite | ) |
Definition at line 2033 of file qtextedit.cpp.
References d.
Definition at line 801 of file qtextedit.cpp.
References d, and placeholderText.
Changes the text of the text edit to the string text.
Any previous text is removed.
Notes: \list
Definition at line 1156 of file qtextedit.cpp.
Referenced by dropevents::Window::dropEvent(), QErrorMessagePrivate::nextPending(), MainWindow::openFile(), and setText().
void QTextEdit::setReadOnly | ( | bool | ro | ) |
Definition at line 2219 of file qtextedit.cpp.
References d, Qt::NoTextInteraction, QEvent::ReadOnlyChange, QCoreApplication::sendEvent(), setAttribute(), shouldEnableInputMethod(), Qt::TextBrowserInteraction, Qt::TextEditorInteraction, Qt::TextSelectableByMouse, and Qt::WA_InputMethodEnabled.
void QTextEdit::setTabChangesFocus | ( | bool | b | ) |
Definition at line 2473 of file qtextedit.cpp.
References d.
Definition at line 2059 of file qtextedit.cpp.
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.
Definition at line 2653 of file qtextedit.cpp.
References Qt::AutoText, d, Qt::mightBeRichText(), Qt::PlainText, Q_UNUSED, Qt::RichText, setHtml(), setPlainText(), and text.
Sets the text background color of the current format to c.
Definition at line 930 of file qtextedit.cpp.
References fmt, and mergeCurrentCharFormat().
Sets the text color of the current format to c.
Definition at line 916 of file qtextedit.cpp.
References fmt, and mergeCurrentCharFormat().
void QTextEdit::setTextCursor | ( | const QTextCursor & | cursor | ) |
Sets the visible cursor.
Definition at line 814 of file qtextedit.cpp.
References cursor, and doSetTextCursor().
Referenced by keyReleaseEvent(), MainWindow::selectBlock(), MainWindow::selectFrame(), MainWindow::selectLine(), MainWindow::selectWord(), and doc_src_richtext::wrapper2().
void QTextEdit::setTextInteractionFlags | ( | Qt::TextInteractionFlags | flags | ) |
Definition at line 2248 of file qtextedit.cpp.
References d.
|
inline |
Definition at line 118 of file qtextedit.h.
void QTextEdit::setWordWrapMode | ( | QTextOption::WrapMode | policy | ) |
Definition at line 2560 of file qtextedit.cpp.
References d.
|
overrideprotectedvirtual |
\reimp
Definition at line 1877 of file qtextedit.cpp.
References d, ensureCursorVisible(), and scrollToAnchor().
bool QTextEdit::tabChangesFocus | ( | ) | const |
Definition at line 2467 of file qtextedit.cpp.
References d.
qreal QTextEdit::tabStopDistance | ( | ) | const |
Definition at line 2053 of file qtextedit.cpp.
References d.
QColor QTextEdit::textBackgroundColor | ( | ) | const |
Returns the text background color of the current format.
Definition at line 713 of file qtextedit.cpp.
References d, Qt::NoBrush, and Qt::transparent.
|
signal |
This signal is emitted whenever the document's content changes; for example, when text is inserted or deleted, or when formatting is applied.
QColor QTextEdit::textColor | ( | ) | const |
Returns the text color of the current format.
Definition at line 700 of file qtextedit.cpp.
References d.
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 836 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().
Qt::TextInteractionFlags QTextEdit::textInteractionFlags | ( | ) | const |
Definition at line 2254 of file qtextedit.cpp.
References d.
|
overrideprotectedvirtual |
Definition at line 1098 of file qtextedit.cpp.
References QRect::adjust(), QRect::bottom(), QRect::center(), clear(), d, e, QRect::height(), QRect::left(), Qt::LeftButton, QEvent::MouseMove, mouseMoveEvent(), Qt::NoModifier, pos, QCursor::pos(), qMax(), qMin(), QRect::right(), QAbstractSlider::SliderSingleStepAdd, QAbstractSlider::SliderSingleStepSub, QRect::top(), QRect::width(), QPoint::x(), and QPoint::y().
QString QTextEdit::toHtml | ( | ) | const |
Definition at line 1206 of file qtextedit.cpp.
References d.
QString QTextEdit::toPlainText | ( | ) | const |
QString QTextEdit::toPlainText() const.
Returns the text of the text edit as plain text.
Definition at line 1170 of file qtextedit.cpp.
References d.
Referenced by MainWindow::mousePressEvent().
|
slot |
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.
Definition at line 959 of file qtextedit.cpp.
References d.
|
signal |
This signal is emitted whenever undo operations become available (available is true) or unavailable (available is false).
QTextOption::WrapMode QTextEdit::wordWrapMode | ( | ) | const |
the mode QTextEdit will use when wrapping text by words
By default, this property is set to QTextOption::WrapAtWordBoundaryOrAnywhere.
Definition at line 2554 of file qtextedit.cpp.
References d.
|
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.
Definition at line 2384 of file qtextedit.cpp.
References zoomInF().
|
protected |
Definition at line 2404 of file qtextedit.cpp.
References font.
Referenced by zoomIn(), and zoomOut().
|
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.
Definition at line 2396 of file qtextedit.cpp.
References zoomInF().
|
friend |
Definition at line 292 of file qtextedit.h.
|
friend |
Definition at line 293 of file qtextedit.h.
|
readwrite |
whether the text edit accepts rich text insertions by the user
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 298 of file qtextedit.h.
|
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 298 of file qtextedit.h.
|
readwrite |
This property specifies the width of the cursor in pixels. The default value is 1.
Definition at line 298 of file qtextedit.h.
|
readwrite |
the underlying document of the text editor.
Definition at line 298 of file qtextedit.h.
Referenced by TextEdit::insertFromMimeData(), keyPressEvent(), main(), main(), MainWindow::printFile(), MainWindow::printPdf(), setDocument(), doc_src_richtext::wrapper(), and doc_src_richtext::wrapper2().
|
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 298 of file qtextedit.h.
Referenced by QTextBrowser::doSetSource().
|
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.
By default, for a newly-created, empty document, this property contains text to describe an HTML 4.0 document with no body text.
Definition at line 298 of file qtextedit.h.
|
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.
Definition at line 298 of file qtextedit.h.
|
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.
Definition at line 298 of file qtextedit.h.
|
readwrite |
whether text entered by the user will overwrite existing text
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 298 of file qtextedit.h.
|
readwrite |
the editor placeholder text
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.
Definition at line 298 of file qtextedit.h.
Referenced by setPlaceholderText().
|
readwrite |
the text editor's contents as plain text.
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.
Definition at line 298 of file qtextedit.h.
|
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 298 of file qtextedit.h.
|
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 298 of file qtextedit.h.
|
readwrite |
the tab stop distance in pixels
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.
Definition at line 298 of file qtextedit.h.
|
readwrite |
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 298 of file qtextedit.h.
Referenced by shouldEnableInputMethod(), and shouldEnableInputMethod().
|
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 298 of file qtextedit.h.