Rich Text Processing¶
Overview of Qt’s rich text processing, editing, and display features.
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:
QTextDocumentcan parse Markdown in both CommonMark and GitHub dialects.
Rich Text Topics¶
Rich Text Document Structure describes the different elements in a
QTextDocumentand 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.
The QAbstractTextDocumentLayout class is an abstract base class used to implement custom layouts for QTextDocuments.
The QFont class specifies a query for a font used for drawing text.
The QSyntaxHighlighter class 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.
The QTextCursor class offers an API to access and modify QTextDocuments.
The QTextDocument class holds formatted text.
The QTextDocumentFragment class represents a piece of formatted text from a QTextDocument.
The QTextDocumentWriter class provides a format-independent interface for writing a QTextDocument to files or other devices.
The QTextLength class encapsulates the different types of length used in a QTextDocument.
The QTextFormat class provides formatting information for a QTextDocument.
The QTextCharFormat class provides formatting information for characters in a QTextDocument.
The QTextBlockFormat class provides formatting information for blocks of text in a QTextDocument.
The QTextListFormat class provides formatting information for lists in a QTextDocument.
The QTextFrameFormat class provides formatting information for frames in a QTextDocument.
The QTextTableFormat class provides formatting information for tables in a QTextDocument.
The QTextImageFormat class provides formatting information for images in a QTextDocument.
The QTextTableCellFormat class provides formatting information for table cells in a QTextDocument.
The QTextInlineObject class represents an inline object in a QAbstractTextDocumentLayout and its implementations.
The QTextLayout class is used to lay out and render text.
The QTextLine class represents a line of text inside a QTextLayout.
The QTextList class provides a decorated list of items in a QTextDocument.
The QTextObject class is a base class for different kinds of objects that can group parts of a QTextDocument together.
The QTextBlockGroup class provides a container for text blocks within a QTextDocument.
The QTextFrame class represents a frame in a QTextDocument.
QTextFrame.iteratorThe iterator class provides an iterator for reading the contents of a QTextFrame.
The QTextBlockUserData class is used to associate custom data with blocks of text.
The QTextBlock class provides a container for text fragments in a QTextDocument.
QTextBlock.iteratorThe QTextBlock::iterator class provides an iterator for reading the contents of a QTextBlock.
The QTextFragment class holds a piece of text in a QTextDocument with a single QTextCharFormat.
The QTextOption class provides a description of general rich text properties.
The QTextTableCell class represents the properties of a cell in a QTextTable.
The QTextTable class represents a table in a QTextDocument.