Class: QgsRichTextEditor¶
A widget for editing rich text documents, with support for user controlled formatting of text and insertion of hyperlinks and images.
QgsRichTextEditor
provides a reusable widget for allowing
users to edit rich text documents, and retrieving and setting the
documents via HTML formatted strings.
Added in version 3.20.
Class Hierarchy¶
Base classes¶
Enums
Widget modes. |
Methods
Clears the current text from the widget. |
|
Returns a reference to the QTextDocument shown in the widget. |
|
Returns the widget's mode, which defines which formatting options are exposed in the widget. |
|
Sets the widget's mode, which defines which formatting options are exposed in the widget. |
|
Sets the text to show in the widget. |
|
Sets the current text cursor. |
|
Returns a reference to the text cursor. |
|
Returns the widget's QTextEditor control. |
|
Returns the widget's content as a HTML string. |
|
Returns the widget's content as a plain text string. |
Signals
Emitted when the text contents are changed. |
- class qgis.gui.QgsRichTextEditor[source]¶
Bases:
QWidget
- __init__(parent: QWidget | None = None)
Constructor for QgsRichTextEditor, with the specified
parent
widget.- Parameters:
parent (Optional[QWidget] = None)
- class Mode(*values)¶
Bases:
IntEnum
Widget modes.
Added in version 3.40.
QTextDocument
: Default mode, exposes the Qt supported HTML/CSS subsetQgsTextRenderer
: QGIS text renderer mode, exposes the HTML/CSS subset supported by theQgsTextRenderer
classPlainText
: Plain text mode
- PlainText = 2¶
- QTextDocument = 0¶
- QgsTextRenderer = 1¶
- document(self) QTextDocument | None [source]¶
Returns a reference to the QTextDocument shown in the widget.
- Return type:
Optional[QTextDocument]
- mode(self) QgsRichTextEditor.Mode [source]¶
Returns the widget’s mode, which defines which formatting options are exposed in the widget.
See also
Added in version 3.40.
- Return type:
- setMode(self, mode: QgsRichTextEditor.Mode)[source]¶
Sets the widget’s
mode
, which defines which formatting options are exposed in the widget.See also
Added in version 3.40.
- Parameters:
mode (QgsRichTextEditor.Mode)
- setText(self, text: str | None)[source]¶
Sets the
text
to show in the widget.The
text
can either be a plain text string or a HTML document.- Parameters:
text (Optional[str])
- setTextCursor(self, cursor: QTextCursor)[source]¶
Sets the current text
cursor
.See also
- Parameters:
cursor (QTextCursor)
- textCursor(self) QTextCursor [source]¶
Returns a reference to the text cursor.
See also
- Return type:
QTextCursor
- textEdit(self) QTextEdit | None [source]¶
Returns the widget’s QTextEditor control.
Added in version 3.40.
- Return type:
Optional[QTextEdit]