Sophie

Sophie

distrib > Mageia > 4 > i586 > by-pkgid > 28b9e36e96ce34b2567ae5b47a27b2c5 > files > 1168

python-qt4-doc-4.10.3-3.mga4.noarch.rpm

<?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="index.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, DocumentUrl }</li><li><div class="fn" />enum <b><a href="qtextdocument.html#ResourceType-enum">ResourceType</a></b> { HtmlResource, ImageResource, StyleSheetResource, UserResource }</li><li><div class="fn" />enum <b><a href="qtextdocument.html#Stacks-enum">Stacks</a></b> { UndoStack, RedoStack, UndoAndRedoStacks }</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" /><b><a href="qtextdocument.html#adjustSize">adjustSize</a></b> (<i>self</i>)</li><li><div class="fn" />list-of-QTextFormat <b><a href="qtextdocument.html#allFormats">allFormats</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qtextdocument.html#availableRedoSteps">availableRedoSteps</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qtextdocument.html#availableUndoSteps">availableUndoSteps</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" />int <b><a href="qtextdocument.html#blockCount">blockCount</a></b> (<i>self</i>)</li><li><div class="fn" />QChar <b><a href="qtextdocument.html#characterAt">characterAt</a></b> (<i>self</i>, int&#160;<i>pos</i>)</li><li><div class="fn" />int <b><a href="qtextdocument.html#characterCount">characterCount</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" /><b><a href="qtextdocument.html#clearUndoRedoStacks">clearUndoRedoStacks</a></b> (<i>self</i>, Stacks&#160;<i>stacks</i>&#160;=&#160;QTextDocument.UndoAndRedoStacks)</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" />Qt.CursorMoveStyle <b><a href="qtextdocument.html#defaultCursorMoveStyle">defaultCursorMoveStyle</a></b> (<i>self</i>)</li><li><div class="fn" />QFont <b><a href="qtextdocument.html#defaultFont">defaultFont</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qtextdocument.html#defaultStyleSheet">defaultStyleSheet</a></b> (<i>self</i>)</li><li><div class="fn" />QTextOption <b><a href="qtextdocument.html#defaultTextOption">defaultTextOption</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" />float <b><a href="qtextdocument.html#documentMargin">documentMargin</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qtextdocument.html#drawContents">drawContents</a></b> (<i>self</i>, QPainter&#160;<i>p</i>, QRectF&#160;<i>rect</i>&#160;=&#160;QRectF())</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>subString</i>, int&#160;<i>position</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>, QRegExp&#160;<i>expr</i>, int&#160;<i>position</i>&#160;=&#160;0, FindFlags&#160;<i>options</i>&#160;=&#160;0)</li><li><div class="fn" />QTextCursor <b><a href="qtextdocument.html#find-3">find</a></b> (<i>self</i>, QString&#160;<i>subString</i>, QTextCursor&#160;<i>cursor</i>, FindFlags&#160;<i>options</i>&#160;=&#160;0)</li><li><div class="fn" />QTextCursor <b><a href="qtextdocument.html#find-4">find</a></b> (<i>self</i>, QRegExp&#160;<i>expr</i>, QTextCursor&#160;<i>cursor</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" />QTextBlock <b><a href="qtextdocument.html#findBlockByLineNumber">findBlockByLineNumber</a></b> (<i>self</i>, int&#160;<i>blockNumber</i>)</li><li><div class="fn" />QTextBlock <b><a href="qtextdocument.html#findBlockByNumber">findBlockByNumber</a></b> (<i>self</i>, int&#160;<i>blockNumber</i>)</li><li><div class="fn" />QTextBlock <b><a href="qtextdocument.html#firstBlock">firstBlock</a></b> (<i>self</i>)</li><li><div class="fn" />float <b><a href="qtextdocument.html#idealWidth">idealWidth</a></b> (<i>self</i>)</li><li><div class="fn" />float <b><a href="qtextdocument.html#indentWidth">indentWidth</a></b> (<i>self</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" />QTextBlock <b><a href="qtextdocument.html#lastBlock">lastBlock</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qtextdocument.html#lineCount">lineCount</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" />int <b><a href="qtextdocument.html#maximumBlockCount">maximumBlockCount</a></b> (<i>self</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#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" /><b><a href="qtextdocument.html#redo-2">redo</a></b> (<i>self</i>, QTextCursor&#160;<i>cursor</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" />int <b><a href="qtextdocument.html#revision">revision</a></b> (<i>self</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#setDefaultCursorMoveStyle">setDefaultCursorMoveStyle</a></b> (<i>self</i>, Qt.CursorMoveStyle&#160;<i>style</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#setDefaultStyleSheet">setDefaultStyleSheet</a></b> (<i>self</i>, QString&#160;<i>sheet</i>)</li><li><div class="fn" /><b><a href="qtextdocument.html#setDefaultTextOption">setDefaultTextOption</a></b> (<i>self</i>, QTextOption&#160;<i>option</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#setDocumentMargin">setDocumentMargin</a></b> (<i>self</i>, float&#160;<i>margin</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#setIndentWidth">setIndentWidth</a></b> (<i>self</i>, float&#160;<i>width</i>)</li><li><div class="fn" /><b><a href="qtextdocument.html#setMaximumBlockCount">setMaximumBlockCount</a></b> (<i>self</i>, int&#160;<i>maximum</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>on</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#setTextWidth">setTextWidth</a></b> (<i>self</i>, float&#160;<i>width</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" />QSizeF <b><a href="qtextdocument.html#size">size</a></b> (<i>self</i>)</li><li><div class="fn" />float <b><a href="qtextdocument.html#textWidth">textWidth</a></b> (<i>self</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" /><b><a href="qtextdocument.html#undo-2">undo</a></b> (<i>self</i>, QTextCursor&#160;<i>cursor</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#blockCountChanged">blockCountChanged</a></b> (int)</li><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#documentLayoutChanged">documentLayoutChanged</a></b> ()</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><li><div class="fn" />void <b><a href="qtextdocument.html#undoCommandAdded">undoCommandAdded</a></b> ()</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 and
other meta-information can be obtained by calling the <a href="qtextdocument.html#metaInformation">metaInformation</a>()
function. For documents that are exposed to users through the
<a href="qtextedit.html">QTextEdit</a> class, the document title is
also available via the <a href="qtextedit.html#documentTitle-prop">QTextEdit.documentTitle</a>()
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. The following are the undo/redo operations of a
QTextDocument:</p>
<ul>
<li>Insertion or removal of characters. A sequence of insertions or
removals within the same text block are regarded as a single
undo/redo operation.</li>
<li>Insertion or removal of text blocks. Sequences of insertion or
removals in a single operation (e.g., by selecting and then
deleting text) are regarded as a single undo/redo operation.</li>
<li>Text character format changes.</li>
<li>Text block format changes.</li>
<li>Text block group format changes.</li>
</ul>
<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-ed together from the following list:</p>
<table class="valuelist">
<tr class="odd" valign="top">
<th class="tblConst">Constant</th>
<th class="tblval">Value</th>
<th class="tbldscr">Description</th>
</tr>
<tr>
<td class="topAlign"><tt>QTextDocument.FindBackward</tt></td>
<td class="topAlign"><tt>0x00001</tt></td>
<td class="topAlign">Search backwards instead of forwards.</td>
</tr>
<tr>
<td class="topAlign">
<tt>QTextDocument.FindCaseSensitively</tt></td>
<td class="topAlign"><tt>0x00002</tt></td>
<td class="topAlign">By default find works case insensitive.
Specifying this option changes the behaviour to a case sensitive
find operation.</td>
</tr>
<tr>
<td class="topAlign"><tt>QTextDocument.FindWholeWords</tt></td>
<td class="topAlign"><tt>0x00004</tt></td>
<td class="topAlign">Makes find match only complete words.</td>
</tr>
</table>
<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 class="valuelist">
<tr class="odd" valign="top">
<th class="tblConst">Constant</th>
<th class="tblval">Value</th>
<th class="tbldscr">Description</th>
</tr>
<tr>
<td class="topAlign"><tt>QTextDocument.DocumentTitle</tt></td>
<td class="topAlign"><tt>0</tt></td>
<td class="topAlign">The title of the document.</td>
</tr>
<tr>
<td class="topAlign"><tt>QTextDocument.DocumentUrl</tt></td>
<td class="topAlign"><tt>1</tt></td>
<td class="topAlign">The url of the document. The <a href="qtextdocument.html#loadResource">loadResource</a>() function uses
this url as the base when loading relative resources.</td>
</tr>
</table>
<p><b>See also</b> <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 class="valuelist">
<tr class="odd" valign="top">
<th class="tblConst">Constant</th>
<th class="tblval">Value</th>
<th class="tbldscr">Description</th>
</tr>
<tr>
<td class="topAlign"><tt>QTextDocument.HtmlResource</tt></td>
<td class="topAlign"><tt>1</tt></td>
<td class="topAlign">The resource contains HTML.</td>
</tr>
<tr>
<td class="topAlign"><tt>QTextDocument.ImageResource</tt></td>
<td class="topAlign"><tt>2</tt></td>
<td class="topAlign">The resource contains image data. Currently
supported data types are <a href="qvariant.html#Type-enum">QVariant.Pixmap</a> and <a href="qvariant.html#Type-enum">QVariant.Image</a>. If the corresponding
variant is of type <a href="qvariant.html#Type-enum">QVariant.ByteArray</a> then Qt attempts
to load the image using QImage.loadFromData. <a href="qvariant.html#Type-enum">QVariant.Icon</a> is currently not
supported. The icon needs to be converted to one of the supported
types first, for example using QIcon.pixmap.</td>
</tr>
<tr>
<td class="topAlign">
<tt>QTextDocument.StyleSheetResource</tt></td>
<td class="topAlign"><tt>3</tt></td>
<td class="topAlign">The resource contains CSS.</td>
</tr>
<tr>
<td class="topAlign"><tt>QTextDocument.UserResource</tt></td>
<td class="topAlign"><tt>100</tt></td>
<td class="topAlign">The first available value for user defined
resource types.</td>
</tr>
</table>
<p><b>See also</b> <a href="qtextdocument.html#loadResource">loadResource</a>().</p>


