QGIS API Documentation 4.3.0-Master (0de80482b60)
Loading...
Searching...
No Matches
QgsRichTextEditor Class Reference

A widget for editing rich text documents, with support for user controlled formatting of text and insertion of hyperlinks and images. More...

#include <qgsrichtexteditor.h>

Inheritance diagram for QgsRichTextEditor:

Public Types

enum class  Mode { QTextDocument , QgsTextRenderer , PlainText }
 Widget modes. More...

Public Slots

void clearSource ()
 Clears the current text from the widget.
void setText (const QString &text)
 Sets the text to show in the widget.

Signals

void textChanged ()
 Emitted when the text contents are changed.

Public Member Functions

 QgsRichTextEditor (QWidget *parent=nullptr)
 Constructor for QgsRichTextEditor, with the specified parent widget.
QTextDocument * document ()
 Returns a reference to the QTextDocument shown in the widget.
Mode mode () const
 Returns the widget's mode, which defines which formatting options are exposed in the widget.
void setMode (Mode mode)
 Sets the widget's mode, which defines which formatting options are exposed in the widget.
void setTextCursor (const QTextCursor &cursor)
 Sets the current text cursor.
QTextCursor textCursor () const
 Returns a reference to the text cursor.
QTextEdit * textEdit ()
 Returns the widget's QTextEditor control.
QString toHtml () const
 Returns the widget's content as a HTML string.
QToolBar * toolBar ()
 Returns the widget's toolbar.
QString toPlainText () const
 Returns the widget's content as a plain text string.

Protected Member Functions

void focusInEvent (QFocusEvent *event) override

Detailed Description

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.

Since
QGIS 3.20

Definition at line 61 of file qgsrichtexteditor.h.

Member Enumeration Documentation

◆ Mode

enum class QgsRichTextEditor::Mode
strong

Widget modes.

Since
QGIS 3.40
Enumerator
QTextDocument 

Default mode, exposes the Qt supported HTML/CSS subset.

QgsTextRenderer 

QGIS text renderer mode, exposes the HTML/CSS subset supported by the QgsTextRenderer class.

PlainText 

Plain text mode.

Definition at line 70 of file qgsrichtexteditor.h.

Constructor & Destructor Documentation

◆ QgsRichTextEditor()

QgsRichTextEditor::QgsRichTextEditor ( QWidget * parent = nullptr)

Constructor for QgsRichTextEditor, with the specified parent widget.

Definition at line 64 of file qgsrichtexteditor.cpp.

Member Function Documentation

◆ clearSource

void QgsRichTextEditor::clearSource ( )
slot

Clears the current text from the widget.

Definition at line 372 of file qgsrichtexteditor.cpp.

◆ document()

QTextDocument * QgsRichTextEditor::document ( )
inline

Returns a reference to the QTextDocument shown in the widget.

Definition at line 135 of file qgsrichtexteditor.h.

◆ focusInEvent()

void QgsRichTextEditor::focusInEvent ( QFocusEvent * event)
overrideprotected

Definition at line 415 of file qgsrichtexteditor.cpp.

◆ mode()

Mode QgsRichTextEditor::mode ( ) const
inline

Returns the widget's mode, which defines which formatting options are exposed in the widget.

See also
setMode()
Since
QGIS 3.40

Definition at line 90 of file qgsrichtexteditor.h.

◆ setMode()

void QgsRichTextEditor::setMode ( Mode mode)

Sets the widget's mode, which defines which formatting options are exposed in the widget.

See also
mode()
Since
QGIS 3.40

Definition at line 155 of file qgsrichtexteditor.cpp.

◆ setText

void QgsRichTextEditor::setText ( const QString & text)
slot

Sets the text to show in the widget.

The text can either be a plain text string or a HTML document.

Definition at line 768 of file qgsrichtexteditor.cpp.

◆ setTextCursor()

void QgsRichTextEditor::setTextCursor ( const QTextCursor & cursor)
inline

Sets the current text cursor.

See also
textCursor()

Definition at line 149 of file qgsrichtexteditor.h.

◆ textChanged

void QgsRichTextEditor::textChanged ( )
signal

Emitted when the text contents are changed.

Since
QGIS 3.26

◆ textCursor()

QTextCursor QgsRichTextEditor::textCursor ( ) const
inline

Returns a reference to the text cursor.

See also
setTextCursor()

Definition at line 142 of file qgsrichtexteditor.h.

◆ textEdit()

QTextEdit * QgsRichTextEditor::textEdit ( )
inline

Returns the widget's QTextEditor control.

Since
QGIS 3.40

Definition at line 120 of file qgsrichtexteditor.h.

◆ toHtml()

QString QgsRichTextEditor::toHtml ( ) const

Returns the widget's content as a HTML string.

See also
toPlainText()

Definition at line 320 of file qgsrichtexteditor.cpp.

◆ toolBar()

QToolBar * QgsRichTextEditor::toolBar ( )
inline

Returns the widget's toolbar.

Exposed so that embedders can adapt it to the space they have, e.g. by shrinking its icons or rehosting its actions.

Since
QGIS 4.4

Definition at line 130 of file qgsrichtexteditor.h.

◆ toPlainText()

QString QgsRichTextEditor::toPlainText ( ) const

Returns the widget's content as a plain text string.

See also
toHtml()

Definition at line 302 of file qgsrichtexteditor.cpp.


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