File: qtextdocument.html

package info (click to toggle)
python-qt4 4.0.1-5
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 18,632 kB
  • ctags: 2,639
  • sloc: python: 29,409; sh: 5,646; cpp: 3,168; xml: 149; makefile: 109
file content (158 lines) | stat: -rw-r--r-- 31,216 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html><head><title>QTextDocument Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
td.postheader { font-family: sans-serif }
tr.address { font-family: sans-serif }
body { background: #ffffff; color: black; }
</style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">&#160;&#160;</td><td class="postheader" valign="center"><a href="../pyqt4ref.html"><font color="#004faf">Home</font></a>&#160;&#183; <a href="classes.html"><font color="#004faf">All Classes</font></a>&#160;&#183; <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QTextDocument Class Reference<br /><sup><sup>[<a href="qtgui.html">QtGui</a> module]</sup></sup></h1><p>The QTextDocument class holds formatted text that can be viewed and edited using a <a href="qtextedit.html">QTextEdit</a>. <a href="#details">More...</a></p>
<p>Inherits <a href="qobject.html">QObject</a>.</p><h3>Types</h3><ul><li><div class="fn" />enum <b><a href="qtextdocument.html#FindFlag-enum">FindFlag</a></b> { FindBackward, FindCaseSensitively, FindWholeWords }</li><li><div class="fn" />class <b><a href="qtextdocument-findflags.html">FindFlags</a></b></li><li><div class="fn" />enum <b><a href="qtextdocument.html#MetaInformation-enum">MetaInformation</a></b> { DocumentTitle }</li><li><div class="fn" />enum <b><a href="qtextdocument.html#ResourceType-enum">ResourceType</a></b> { HtmlResource, ImageResource, UserResource }</li></ul><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qtextdocument.html#QTextDocument">__init__</a></b> (<i>self</i>, QObject&#160;<i>parent</i>&#160;=&#160;None)</li><li><div class="fn" /><b><a href="qtextdocument.html#QTextDocument-2">__init__</a></b> (<i>self</i>, QString&#160;<i>text</i>, QObject&#160;<i>parent</i>&#160;=&#160;None)</li><li><div class="fn" /><b><a href="qtextdocument.html#addResource">addResource</a></b> (<i>self</i>, int&#160;<i>type</i>, QUrl&#160;<i>name</i>, QVariant&#160;<i>resource</i>)</li><li><div class="fn" />QTextFormat-list <b><a href="qtextdocument.html#allFormats">allFormats</a></b> (<i>self</i>)</li><li><div class="fn" />QTextBlock <b><a href="qtextdocument.html#begin">begin</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qtextdocument.html#clear">clear</a></b> (<i>self</i>)</li><li><div class="fn" />QTextDocument <b><a href="qtextdocument.html#clone">clone</a></b> (<i>self</i>, QObject&#160;<i>parent</i>&#160;=&#160;None)</li><li><div class="fn" />QTextObject <b><a href="qtextdocument.html#createObject">createObject</a></b> (<i>self</i>, QTextFormat&#160;<i>f</i>)</li><li><div class="fn" />QFont <b><a href="qtextdocument.html#defaultFont">defaultFont</a></b> (<i>self</i>)</li><li><div class="fn" />QAbstractTextDocumentLayout <b><a href="qtextdocument.html#documentLayout">documentLayout</a></b> (<i>self</i>)</li><li><div class="fn" />QTextBlock <b><a href="qtextdocument.html#end">end</a></b> (<i>self</i>)</li><li><div class="fn" />QTextCursor <b><a href="qtextdocument.html#find">find</a></b> (<i>self</i>, QString&#160;<i>expr</i>, int&#160;<i>from</i>&#160;=&#160;0, FindFlags&#160;<i>options</i>&#160;=&#160;0)</li><li><div class="fn" />QTextCursor <b><a href="qtextdocument.html#find-2">find</a></b> (<i>self</i>, QString&#160;<i>expr</i>, QTextCursor&#160;<i>from</i>, FindFlags&#160;<i>options</i>&#160;=&#160;0)</li><li><div class="fn" />QTextBlock <b><a href="qtextdocument.html#findBlock">findBlock</a></b> (<i>self</i>, int&#160;<i>pos</i>)</li><li><div class="fn" />bool <b><a href="qtextdocument.html#isEmpty">isEmpty</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qtextdocument.html#isModified">isModified</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qtextdocument.html#isRedoAvailable">isRedoAvailable</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qtextdocument.html#isUndoAvailable">isUndoAvailable</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qtextdocument.html#isUndoRedoEnabled">isUndoRedoEnabled</a></b> (<i>self</i>)</li><li><div class="fn" />QVariant <b><a href="qtextdocument.html#loadResource">loadResource</a></b> (<i>self</i>, int&#160;<i>type</i>, QUrl&#160;<i>name</i>)</li><li><div class="fn" /><b><a href="qtextdocument.html#markContentsDirty">markContentsDirty</a></b> (<i>self</i>, int&#160;<i>from</i>, int&#160;<i>length</i>)</li><li><div class="fn" />QString <b><a href="qtextdocument.html#metaInformation">metaInformation</a></b> (<i>self</i>, MetaInformation&#160;<i>info</i>)</li><li><div class="fn" />QTextObject <b><a href="qtextdocument.html#object">object</a></b> (<i>self</i>, int&#160;<i>objectIndex</i>)</li><li><div class="fn" />QTextObject <b><a href="qtextdocument.html#objectForFormat">objectForFormat</a></b> (<i>self</i>, QTextFormat)</li><li><div class="fn" />int <b><a href="qtextdocument.html#pageCount">pageCount</a></b> (<i>self</i>)</li><li><div class="fn" />QSizeF <b><a href="qtextdocument.html#pageSize">pageSize</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qtextdocument.html#print">print_</a></b> (<i>self</i>, QPrinter&#160;<i>printer</i>)</li><li><div class="fn" /><b><a href="qtextdocument.html#redo">redo</a></b> (<i>self</i>)</li><li><div class="fn" />QVariant <b><a href="qtextdocument.html#resource">resource</a></b> (<i>self</i>, int&#160;<i>type</i>, QUrl&#160;<i>name</i>)</li><li><div class="fn" />QTextFrame <b><a href="qtextdocument.html#rootFrame">rootFrame</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qtextdocument.html#setDefaultFont">setDefaultFont</a></b> (<i>self</i>, QFont&#160;<i>font</i>)</li><li><div class="fn" /><b><a href="qtextdocument.html#setDocumentLayout">setDocumentLayout</a></b> (<i>self</i>, QAbstractTextDocumentLayout&#160;<i>layout</i>)</li><li><div class="fn" /><b><a href="qtextdocument.html#setHtml">setHtml</a></b> (<i>self</i>, QString&#160;<i>html</i>)</li><li><div class="fn" /><b><a href="qtextdocument.html#setMetaInformation">setMetaInformation</a></b> (<i>self</i>, MetaInformation&#160;<i>info</i>, QString)</li><li><div class="fn" /><b><a href="qtextdocument.html#setModified">setModified</a></b> (<i>self</i>, bool&#160;<i>m</i>&#160;=&#160;True)</li><li><div class="fn" /><b><a href="qtextdocument.html#setPageSize">setPageSize</a></b> (<i>self</i>, QSizeF&#160;<i>size</i>)</li><li><div class="fn" /><b><a href="qtextdocument.html#setPlainText">setPlainText</a></b> (<i>self</i>, QString&#160;<i>text</i>)</li><li><div class="fn" /><b><a href="qtextdocument.html#setUndoRedoEnabled">setUndoRedoEnabled</a></b> (<i>self</i>, bool&#160;<i>enable</i>)</li><li><div class="fn" /><b><a href="qtextdocument.html#setUseDesignMetrics">setUseDesignMetrics</a></b> (<i>self</i>, bool&#160;<i>b</i>)</li><li><div class="fn" />QString <b><a href="qtextdocument.html#toHtml">toHtml</a></b> (<i>self</i>, QByteArray&#160;<i>encoding</i>&#160;=&#160;QByteArray())</li><li><div class="fn" />QString <b><a href="qtextdocument.html#toPlainText">toPlainText</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qtextdocument.html#undo">undo</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qtextdocument.html#useDesignMetrics">useDesignMetrics</a></b> (<i>self</i>)</li></ul><h3>Qt Signals</h3><ul><li><div class="fn" />void <b><a href="qtextdocument.html#contentsChange">contentsChange</a></b> (int,int,int)</li><li><div class="fn" />void <b><a href="qtextdocument.html#contentsChanged">contentsChanged</a></b> ()</li><li><div class="fn" />void <b><a href="qtextdocument.html#cursorPositionChanged">cursorPositionChanged</a></b> (const QTextCursor&amp;)</li><li><div class="fn" />void <b><a href="qtextdocument.html#modificationChanged">modificationChanged</a></b> (bool)</li><li><div class="fn" />void <b><a href="qtextdocument.html#redoAvailable">redoAvailable</a></b> (bool)</li><li><div class="fn" />void <b><a href="qtextdocument.html#undoAvailable">undoAvailable</a></b> (bool)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QTextDocument class holds formatted text that can be viewed and edited using a <a href="qtextedit.html">QTextEdit</a>.</p>
<p>QTextDocument is a container for structured rich text documents, providing support for styled text and various types of document elements, such as lists, tables, frames, and images. They can be created for use in a <a href="qtextedit.html">QTextEdit</a>, or used independently.</p>
<p>Each document element is described by an associated format object. Each format object is treated as a unique object by QTextDocuments, and can be passed to <a href="qtextdocument.html#objectForFormat">objectForFormat</a>() to obtain the document element that it is applied to.</p>
<p>A QTextDocument can be edited programmatically using a <a href="qtextcursor.html">QTextCursor</a>, and its contents can be examined by traversing the document structure. The entire document structure is stored as a hierarchy of document elements beneath the root frame, found with the <a href="qtextdocument.html#rootFrame">rootFrame</a>() function. Alternatively, if you just want to iterate over the textual contents of the document you can use <a href="qtextdocument.html#begin">begin</a>(), <a href="qtextdocument.html#end">end</a>(), and <a href="qtextdocument.html#findBlock">findBlock</a>() to retrieve text blocks that you can examine and iterate over.</p>
<p>The layout of a document is determined by the <a href="qtextdocument.html#documentLayout">documentLayout</a>(); you can create your own <a href="qabstracttextdocumentlayout.html">QAbstractTextDocumentLayout</a> subclass and set it using <a href="qtextdocument.html#setDocumentLayout">setDocumentLayout</a>() if you want to use your own layout logic. The document's title can be obtained by calling the documentTitle() function.</p>
<p>The <a href="qtextdocument.html#toPlainText">toPlainText</a>() and <a href="qtextdocument.html#toHtml">toHtml</a>() convenience functions allow you to retrieve the contents of the document as plain text and HTML. The document's text can be searched using the <a href="qtextdocument.html#find">find</a>() functions.</p>
<p>Undo/redo of operations performed on the document can be controlled using the <a href="qtextdocument.html#undoRedoEnabled-prop">setUndoRedoEnabled</a>() function. The undo/redo system can be controlled by an editor widget through the <a href="qtextdocument.html#undo">undo</a>() and <a href="qtextdocument.html#redo">redo</a>() slots; the document also provides <a href="qtextdocument.html#contentsChanged">contentsChanged</a>(), <a href="qtextdocument.html#undoAvailable">undoAvailable</a>(), and <a href="qtextdocument.html#redoAvailable">redoAvailable</a>() signals that inform connected editor widgets about the state of the undo/redo system.</p>
<p>See also <a href="qtextcursor.html">QTextCursor</a>, <a href="qtextedit.html">QTextEdit</a>, and <a href="richtext.html">Rich Text Processing</a>.</p>
<hr /><h2>Type Documentation</h2><h3 class="fn"><a name="FindFlag-enum" />QTextDocument.FindFlag</h3><p>This enum describes the options available to <a href="qtextdocument.html">QTextDocument</a>'s find function. The options can be OR-red together from the following list:</p>
<table border="1" cellpadding="2" cellspacing="1" width="100%">
<tr>
<th width="25%">Constant</th>
<th width="15%">Value</th>
<th width="60%">Description</th>
</tr>
<tr>
<td valign="top"><tt>QTextDocument.FindBackward</tt></td>
<td align="center" valign="top"><tt>0x00001</tt></td>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top"><tt>QTextDocument.FindCaseSensitively</tt></td>
<td align="center" valign="top"><tt>0x00002</tt></td>
<td valign="top">By default find works case insensitive. Specifying this option changes the behaviour to a case sensitive find operation.</td>
</tr>
<tr>
<td valign="top"><tt>QTextDocument.FindWholeWords</tt></td>
<td align="center" valign="top"><tt>0x00004</tt></td>
<td valign="top">Makes find match only complete words.</td>
</tr>
</table>
<br />
<br />
<p>The FindFlags type is a typedef for <a href="qflags.html">QFlags</a>&lt;FindFlag&gt;. It stores an OR combination of FindFlag values.</p>
<h3 class="fn"><a name="MetaInformation-enum" />QTextDocument.MetaInformation</h3><p>This enum describes the different types of meta information that can be added to a document.</p>
<table border="1" cellpadding="2" cellspacing="1" width="100%">
<tr>
<th width="25%">Constant</th>
<th width="15%">Value</th>
<th width="60%">Description</th>
</tr>
<tr>
<td valign="top"><tt>QTextDocument.DocumentTitle</tt></td>
<td align="center" valign="top"><tt>0</tt></td>
<td valign="top">The title of the document.</td>
</tr>
</table>
<br />
<br />
<p>See also <a href="qtextdocument.html#metaInformation">metaInformation</a>() and <a href="qtextdocument.html#setMetaInformation">setMetaInformation</a>().</p>
<h3 class="fn"><a name="ResourceType-enum" />QTextDocument.ResourceType</h3><p>This enum describes the types of resources that can be loaded by <a href="qtextdocument.html">QTextDocument</a>'s <a href="qtextdocument.html#loadResource">loadResource</a>() function.</p>
<table border="1" cellpadding="2" cellspacing="1" width="100%">
<tr>
<th width="25%">Constant</th>
<th width="15%">Value</th>
<th width="60%">Description</th>
</tr>
<tr>
<td valign="top"><tt>QTextDocument.HtmlResource</tt></td>
<td align="center" valign="top"><tt>1</tt></td>
<td valign="top">The resource contains HTML.</td>
</tr>
<tr>
<td valign="top"><tt>QTextDocument.ImageResource</tt></td>
<td align="center" valign="top"><tt>2</tt></td>
<td valign="top">The resource contains image data.</td>
</tr>
<tr>
<td valign="top"><tt>QTextDocument.UserResource</tt></td>
<td align="center" valign="top"><tt>100</tt></td>
<td valign="top">The first available value for user defined resource types.</td>
</tr>
</table>
<br />
<br />
<p>See also <a href="qtextdocument.html#loadResource">loadResource</a>().</p>
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QTextDocument" />QTextDocument.__init__ (<i>self</i>, <a href="qobject.html">QObject</a>&#160;<i>parent</i>&#160;=&#160;None)</h3><p>The <i>parent</i> argument, if not None, causes <i>self</i> to be owned by Qt instead of PyQt.</p><p>Constructs an empty <a href="qtextdocument.html">QTextDocument</a> with the given <i>parent</i>.</p>
<h3 class="fn"><a name="QTextDocument-2" />QTextDocument.__init__ (<i>self</i>, <a href="qstring.html">QString</a>&#160;<i>text</i>, <a href="qobject.html">QObject</a>&#160;<i>parent</i>&#160;=&#160;None)</h3><p>The <i>parent</i> argument, if not None, causes <i>self</i> to be owned by Qt instead of PyQt.</p><p>Constructs a <a href="qtextdocument.html">QTextDocument</a> containing the plain (unformatted) <i>text</i> specified, and with the given <i>parent</i>.</p>
<h3 class="fn"><a name="addResource" />QTextDocument.addResource (<i>self</i>, int&#160;<i>type</i>, <a href="qurl.html">QUrl</a>&#160;<i>name</i>, <a href="qvariant.html">QVariant</a>&#160;<i>resource</i>)</h3><p>Adds the resource <i>resource</i> to the resource cache, using <i>type</i> and <i>name</i> as identifiers.</p>
<h3 class="fn"><a name="allFormats" />QTextFormat-list QTextDocument.allFormats (<i>self</i>)</h3><p>Returns a vector of text formats for all the formats used in the document.</p>
<h3 class="fn"><a name="begin" /><a href="qtextblock.html">QTextBlock</a> QTextDocument.begin (<i>self</i>)</h3><p>Returns the document's first text block.</p>
<h3 class="fn"><a name="clear" />QTextDocument.clear (<i>self</i>)</h3><p>Clears the document.</p>
<h3 class="fn"><a name="clone" /><a href="qtextdocument.html">QTextDocument</a> QTextDocument.clone (<i>self</i>, <a href="qobject.html">QObject</a>&#160;<i>parent</i>&#160;=&#160;None)</h3><p>The <i>parent</i> argument, if not None, causes <i>self</i> to be owned by Qt instead of PyQt.</p><p>Creates a new <a href="qtextdocument.html">QTextDocument</a> that is a copy of this text document. <i>parent</i> is the parent of the returned text document.</p>
<h3 class="fn"><a name="createObject" /><a href="qtextobject.html">QTextObject</a> QTextDocument.createObject (<i>self</i>, <a href="qtextformat.html">QTextFormat</a>&#160;<i>f</i>)</h3><p>Creates and returns a new document object (a <a href="qtextobject.html">QTextObject</a>), based on the given <i>format</i>.</p>
<p>QTextObjects will always get created through this method, so you must reimplement it if you use custom text objects inside your document.</p>
<h3 class="fn"><a name="defaultFont" /><a href="qfont.html">QFont</a> QTextDocument.defaultFont (<i>self</i>)</h3><h3 class="fn"><a name="documentLayout" /><a href="qabstracttextdocumentlayout.html">QAbstractTextDocumentLayout</a> QTextDocument.documentLayout (<i>self</i>)</h3><p>Returns the document layout for this document.</p>
<p>See also <a href="qtextdocument.html#setDocumentLayout">setDocumentLayout</a>().</p>
<h3 class="fn"><a name="end" /><a href="qtextblock.html">QTextBlock</a> QTextDocument.end (<i>self</i>)</h3><p>Returns the document's last text block.</p>
<h3 class="fn"><a name="find" /><a href="qtextcursor.html">QTextCursor</a> QTextDocument.find (<i>self</i>, <a href="qstring.html">QString</a>&#160;<i>expr</i>, int&#160;<i>from</i>&#160;=&#160;0, <a href="qtextdocument-findflags.html">FindFlags</a>&#160;<i>options</i>&#160;=&#160;0)</h3><p>Finds the next occurrence of the string, <i>expr</i>, in the document. The search starts at the position of the given <i>cursor</i>, and proceeds forwards through the document unless specified otherwise in the search options. The <i>options</i> control the type of search performed.</p>
<p>Returns a cursor with the match selected if <i>expr</i> was found; otherwise returns a null cursor.</p>
<p>If the given <i>cursor</i> has a selection, the search begins after the selection; otherwise it begins at the cursor's position.</p>
<p>By default the search is case-sensitive, and can match text anywhere in the document.</p>
<h3 class="fn"><a name="find-2" /><a href="qtextcursor.html">QTextCursor</a> QTextDocument.find (<i>self</i>, <a href="qstring.html">QString</a>&#160;<i>expr</i>, <a href="qtextcursor.html">QTextCursor</a>&#160;<i>from</i>, <a href="qtextdocument-findflags.html">FindFlags</a>&#160;<i>options</i>&#160;=&#160;0)</h3><p>This is an overloaded member function, provided for convenience.</p>
<p>Finds the next occurrence of the string, <i>expr</i>, in the document. The search starts at the given <i>position</i>, and proceeds forwards through the document unless specified otherwise in the search options. The <i>options</i> control the type of search performed.</p>
<p>Returns a cursor with the match selected if <i>expr</i> was found; otherwise returns a null cursor.</p>
<p>If the <i>position</i> is 0 (the default) the search begins from the beginning of the document; otherwise it begins at the specified position.</p>
<h3 class="fn"><a name="findBlock" /><a href="qtextblock.html">QTextBlock</a> QTextDocument.findBlock (<i>self</i>, int&#160;<i>pos</i>)</h3><p>Returns the text block that contains the <i>pos</i>-th character.</p>
<h3 class="fn"><a name="isEmpty" />bool QTextDocument.isEmpty (<i>self</i>)</h3><p>Returns true if the document is empty; otherwise returns false.</p>
<h3 class="fn"><a name="isModified" />bool QTextDocument.isModified (<i>self</i>)</h3><h3 class="fn"><a name="isRedoAvailable" />bool QTextDocument.isRedoAvailable (<i>self</i>)</h3><p>Returns true is redo is available; otherwise returns false.</p>
<h3 class="fn"><a name="isUndoAvailable" />bool QTextDocument.isUndoAvailable (<i>self</i>)</h3><p>Returns true is undo is available; otherwise returns false.</p>
<h3 class="fn"><a name="isUndoRedoEnabled" />bool QTextDocument.isUndoRedoEnabled (<i>self</i>)</h3><h3 class="fn"><a name="loadResource" /><a href="qvariant.html">QVariant</a> QTextDocument.loadResource (<i>self</i>, int&#160;<i>type</i>, <a href="qurl.html">QUrl</a>&#160;<i>name</i>)</h3><p>Loads data of the specified <i>type</i> from the resource with the given <i>name</i>.</p>
<p>This function is called by the rich text engine to request data that isn't directly stored by <a href="qtextdocument.html">QTextDocument</a>, but still associated with it. For example, images are referenced indirectly by the name attribute of a <a href="qtextimageformat.html">QTextImageFormat</a> object.</p>
<p>When called by Qt, <i>type</i> is one of the values of <a href="qtextdocument.html#ResourceType-enum">QTextDocument.ResourceType</a>.</p>
<p>If the <a href="qtextdocument.html">QTextDocument</a> is a child object of a <a href="qtextedit.html">QTextEdit</a>, <a href="qtextbrowser.html">QTextBrowser</a>, or a <a href="qtextdocument.html">QTextDocument</a> itself then the default implementation tries to retrieve the data from the parent.</p>
<h3 class="fn"><a name="markContentsDirty" />QTextDocument.markContentsDirty (<i>self</i>, int&#160;<i>from</i>, int&#160;<i>length</i>)</h3><p>Marks the contents specified by the given <i>position</i> and <i>length</i> as "dirty", informing the document that it needs to be layed out again.</p>
<h3 class="fn"><a name="metaInformation" /><a href="qstring.html">QString</a> QTextDocument.metaInformation (<i>self</i>, <a href="qtextdocument.html#MetaInformation-enum">MetaInformation</a>&#160;<i>info</i>)</h3><p>Returns meta information about the document of the type specified by <i>info</i>.</p>
<p>See also <a href="qtextdocument.html#setMetaInformation">setMetaInformation</a>().</p>
<h3 class="fn"><a name="object" /><a href="qtextobject.html">QTextObject</a> QTextDocument.object (<i>self</i>, int&#160;<i>objectIndex</i>)</h3><p>Returns the text object associated with the given <i>objectIndex</i>.</p>
<h3 class="fn"><a name="objectForFormat" /><a href="qtextobject.html">QTextObject</a> QTextDocument.objectForFormat (<i>self</i>, <a href="qtextformat.html">QTextFormat</a>)</h3><p>Returns the text object associated with the format <i>f</i>.</p>
<h3 class="fn"><a name="pageCount" />int QTextDocument.pageCount (<i>self</i>)</h3><p>returns the number of pages in this document.</p>
<h3 class="fn"><a name="pageSize" /><a href="qsizef.html">QSizeF</a> QTextDocument.pageSize (<i>self</i>)</h3><h3 class="fn"><a name="print" />QTextDocument.print_ (<i>self</i>, <a href="qprinter.html">QPrinter</a>&#160;<i>printer</i>)</h3><p>Prints the document to the given <i>printer</i>. The <a href="qprinter.html">QPrinter</a> must be set up before being used with this function.</p>
<p>This is only a convenience method to print the whole document to the printer.</p>
<h3 class="fn"><a name="redo" />QTextDocument.redo (<i>self</i>)</h3><p>This method is also a Qt slot with the C++ signature <tt>void redo()</tt>.</p><p>Redoes the last editing operation on the document if <a href="qtextdocument.html#isRedoAvailable">redo is available</a>.</p>
<h3 class="fn"><a name="resource" /><a href="qvariant.html">QVariant</a> QTextDocument.resource (<i>self</i>, int&#160;<i>type</i>, <a href="qurl.html">QUrl</a>&#160;<i>name</i>)</h3><p>Returns data of the specified <i>type</i> from the resource with the given <i>name</i>.</p>
<p>This function is called by the rich text engine to request data that isn't directly stored by <a href="qtextdocument.html">QTextDocument</a>, but still associated with it. For example, images are referenced indirectly by the name attribute of a <a href="qtextimageformat.html">QTextImageFormat</a> object.</p>
<p>Resources are cached internally in the document. If a resource can not be found in the cache, loadResource is called to try to load the resource. loadResource should then use addResource to add the resource to the cache.</p>
<h3 class="fn"><a name="rootFrame" /><a href="qtextframe.html">QTextFrame</a> QTextDocument.rootFrame (<i>self</i>)</h3><p>Returns the document's root frame.</p>
<h3 class="fn"><a name="setDefaultFont" />QTextDocument.setDefaultFont (<i>self</i>, <a href="qfont.html">QFont</a>&#160;<i>font</i>)</h3><h3 class="fn"><a name="setDocumentLayout" />QTextDocument.setDocumentLayout (<i>self</i>, <a href="qabstracttextdocumentlayout.html">QAbstractTextDocumentLayout</a>&#160;<i>layout</i>)</h3><p>The <i>layout</i> argument has it's ownership transferred to Qt.</p><p>Sets the document to use the given <i>layout</i>. The previous layout is deleted.</p>
<p>See also <a href="qtextdocument.html#documentLayout">documentLayout</a>().</p>
<h3 class="fn"><a name="setHtml" />QTextDocument.setHtml (<i>self</i>, <a href="qstring.html">QString</a>&#160;<i>html</i>)</h3><p>Replaces the entire contents of the document with the given HTML-formatted text in the <i>html</i> string.</p>
<p>The HTML formatting is respected as much as possible; for example, "&lt;b&gt;bold&lt;/b&gt; text" will produce text where the first word has a font weight that gives it a bold appearance: "<b>bold</b> text".</p>
<p>See also <a href="qtextdocument.html#setPlainText">setPlainText</a>() and <a href="richtext-html-subset.html">Supported HTML Subset</a>.</p>
<h3 class="fn"><a name="setMetaInformation" />QTextDocument.setMetaInformation (<i>self</i>, <a href="qtextdocument.html#MetaInformation-enum">MetaInformation</a>&#160;<i>info</i>, <a href="qstring.html">QString</a>)</h3><p>Sets the document's meta information of the type specified by <i>info</i> to the given <i>string</i>.</p>
<p>See also <a href="qtextdocument.html#metaInformation">metaInformation</a>().</p>
<h3 class="fn"><a name="setModified" />QTextDocument.setModified (<i>self</i>, bool&#160;<i>m</i>&#160;=&#160;True)</h3><p>This method is also a Qt slot with the C++ signature <tt>void setModified(bool = 1)</tt>.</p><h3 class="fn"><a name="setPageSize" />QTextDocument.setPageSize (<i>self</i>, <a href="qsizef.html">QSizeF</a>&#160;<i>size</i>)</h3><h3 class="fn"><a name="setPlainText" />QTextDocument.setPlainText (<i>self</i>, <a href="qstring.html">QString</a>&#160;<i>text</i>)</h3><p>Replaces the entire contents of the document with the given plain <i>text</i>.</p>
<p>See also <a href="qtextdocument.html#setHtml">setHtml</a>().</p>
<h3 class="fn"><a name="setUndoRedoEnabled" />QTextDocument.setUndoRedoEnabled (<i>self</i>, bool&#160;<i>enable</i>)</h3><h3 class="fn"><a name="setUseDesignMetrics" />QTextDocument.setUseDesignMetrics (<i>self</i>, bool&#160;<i>b</i>)</h3><h3 class="fn"><a name="toHtml" /><a href="qstring.html">QString</a> QTextDocument.toHtml (<i>self</i>, <a href="qbytearray.html">QByteArray</a>&#160;<i>encoding</i>&#160;=&#160;QByteArray())</h3><p>Returns a string containing an HTML representation of the document.</p>
<p>The <i>encoding</i> parameter specifies the value for the charset attribute in the html header. For example if 'utf-8' is specified then the beginning of the generated html will look like this:</p>
<pre>
    &lt;html&gt;&lt;head&gt;&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"&gt;&lt;/head&gt;&lt;body&gt;...
</pre>
<p>If no encoding is specified then no such meta information is generated.</p>
<p>If you later on convert the returned html string into a byte array for transmission over a network or when saving to disk you should specify the encoding you're going to use for the conversion to a byte array here.</p>
<p>See also <a href="richtext-html-subset.html">Supported HTML Subset</a>.</p>
<h3 class="fn"><a name="toPlainText" /><a href="qstring.html">QString</a> QTextDocument.toPlainText (<i>self</i>)</h3><p>Returns the plain text contained in the document. If you want formatting information use a <a href="qtextcursor.html">QTextCursor</a> instead.</p>
<p>See also <a href="qtextdocument.html#toHtml">toHtml</a>().</p>
<h3 class="fn"><a name="undo" />QTextDocument.undo (<i>self</i>)</h3><p>This method is also a Qt slot with the C++ signature <tt>void undo()</tt>.</p><p>Undoes the last editing operation on the document if <a href="qtextdocument.html#isUndoAvailable">undo is available</a>.</p>
<h3 class="fn"><a name="useDesignMetrics" />bool QTextDocument.useDesignMetrics (<i>self</i>)</h3><hr /><h2>Qt Signal Documentation</h2><h3 class="fn"><a name="contentsChange" />void contentsChange (int,int,int)</h3><p>This signal is emitted whenever the document's content changes; for example, when text is inserted or deleted, or when formatting is applied.</p>
<p>Information is provided about the <i>position</i> of the character in the document where the change occurred, the number of characters removed (<i>charsRemoved</i>), and the number of characters added (<i>charsAdded</i>).</p>
<p>The signal is emitted before the document's layout manager is notified about the change. This hook allows you to implement syntax highlighting for the document.</p>
<p>See also <a href="qabstracttextdocumentlayout.html#documentChanged">QAbstractTextDocumentLayout.documentChanged</a>() and <a href="qtextdocument.html#contentsChanged">contentsChanged</a>().</p>
<h3 class="fn"><a name="contentsChanged" />void contentsChanged ()</h3><p>This signal is emitted whenever the document's content changes; for example, when text is inserted or deleted, or when formatting is applied.</p>
<p>See also <a href="qtextdocument.html#contentsChange">contentsChange</a>().</p>
<h3 class="fn"><a name="cursorPositionChanged" />void cursorPositionChanged (const QTextCursor&amp;)</h3><p>This signal is emitted whenever the position of a cursor changed due to an editing operation. The cursor that changed is passed in <i>cursor</i>.</p>
<h3 class="fn"><a name="modificationChanged" />void modificationChanged (bool)</h3><p>This signal is emitted whenever the content of the document changes in a way that affects the modification state. If <i>changed</i> is true, the document has been modified; otherwise it is false.</p>
<p>For example, calling setModified(false) on a document and then inserting text causes the signal to get emitted. If you undo that operation, causing the document to return to its original unmodified state, the signal will get emitted again.</p>
<h3 class="fn"><a name="redoAvailable" />void redoAvailable (bool)</h3><p>This signal is emitted whenever redo operations become available (<i>available</i> is true) or unavailable (<i>available</i> is false).</p>
<h3 class="fn"><a name="undoAvailable" />void undoAvailable (bool)</h3><p>This signal is emitted whenever undo operations become available (<i>available</i> is true) or unavailable (<i>available</i> is false).</p>
<address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td width="25%">PyQt&#160;4.0.1 for X11</td><td align="center" width="50%">Copyright &#169; <a href="http://www.riverbankcomputing.com">Riverbank&#160;Computing&#160;Ltd</a> and <a href="http://www.trolltech.com">Trolltech&#160;AS</a> 2006</td><td align="right" width="25%">Qt&#160;4.1.4</td></tr></table></div></address></body></html>