source: trunk/doc/src/richtext.qdoc@ 357

Last change on this file since 357 was 2, checked in by Dmitry A. Kuminov, 17 years ago

Initially imported qt-all-opensource-src-4.5.1 from Trolltech.

File size: 41.5 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
4** Contact: Qt Software Information ([email protected])
5**
6** This file is part of the documentation of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial Usage
10** Licensees holding valid Qt Commercial licenses may use this file in
11** accordance with the Qt Commercial License Agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and Nokia.
14**
15** GNU Lesser General Public License Usage
16** Alternatively, this file may be used under the terms of the GNU Lesser
17** General Public License version 2.1 as published by the Free Software
18** Foundation and appearing in the file LICENSE.LGPL included in the
19** packaging of this file. Please review the following information to
20** ensure the GNU Lesser General Public License version 2.1 requirements
21** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
22**
23** In addition, as a special exception, Nokia gives you certain
24** additional rights. These rights are described in the Nokia Qt LGPL
25** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
26** package.
27**
28** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file. Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
36** If you are unsure which license is appropriate for your use, please
37** contact the sales department at [email protected].
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42/*!
43\page richtext.html
44\nextpage Rich Text Document Structure
45
46\title Rich Text Processing
47\ingroup architecture
48\ingroup text-processing
49\brief An overview of Qt's rich text processing, editing and display features.
50
51The Scribe framework provides a set of classes for reading and manipulating
52structured rich text documents. Unlike previous rich text support in Qt, the
53new classes are centered around the QTextDocument class rather than raw
54textual information. This enables the developer to create and modify
55structured rich text documents without having to prepare content in an
56intermediate markup format.
57
58The information within a document can be accessed via two complementary
59interfaces: A cursor-based interface is used for editing, and a read-only
60hierarchical interface provides a high level overview of the document
61structure. The main advantage of the cursor-based interface is that the
62text can be edited using operations that mimic a user's interaction with
63an editor, without losing the underlying structure of the document. The
64read-only hierarchical interface is most useful when performing operations
65such as searching and document export.
66
67This document is divided up into chapters for convenient reference:
68
69\list
70\i \l{Rich Text Document Structure} outlines
71 the different kinds of elements in a QTextDocument, and describes how
72 they are arranged in a document structure.
73\i \l{The QTextCursor Interface} explains how rich
74 text documents can be edited using the cursor-based interface.
75\i \l{Common Rich Text Editing Tasks} examines some
76 common tasks that involve reading or manipulating rich text documents.
77\i \l{Advanced Rich Text Processing} examines advanced rich text editing tasks.
78\i \l{Supported HTML Subset} lists the HTML tags supported by QTextDocument.
79\endlist
80
81See also the list of \l{Text Processing Classes}.
82
83*/
84
85/*!
86\page richtext-structure.html
87\contentspage richtext.html Contents
88\previouspage Rich Text Processing
89\nextpage The QTextCursor Interface
90
91\title Rich Text Document Structure
92
93\tableofcontents
94
95The structured representation of a text document presents its contents as
96a hierarchy of text blocks, frames, tables, and other objects. These provide
97a logical structure to the document and describe how their contents will be
98displayed. Generally, frames and tables are used to group other
99structures while text blocks contain the actual textual information.
100
101New elements are created and inserted into the document programmatically
102\l{richtext-cursor.html}{with a QTextCursor} or by using an editor
103widget, such as QTextEdit. Elements can be given a particular format when
104they are created; otherwise they take the cursor's current format for the
105element.
106
107\table
108\row
109\i \inlineimage richtext-document.png
110\i \bold{Basic structure}
111
112The "top level" of a document might be populated in the way shown.
113Each document always contains a root frame, and this always contains
114at least one text block.
115
116For documents with some textual content, the root
117frame usually contains a sequence of blocks and other elements.
118
119Sequences of frames and tables are always separated by text blocks in a
120document, even if the text blocks contain no information. This ensures that
121new elements can always be inserted between existing structures.
122\endtable
123
124In this chapter, we look at each of the structural elements
125used in a rich text document, outline their features and uses, and show
126how to examine their contents. Document editing is described in
127\l{richtext-cursor.html}{The QTextCursor Interface}.
128
129\section1 Rich Text Documents
130
131QTextDocument objects contain all the information required to construct
132rich text documents for use with a QTextEdit widget or in a custom editor.
133Although QTextEdit makes it easy to display and edit rich text, documents
134can also be used independently of any editor widget, for example: