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¶
- class qgis.gui.QgsRichTextEditor[source]¶
Bases:
QWidget- __init__(parent: QWidget | None = None)
Constructor for QgsRichTextEditor, with the specified
parentwidget.- Parameters:
parent (Optional[QWidget] = None)
- class Mode(*values)¶
Bases:
IntEnumWidget 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 theQgsTextRendererclassPlainText: 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
textto show in the widget.The
textcan 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)
- signal textChanged[source]¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- 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]