<h3 class="fn"><a name="Stacks-enum" />QTextDocument.Stacks</h3><table class="valuelist">
<tr class="odd" valign="top">
<th class="tblConst">Constant</th>
<th class="tblval">Value</th>
<th class="tbldscr">Description</th>
</tr>
<tr>
<td class="topAlign"><tt>QTextDocument.UndoStack</tt></td>
<td class="topAlign"><tt>0x01</tt></td>
<td class="topAlign">The undo stack.</td>
</tr>
<tr>
<td class="topAlign"><tt>QTextDocument.RedoStack</tt></td>
<td class="topAlign"><tt>0x02</tt></td>
<td class="topAlign">The redo stack.</td>
</tr>
<tr>
<td class="topAlign"><tt>QTextDocument.UndoAndRedoStacks</tt></td>
<td class="topAlign"><tt>UndoStack | RedoStack</tt></td>
<td class="topAlign">Both the undo and redo stacks.</td>
</tr>
</table>
<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>, QString&#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>, QVariant&#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. <i>type</i> should be a
value from <a href="qtextdocument.html#ResourceType-enum">QTextDocument.ResourceType</a>.</p>
<p>For example, you can add an image as a resource in order to
reference it from within the document:</p>
<pre class="cpp">
     document<span class="operator">-</span><span class="operator">&gt;</span>addResource(<span class="type"><a href="qtextdocument.html">QTextDocument</a></span><span class="operator">.</span>ImageResource<span class="operator">,</span>
         <span class="type"><a href="qurl.html">QUrl</a></span>(<span class="string">"mydata://image.png"</span>)<span class="operator">,</span> <span class="type"><a href="qvariant.html">QVariant</a></span>(image));
