<?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>QTextList 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">  </td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a> · <a href="classes.html"><font color="#004faf">All Classes</font></a> · <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QTextList Class Reference<br /><sup><sup>[<a href="qtgui.html">QtGui</a> module]</sup></sup></h1><p>The QTextList class provides a decorated list of items in a <a href="qtextdocument.html">QTextDocument</a>. <a href="#details">More...</a></p> <p>Inherits <a href="qtextblockgroup.html">QTextBlockGroup</a>.</p><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qtextlist.html#QTextList">__init__</a></b> (<i>self</i>, QTextDocument <i>doc</i>)</li><li><div class="fn" /><b><a href="qtextlist.html#add">add</a></b> (<i>self</i>, QTextBlock <i>block</i>)</li><li><div class="fn" />int <b><a href="qtextlist.html#count">count</a></b> (<i>self</i>)</li><li><div class="fn" />QTextListFormat <b><a href="qtextlist.html#format">format</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qtextlist.html#isEmpty">isEmpty</a></b> (<i>self</i>)</li><li><div class="fn" />QTextBlock <b><a href="qtextlist.html#item">item</a></b> (<i>self</i>, int <i>i</i>)</li><li><div class="fn" />int <b><a href="qtextlist.html#itemNumber">itemNumber</a></b> (<i>self</i>, QTextBlock)</li><li><div class="fn" />QString <b><a href="qtextlist.html#itemText">itemText</a></b> (<i>self</i>, QTextBlock)</li><li><div class="fn" /><b><a href="qtextlist.html#remove">remove</a></b> (<i>self</i>, QTextBlock)</li><li><div class="fn" /><b><a href="qtextlist.html#removeItem">removeItem</a></b> (<i>self</i>, int <i>i</i>)</li><li><div class="fn" /><b><a href="qtextlist.html#setFormat">setFormat</a></b> (<i>self</i>, QTextListFormat <i>aformat</i>)</li></ul><h3>Special Methods</h3><ul><li><div class="fn" /> <b><a href="qtextlist.html#__len__">__len__</a></b> (<i>self</i>)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QTextList class provides a decorated list of items in a <a href="qtextdocument.html">QTextDocument</a>.</p> <p>A list contains a sequence of text blocks, each of which is marked with a bullet point or other symbol. Multiple levels of lists can be used, and the automatic numbering feature provides support for ordered numeric and alphabetical lists.</p> <p>Lists are created by using a text cursor to insert an empty list at the current position or by moving existing text into a new list. The <a href="qtextcursor.html#insertList">QTextCursor.insertList</a>() function inserts an empty block into the document at the cursor position, and makes it the first item in a list.</p> <pre class="cpp"> <span class="type"><a href="qtextlistformat.html">QTextListFormat</a></span> listFormat; <span class="keyword">if</span> (list) { listFormat <span class="operator">=</span> list<span class="operator">-</span><span class="operator">></span>format(); listFormat<span class="operator">.</span>setIndent(listFormat<span class="operator">.</span>indent() <span class="operator">+</span> <span class="number">1</span>); } listFormat<span class="operator">.</span>setStyle(<span class="type"><a href="qtextlistformat.html">QTextListFormat</a></span><span class="operator">.</span>ListDisc); cursor<span class="operator">.</span>insertList(listFormat); </pre> <p>The <a href="qtextcursor.html#createList">QTextCursor.createList</a>() function takes the contents of the cursor's current block and turns it into the first item of a new list.</p> <p>The cursor's current list is found with <a href="qtextcursor.html#currentList">QTextCursor.currentList</a>().</p> <p>The number of items in a list is given by <a href="qtextlist.html#count">count</a>(). Each item can be obtained by its index in the list with the <a href="qtextlist.html#item">item</a>() function. Similarly, the index of a given item can be found with <a href="qtextlist.html#itemNumber">itemNumber</a>(). The text of each item can be found with the <a href="qtextlist.html#itemText">itemText</a>() function.</p> <p>Note that the items in the list may not be adjacent elements in the document. For example, the top-level items in a multi-level list will be separated by the items in lower levels of the list.</p> <p>List items can be deleted by index with the <a href="qtextlist.html#removeItem">removeItem</a>() function. <a href="qtextlist.html#remove">remove</a>() deletes the specified item in the list.</p> <p>The list's format is set with <a href="qtextlist.html#setFormat">setFormat</a>() and read with <a href="qtextlist.html#format">format</a>(). The format describes the decoration of the list itself, and not the individual items.</p> <hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QTextList" />QTextList.__init__ (<i>self</i>, <a href="qtextdocument.html">QTextDocument</a> <i>doc</i>)</h3><h3 class="fn"><a name="add" />QTextList.add (<i>self</i>, <a href="qtextblock.html">QTextBlock</a> <i>block</i>)</h3><p>Makes the given <i>block</i> part of the list.</p> <p><b>See also</b> <a href="qtextlist.html#remove">remove</a>() and <a href="qtextlist.html#removeItem">removeItem</a>().</p> <h3 class="fn"><a name="count" />int QTextList.count (<i>self</i>)</h3><p>Returns the number of items in the list.</p> <h3 class="fn"><a name="format" /><a href="qtextlistformat.html">QTextListFormat</a> QTextList.format (<i>self</i>)</h3><p>Returns the list's format.</p> <p><b>See also</b> <a href="qtextlist.html#setFormat">setFormat</a>().</p> <h3 class="fn"><a name="isEmpty" />bool QTextList.isEmpty (<i>self</i>)</h3><h3 class="fn"><a name="item" /><a href="qtextblock.html">QTextBlock</a> QTextList.item (<i>self</i>, int <i>i</i>)</h3><p>Returns the <i>i</i>-th text block in the list.</p> <p><b>See also</b> <a href="qtextlist.html#count">count</a>() and <a href="qtextlist.html#itemText">itemText</a>().</p> <h3 class="fn"><a name="itemNumber" />int QTextList.itemNumber (<i>self</i>, <a href="qtextblock.html">QTextBlock</a>)</h3><p>Returns the index of the list item that corresponds to the given <i>block</i>. Returns -1 if the block was not present in the list.</p> <h3 class="fn"><a name="itemText" />QString QTextList.itemText (<i>self</i>, <a href="qtextblock.html">QTextBlock</a>)</h3><p>Returns the text of the list item that corresponds to the given <i>block</i>.</p> <h3 class="fn"><a name="remove" />QTextList.remove (<i>self</i>, <a href="qtextblock.html">QTextBlock</a>)</h3><p>Removes the given <i>block</i> from the list.</p> <p><b>See also</b> <a href="qtextlist.html#add">add</a>() and <a href="qtextlist.html#removeItem">removeItem</a>().</p> <h3 class="fn"><a name="removeItem" />QTextList.removeItem (<i>self</i>, int <i>i</i>)</h3><p>Removes the item at item position <i>i</i> from the list. When the last item in the list is removed, the list is automatically deleted by the <a href="qtextdocument.html">QTextDocument</a> that owns it.</p> <p><b>See also</b> <a href="qtextlist.html#add">add</a>() and <a href="qtextlist.html#remove">remove</a>().</p> <h3 class="fn"><a name="setFormat" />QTextList.setFormat (<i>self</i>, <a href="qtextlistformat.html">QTextListFormat</a> <i>aformat</i>)</h3><p>Sets the list's format to <i>format</i>.</p> <p><b>See also</b> <a href="qtextlist.html#format">format</a>().</p> <h3 class="fn"><a name="__len__" /> QTextList.__len__ (<i>self</i>)</h3><address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt 4.10.3 for X11</td><td align="center" width="50%">Copyright © <a href="http://www.riverbankcomputing.com">Riverbank Computing Ltd</a> and <a href="http://www.qtsoftware.com">Nokia</a> 2012</td><td align="right" width="25%">Qt 4.8.5</td></tr></table></div></address></body></html>