- Qt 6.11
- Qt GUI
- Rich Text Processing
- Qt 6.11.1 Reference Documentation

Rendering in 3D ◦ Rich Text Document Structure

# Rich Text Processing

Qt provides a set of classes for creating, editing, and rendering structured rich text documents. These classes center around QTextDocument, which represents a rich text document with a well-defined internal structure. Working directly with QTextDocument allows applications to create, modify, and inspect rich text without relying on intermediate markup formats.

You can access document information via two complementary interfaces:

Interface | Description
--- | ---
Cursor-based interface (QTextCursor) | Supports editing operations that mimic user actions in a text editor. Edits maintain the structural integrity of the underlying document.
Read-only hierarchical interface | Provides a high-level structural view of the document. It is useful for tasks such as searching, inspection, and exporting content.

## Rich Text Serialization

QTextDocument supports serialization to and from these markup formats:

- HTML: A defined subset of HTML is supported for loading and saving. See Supported HTML Subset.
- Markdown: QTextDocument can parse Markdown in both CommonMark and GitHub dialects.

## Rich Text Topics

- Rich Text Document Structure describes the different elements in a QTextDocument and how they are arranged in a document structure.
- The QTextCursor Interface explains how to edit rich text documents using the cursor-based interface.
- Document Layouts describes how to visually arrange document contents.
- Common Rich Text Editing Tasks describes frequently used operations for reading and manipulating rich text such as selecting, searching, and printing.
- Advanced Rich Text Processing describes advanced rich text editing tasks such as handling large files.
- Supported HTML Subset lists the HTML tags supported by QTextDocument.

## Rich Text Processing APIs

Qt provides an extensive collection of classes for parsing, rendering manipulating and editing rich text.

QAbstractTextDocumentLayout | Abstract base class used to implement custom layouts for QTextDocuments
QFont | Specifies a query for a font used for drawing text
QPlainTextDocumentLayout | Implements a plain text layout for QTextDocument
QPlainTextEdit | Widget that is used to edit and display plain text
QSyntaxHighlighter | Allows you to define syntax highlighting rules, and in addition you can use the class to query a document's current formatting or user data
QTextBlock | Container for text fragments in a QTextDocument
QTextBlock::iterator | QTextBlock::iterator class provides an iterator for reading the contents of a QTextBlock
QTextBlockFormat | Formatting information for blocks of text in a QTextDocument
QTextBlockGroup | Container for text blocks within a QTextDocument
QTextBlockUserData | Used to associate custom data with blocks of text
QTextBrowser | Rich text browser with hypertext navigation
QTextCharFormat | Formatting information for characters in a QTextDocument
QTextCursor | Offers an API to access and modify QTextDocuments
QTextDocument | Holds formatted text
QTextDocumentFragment | Represents a piece of formatted text from a QTextDocument
QTextDocumentWriter | Format-independent interface for writing a QTextDocument to files or other devices
QTextEdit | Widget that is used to edit and display both plain and rich text
QTextFormat | Formatting information for a QTextDocument
QTextFragment | Holds a piece of text in a QTextDocument with a single QTextCharFormat
QTextFrame | Represents a frame in a QTextDocument
QTextFrame::iterator | Iterator for reading the contents of a QTextFrame
QTextFrameFormat | Formatting information for frames in a QTextDocument
QTextImageFormat | Formatting information for images in a QTextDocument
QTextInlineObject | Represents an inline object in a QAbstractTextDocumentLayout and its implementations
QTextLayout | Used to lay out and render text
QTextLength | Encapsulates the different types of length used in a QTextDocument
QTextLine | Represents a line of text inside a QTextLayout
QTextList | Decorated list of items in a QTextDocument
QTextListFormat | Formatting information for lists in a QTextDocument
QTextObject | Base class for different kinds of objects that can group parts of a QTextDocument together
QTextOption | Description of general rich text properties
QTextTable | Represents a table in a QTextDocument
QTextTableCell | Represents the properties of a cell in a QTextTable
QTextTableCellFormat | Formatting information for table cells in a QTextDocument
QTextTableFormat | Formatting information for tables in a QTextDocument