</pre>
<p>The image can be inserted into the document using the <a href="qtextcursor.html">QTextCursor</a> API:</p>
<pre class="cpp">
     <span class="type"><a href="qtextimageformat.html">QTextImageFormat</a></span> imageFormat;
     imageFormat<span class="operator">.</span>setName(<span class="string">"mydata://image.png"</span>);
     cursor<span class="operator">.</span>insertImage(imageFormat);
</pre>
<p>Alternatively, you can insert images using the HTML <tt>img</tt>
tag:</p>
<pre class="cpp">
     editor<span class="operator">-</span><span class="operator">&gt;</span>append(<span class="string">"&lt;img src=\"mydata://image.png\" /&gt;"</span>);
</pre>


<h3 class="fn"><a name="adjustSize" />QTextDocument.adjustSize (<i>self</i>)</h3><p>Adjusts the document to a reasonable size.</p>
<p>This function was introduced in Qt 4.2.</p>
<p><b>See also</b> <a href="qtextdocument.html#idealWidth">idealWidth</a>(), <a href="qtextdocument.html#textWidth-prop">textWidth</a>, and <a href="qtextdocument.html#size-prop">size</a>.</p>


<h3 class="fn"><a name="allFormats" />list-of-QTextFormat 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="availableRedoSteps" />int QTextDocument.availableRedoSteps (<i>self</i>)</h3><p>Returns the number of available redo steps.</p>
<p>This function was introduced in Qt 4.6.</p>
<p><b>See also</b> <a href="qtextdocument.html#isRedoAvailable">isRedoAvailable</a>().</p>


<h3 class="fn"><a name="availableUndoSteps" />int QTextDocument.availableUndoSteps (<i>self</i>)</h3><p>Returns the number of available undo steps.</p>
<p>This function was introduced in Qt 4.6.</p>
<p><b>See also</b> <a href="qtextdocument.html#isUndoAvailable">isUndoAvailable</a>().</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>
<p><b>See also</b> <a href="qtextdocument.html#firstBlock">firstBlock</a>().</p>


<h3 class="fn"><a name="blockCount" />int QTextDocument.blockCount (<i>self</i>)</h3><h3 class="fn"><a name="characterAt" />QChar QTextDocument.characterAt (<i>self</i>, int&#160;<i>pos</i>)</h3><p>Returns the character at position <i>pos</i>, or a null
character if the position is out of range.</p>
<p>This function was introduced in Qt 4.5.</p>
<p><b>See also</b> <a href="qtextdocument.html#characterCount">characterCount</a>().</p>


<h3 class="fn"><a name="characterCount" />int QTextDocument.characterCount (<i>self</i>)</h3><p>Returns the number of characters of this document.</p>
<p>This function was introduced in Qt 4.5.</p>
<p><b>See also</b> <a href="qtextdocument.html#blockCount-prop">blockCount</a>() and <a href="qtextdocument.html#characterAt">characterAt</a>().</p>


<h3 class="fn"><a name="clear" />QTextDocument.clear (<i>self</i>)</h3><p>Clears the document.</p>


<h3 class="fn"><a name="clearUndoRedoStacks" />QTextDocument.clearUndoRedoStacks (<i>self</i>, <a href="qtextdocument.html#Stacks-enum">Stacks</a>&#160;<i>stacks</i>&#160;=&#160;QTextDocument.UndoAndRedoStacks)</h3><p>Clears the stacks specified by <i>stacksToClear</i>.</p>
<p>This method clears any commands on the undo stack, the redo
stack, or both (the default). If commands are cleared, the
appropriate signals are emitted, <a href="qtextdocument.html#undoAvailable">QTextDocument.undoAvailable</a>()
or <a href="qtextdocument.html#redoAvailable">QTextDocument.redoAvailable</a>().</p>
<p>This function was introduced in Qt 4.7.</p>
<p><b>See also</b> <a href="qtextdocument.html#undoAvailable">QTextDocument.undoAvailable</a>()
and <a href="qtextdocument.html#redoAvailable">QTextDocument.redoAvailable</a>().</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="defaultCursorMoveStyle" /><a href="qt.html#CursorMoveStyle-enum">Qt.CursorMoveStyle</a> QTextDocument.defaultCursorMoveStyle (<i>self</i>)</h3><p>The default cursor movement style is used by all <a href="qtextcursor.html">QTextCursor</a> objects created from the
document. The default is <a href="qt.html#CursorMoveStyle-enum">Qt.LogicalMoveStyle</a>.</p>
<p>This function was introduced in Qt 4.8.</p>
<p><b>See also</b> <a href="qtextdocument.html#setDefaultCursorMoveStyle">setDefaultCursorMoveStyle</a>().</p>


<h3 class="fn"><a name="defaultFont" /><a href="qfont.html">QFont</a> QTextDocument.defaultFont (<i>self</i>)</h3><h3 class="fn"><a name="defaultStyleSheet" />QString QTextDocument.defaultStyleSheet (<i>self</i>)</h3><h3 class="fn"><a name="defaultTextOption" /><a href="qtextoption.html">QTextOption</a> QTextDocument.defaultTextOption (<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><b>See also</b> <a href="qtextdocument.html#setDocumentLayout">setDocumentLayout</a>().</p>


<h3 class="fn"><a name="documentMargin" />float QTextDocument.documentMargin (<i>self</i>)</h3><h3 class="fn"><a name="drawContents" />QTextDocument.drawContents (<i>self</i>, <a href="qpainter.html">QPainter</a>&#160;<i>p</i>, <a href="qrectf.html">QRectF</a>&#160;<i>rect</i>&#160;=&#160;QRectF())</h3><p>Draws the content of the document with painter <i>p</i>, clipped
to <i>rect</i>. If <i>rect</i> is a null rectangle (default) then
the document is painted unclipped.</p>
<p>This function was introduced in Qt 4.2.</p>


<h3 class="fn"><a name="end" /><a href="qtextblock.html">QTextBlock</a> QTextDocument.end (<i>self</i>)</h3><p>This function returns a block to test for the end of the
document while iterating over it.</p>
<pre class="cpp">
     <span class="keyword">for</span> (<span class="type"><a href="qtextblock.html">QTextBlock</a></span> it <span class="operator">=</span> doc<span class="operator">-</span><span class="operator">&gt;</span>begin(); it <span class="operator">!</span><span class="operator">=</span> doc<span class="operator">-</span><span class="operator">&gt;</span>end(); it <span class="operator">=</span> it<span class="operator">.</span>next())
         cout <span class="operator">&lt;</span><span class="operator">&lt;</span> it<span class="operator">.</span>text()<span class="operator">.</span>toStdString() <span class="operator">&lt;</span><span class="operator">&lt;</span> endl;
</pre>
<p>The block returned is invalid and represents the block after the
last block in the document. You can use <a href="qtextdocument.html#lastBlock">lastBlock</a>() to retrieve the last
valid block of the document.</p>
<p><b>See also</b> <a href="qtextdocument.html#lastBlock">lastBlock</a>().</p>


<h3 class="fn"><a name="find" /><a href="qtextcursor.html">QTextCursor</a> QTextDocument.find (<i>self</i>, QString&#160;<i>subString</i>, int&#160;<i>position</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>subString</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>subString</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="qregexp.html">QRegExp</a>&#160;<i>expr</i>, int&#160;<i>position</i>&#160;=&#160;0, <a href="qtextdocument-findflags.html">FindFlags</a>&#160;<i>options</i>&#160;=&#160;0)</h3><p>Finds the next occurrence, matching the regular expression,
<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. The <a href="qtextdocument.html#FindFlag-enum">FindCaseSensitively</a> option
is ignored for this overload, use QRegExp.caseSensitivity
instead.</p>
<p>Returns a cursor with the match selected if a match 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-3" /><a href="qtextcursor.html">QTextCursor</a> QTextDocument.find (<i>self</i>, QString&#160;<i>subString</i>, <a href="qtextcursor.html">QTextCursor</a>&#160;<i>cursor</i>, <a href="qtextdocument-findflags.html">FindFlags</a>&#160;<i>options</i>&#160;=&#160;0)</h3><p>This is an overloaded function.</p>
<p>Finds the next occurrence of the string, <i>subString</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>subString</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="find-4" /><a href="qtextcursor.html">QTextCursor</a> QTextDocument.find (<i>self</i>, <a href="qregexp.html">QRegExp</a>&#160;<i>expr</i>, <a href="qtextcursor.html">QTextCursor</a>&#160;<i>cursor</i>, <a href="qtextdocument-findflags.html">FindFlags</a>&#160;<i>options</i>&#160;=&#160;0)</h3><p>This is an overloaded function.</p>
<p>Finds the next occurrence, matching the regular expression,
<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. The <a href="qtextdocument.html#FindFlag-enum">FindCaseSensitively</a> option
is ignored for this overload, use QRegExp.caseSensitivity
instead.</p>
<p>Returns a cursor with the match selected if a match 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="findBlockByLineNumber" /><a href="qtextblock.html">QTextBlock</a> QTextDocument.findBlockByLineNumber (<i>self</i>, int&#160;<i>blockNumber</i>)</h3><p>Returns the text block that contains the specified
<i>lineNumber</i>.</p>
<p>This function was introduced in Qt 4.5.</p>
<p><b>See also</b> <a href="qtextblock.html#firstLineNumber">QTextBlock.firstLineNumber</a>().</p>


<h3 class="fn"><a name="findBlockByNumber" /><a href="qtextblock.html">QTextBlock</a> QTextDocument.findBlockByNumber (<i>self</i>, int&#160;<i>blockNumber</i>)</h3><p>Returns the text block with the specified
<i>blockNumber</i>.</p>
<p>This function was introduced in Qt 4.4.</p>
<p><b>See also</b> <a href="qtextblock.html#blockNumber">QTextBlock.blockNumber</a>().</p>


<h3 class="fn"><a name="firstBlock" /><a href="qtextblock.html">QTextBlock</a> QTextDocument.firstBlock (<i>self</i>)</h3><p>Returns the document's first text block.</p>
<p>This function was introduced in Qt 4.4.</p>


<h3 class="fn"><a name="idealWidth" />float QTextDocument.idealWidth (<i>self</i>)</h3><p>Returns the ideal width of the text document. The ideal width is
the actually used width of the document without optional alignments
taken into account. It is always &lt;= <a href="qtextdocument.html#size-prop">size</a>().width().</p>
<p>This function was introduced in Qt 4.2.</p>
<p><b>See also</b> <a href="qtextdocument.html#adjustSize">adjustSize</a>() and <a href="qtextdocument.html#textWidth-prop">textWidth</a>.</p>


<h3 class="fn"><a name="indentWidth" />float QTextDocument.indentWidth (<i>self</i>)</h3><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 if redo is available; otherwise returns false.</p>
<p><b>See also</b> <a href="qtextdocument.html#isUndoAvailable">isUndoAvailable</a>() and
<a href="qtextdocument.html#availableRedoSteps">availableRedoSteps</a>().</p>


<h3 class="fn"><a name="isUndoAvailable" />bool QTextDocument.isUndoAvailable (<i>self</i>)</h3><p>Returns true if undo is available; otherwise returns false.</p>
<p><b>See also</b> <a href="qtextdocument.html#isRedoAvailable">isRedoAvailable</a>() and
<a href="qtextdocument.html#availableUndoSteps">availableUndoSteps</a>().</p>


<h3 class="fn"><a name="isUndoRedoEnabled" />bool QTextDocument.isUndoRedoEnabled (<i>self</i>)</h3><h3 class="fn"><a name="lastBlock" /><a href="qtextblock.html">QTextBlock</a> QTextDocument.lastBlock (<i>self</i>)</h3><p>Returns the document's last (valid) text block.</p>
<p>This function was introduced in Qt 4.4.</p>


<h3 class="fn"><a name="lineCount" />int QTextDocument.lineCount (<i>self</i>)</h3><p>Returns the number of lines of this document (if the layout
supports this). Otherwise, this is identical to the number of
blocks.</p>
<p>This function was introduced in Qt 4.5.</p>
<p><b>See also</b> <a href="qtextdocument.html#blockCount-prop">blockCount</a>() and <a href="qtextdocument.html#characterCount">characterCount</a>().</p>


<h3 class="fn"><a name="loadResource" />QVariant 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 laid out again.</p>


<h3 class="fn"><a name="maximumBlockCount" />int QTextDocument.maximumBlockCount (<i>self</i>)</h3><h3 class="fn"><a name="metaInformation" />QString 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><b>See also</b> <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>
<p>If the document is already paginated through a specified height
in the <a href="qtextdocument.html#pageSize-prop">pageSize</a>()
property it is printed as-is.</p>
<p>If the document is not paginated, like for example a document
used in a <a href="qtextedit.html">QTextEdit</a>, then a temporary
copy of the document is created and the copy is broken into
multiple pages according to the size of the <a href="qprinter.html">QPrinter</a>'s paperRect(). By default a 2 cm
margin is set around the document contents. In addition the current
page number is printed at the bottom of each page.</p>
<p>Note that <a href="qprinter.html#PrintRange-enum">QPrinter.Selection</a> is not
supported as print range with this function since the selection is
a property of <a href="qtextcursor.html">QTextCursor</a>. If you
have a <a href="qtextedit.html">QTextEdit</a> associated with your
<a href="qtextdocument.html">QTextDocument</a> then you can use
<a href="qtextedit.html">QTextEdit</a>'s print() function because
<a href="qtextedit.html">QTextEdit</a> has access to the user's
selection.</p>
<p><b>See also</b> <a href="qtextedit.html#print">QTextEdit.print</a>().</p>


<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>
<p>If the document is already paginated through a specified height
in the <a href="qtextdocument.html#pageSize-prop">pageSize</a>()
property it is printed as-is.</p>
<p>If the document is not paginated, like for example a document
used in a <a href="qtextedit.html">QTextEdit</a>, then a temporary
copy of the document is created and the copy is broken into
multiple pages according to the size of the <a href="qprinter.html">QPrinter</a>'s paperRect(). By default a 2 cm
margin is set around the document contents. In addition the current
page number is printed at the bottom of each page.</p>
<p>Note that <a href="qprinter.html#PrintRange-enum">QPrinter.Selection</a> is not
supported as print range with this function since the selection is
a property of <a href="qtextcursor.html">QTextCursor</a>. If you
have a <a href="qtextedit.html">QTextEdit</a> associated with your
<a href="qtextdocument.html">QTextDocument</a> then you can use
<a href="qtextedit.html">QTextEdit</a>'s print() function because
<a href="qtextedit.html">QTextEdit</a> has access to the user's
selection.</p>
<p><b>See also</b> <a href="qtextedit.html#print">QTextEdit.print</a>().</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>
<p>The provided <i>cursor</i> is positioned at the end of the
location where the edition operation was redone.</p>
<p>This function was introduced in Qt 4.2.</p>


<h3 class="fn"><a name="redo-2" />QTextDocument.redo (<i>self</i>, <a href="qtextcursor.html">QTextCursor</a>&#160;<i>cursor</i>)</h3><p>This is an overloaded function.</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" />QVariant 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>
<p><b>See also</b> <a href="qtextdocument.html#ResourceType-enum">QTextDocument.ResourceType</a>.</p>


<h3 class="fn"><a name="revision" />int QTextDocument.revision (<i>self</i>)</h3><p>Returns the document's revision (if undo is enabled).</p>
<p>The revision is guaranteed to increase when a document that is
not modified is edited.</p>
<p>This function was introduced in Qt 4.4.</p>
<p><b>See also</b> <a href="qtextblock.html#revision">QTextBlock.revision</a>() and <a href="qtextdocument.html#modified-prop">isModified</a>().</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="setDefaultCursorMoveStyle" />QTextDocument.setDefaultCursorMoveStyle (<i>self</i>, <a href="qt.html#CursorMoveStyle-enum">Qt.CursorMoveStyle</a>&#160;<i>style</i>)</h3><p>Sets the default cursor movement style to the given
<i>style</i>.</p>
<p>This function was introduced in Qt 4.8.</p>
<p><b>See also</b> <a href="qtextdocument.html#defaultCursorMoveStyle">defaultCursorMoveStyle</a>().</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="setDefaultStyleSheet" />QTextDocument.setDefaultStyleSheet (<i>self</i>, QString&#160;<i>sheet</i>)</h3><h3 class="fn"><a name="setDefaultTextOption" />QTextDocument.setDefaultTextOption (<i>self</i>, <a href="qtextoption.html">QTextOption</a>&#160;<i>option</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><b>See also</b> <a href="qtextdocument.html#documentLayoutChanged">documentLayoutChanged</a>().</p>


<h3 class="fn"><a name="setDocumentMargin" />QTextDocument.setDocumentMargin (<i>self</i>, float&#160;<i>margin</i>)</h3><h3 class="fn"><a name="setHtml" />QTextDocument.setHtml (<i>self</i>, QString&#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><b>Note:</b> It is the responsibility of the caller to make sure
that the text is correctly decoded when a <a href="qstring.html">QString</a> containing HTML is created and passed to
setHtml().</p>
<p><b>See also</b> <a href="qtextdocument.html#setPlainText">setPlainText</a>() and <a href="richtext-html-subset.html">Supported HTML Subset</a>.</p>


<h3 class="fn"><a name="setIndentWidth" />QTextDocument.setIndentWidth (<i>self</i>, float&#160;<i>width</i>)</h3><h3 class="fn"><a name="setMaximumBlockCount" />QTextDocument.setMaximumBlockCount (<i>self</i>, int&#160;<i>maximum</i>)</h3><h3 class="fn"><a name="setMetaInformation" />QTextDocument.setMetaInformation (<i>self</i>, <a href="qtextdocument.html#MetaInformation-enum">MetaInformation</a>&#160;<i>info</i>, QString)</h3><p>Sets the document's meta information of the type specified by
<i>info</i> to the given <i>string</i>.</p>
<p><b>See also</b> <a href="qtextdocument.html#metaInformation">metaInformation</a>().</p>


<h3 class="fn"><a name="setModified" />QTextDocument.setModified (<i>self</i>, bool&#160;<i>on</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>, QString&#160;<i>text</i>)</h3><p>Replaces the entire contents of the document with the given
plain <i>text</i>.</p>
<p><b>See also</b> <a href="qtextdocument.html#setHtml">setHtml</a>().</p>


<h3 class="fn"><a name="setTextWidth" />QTextDocument.setTextWidth (<i>self</i>, float&#160;<i>width</i>)</h3><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="size" /><a href="qsizef.html">QSizeF</a> QTextDocument.size (<i>self</i>)</h3><h3 class="fn"><a name="textWidth" />float QTextDocument.textWidth (<i>self</i>)</h3><h3 class="fn"><a name="toHtml" />QString 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 class="cpp">
 <span class="operator">&lt;</span>html<span class="operator">&gt;</span><span class="operator">&lt;</span>head<span class="operator">&gt;</span><span class="operator">&lt;</span>meta http<span class="operator">-</span>equiv<span class="operator">=</span><span class="string">"Content-Type"</span> content<span class="operator">=</span><span class="string">"text/html; charset=utf-8"</span><span class="operator">&gt;</span><span class="operator">&lt;</span><span class="operator">/</span>head<span class="operator">&gt;</span><span class="operator">&lt;</span>body<span class="operator">&gt;</span><span class="operator">.</span><span class="operator">.</span><span class="operator">.</span>
</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><b>See also</b> <a href="richtext-html-subset.html">Supported
HTML Subset</a>.</p>


<h3 class="fn"><a name="toPlainText" />QString 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><b>See also</b> <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 undo is
available. The provided <i>cursor</i> is positioned at the end of
the location where the edition operation was undone.</p>
<p>See the <a href="qundo.html">Qt Undo Framework</a> documentation
for details.</p>
<p>This function was introduced in Qt 4.2.</p>
<p><b>See also</b> <a href="qtextdocument.html#undoAvailable">undoAvailable</a>() and <a href="qtextdocument.html#undoRedoEnabled-prop">isUndoRedoEnabled</a>().</p>


<h3 class="fn"><a name="undo-2" />QTextDocument.undo (<i>self</i>, <a href="qtextcursor.html">QTextCursor</a>&#160;<i>cursor</i>)</h3><p>This is an overloaded function.</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="blockCountChanged" />void blockCountChanged (int)</h3><p>This is the default overload of this signal.</p><p>This signal is emitted when the total number of text blocks in
the document changes. The value passed in <i>newBlockCount</i> is
the new total.</p>
<p>This function was introduced in Qt 4.3.</p>


<h3 class="fn"><a name="contentsChange" />void contentsChange (int,int,int)</h3><p>This is the default overload of this signal.</p><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><b>See also</b> <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 is the default overload of this signal.</p><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><b>See also</b> <a href="qtextdocument.html#contentsChange">contentsChange</a>().</p>


<h3 class="fn"><a name="cursorPositionChanged" />void cursorPositionChanged (const QTextCursor&amp;)</h3><p>This is the default overload of this signal.</p><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>. If you need a signal when the cursor is moved with
the arrow keys you can use the <a href="qtextedit.html#cursorPositionChanged">cursorPositionChanged()</a>
signal in <a href="qtextedit.html">QTextEdit</a>.</p>


<h3 class="fn"><a name="documentLayoutChanged" />void documentLayoutChanged ()</h3><p>This is the default overload of this signal.</p><p>This signal is emitted when a new document layout is set.</p>
<p>This function was introduced in Qt 4.4.</p>
<p><b>See also</b> <a href="qtextdocument.html#setDocumentLayout">setDocumentLayout</a>().</p>


<h3 class="fn"><a name="modificationChanged" />void modificationChanged (bool)</h3><p>This is the default overload of this signal.</p><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 is the default overload of this signal.</p><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 is the default overload of this signal.</p><p>This signal is emitted whenever undo operations become available
(<i>available</i> is true) or unavailable (<i>available</i> is
false).</p>
<p>See the <a href="qundo.html">Qt Undo Framework</a> documentation
for details.</p>
<p><b>See also</b> <a href="qtextdocument.html#undo">undo</a>() and
<a href="qtextdocument.html#undoRedoEnabled-prop">isUndoRedoEnabled</a>().</p>


<h3 class="fn"><a name="undoCommandAdded" />void undoCommandAdded ()</h3><p>This is the default overload of this signal.</p><p>This signal is emitted every time a new level of undo is added
to the <a href="qtextdocument.html">QTextDocument</a>.</p>
<p>This function was introduced in Qt 4.4.</p>
<address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt&#160;4.10.3 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.qtsoftware.com">Nokia</a> 2012</td><td align="right" width="25%">Qt&#160;4.8.5</td></tr></table></div></address></body></html>