<?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>QTextBoundaryFinder 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">QTextBoundaryFinder Class Reference<br /><sup><sup>[<a href="qtcore.html">QtCore</a> module]</sup></sup></h1><p>The QTextBoundaryFinder class provides a way of finding Unicode text boundaries in a string. <a href="#details">More...</a></p> <h3>Types</h3><ul><li><div class="fn" />enum <b><a href="qtextboundaryfinder.html#BoundaryReason-enum">BoundaryReason</a></b> { NotAtBoundary, StartWord, EndWord }</li><li><div class="fn" />class <b><a href="qtextboundaryfinder-boundaryreasons.html">BoundaryReasons</a></b></li><li><div class="fn" />enum <b><a href="qtextboundaryfinder.html#BoundaryType-enum">BoundaryType</a></b> { Grapheme, Word, Line, Sentence }</li></ul><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qtextboundaryfinder.html#QTextBoundaryFinder">__init__</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qtextboundaryfinder.html#QTextBoundaryFinder-2">__init__</a></b> (<i>self</i>, QTextBoundaryFinder <i>other</i>)</li><li><div class="fn" /><b><a href="qtextboundaryfinder.html#QTextBoundaryFinder-3">__init__</a></b> (<i>self</i>, BoundaryType <i>type</i>, QString <i>string</i>)</li><li><div class="fn" />BoundaryReasons <b><a href="qtextboundaryfinder.html#boundaryReasons">boundaryReasons</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qtextboundaryfinder.html#isAtBoundary">isAtBoundary</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qtextboundaryfinder.html#isValid">isValid</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qtextboundaryfinder.html#position">position</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qtextboundaryfinder.html#setPosition">setPosition</a></b> (<i>self</i>, int <i>position</i>)</li><li><div class="fn" />QString <b><a href="qtextboundaryfinder.html#string">string</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qtextboundaryfinder.html#toEnd">toEnd</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qtextboundaryfinder.html#toNextBoundary">toNextBoundary</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qtextboundaryfinder.html#toPreviousBoundary">toPreviousBoundary</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qtextboundaryfinder.html#toStart">toStart</a></b> (<i>self</i>)</li><li><div class="fn" />BoundaryType <b><a href="qtextboundaryfinder.html#type">type</a></b> (<i>self</i>)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QTextBoundaryFinder class provides a way of finding Unicode text boundaries in a string.</p> <p>QTextBoundaryFinder allows to find Unicode text boundaries in a string, similar to the Unicode text boundary specification (see http://www.unicode.org/reports/tr29/tr29-11.html).</p> <p>QTextBoundaryFinder can operate on a <a href="qstring.html">QString</a> in four possible modes depending on the value of <i>BoundaryType</i>.</p> <p>Units of Unicode characters that make up what the user thinks of as a character or basic unit of the language are here called Grapheme clusters. The two unicode characters 'A' + diaeresis do for example form one grapheme cluster as the user thinks of them as one character, yet it is in this case represented by two unicode code points.</p> <p>Word boundaries are there to locate the start and end of what a language considers to be a word.</p> <p>Line break boundaries give possible places where a line break might happen and sentence boundaries will show the beginning and end of whole sentences.</p> <p>The first position in a string is always a valid boundary and refers to the position before the first character. The last position at the length of the string is also valid and refers to the position after the last character.</p> <hr /><h2>Type Documentation</h2><h3 class="fn"><a name="BoundaryReason-enum" />QTextBoundaryFinder.BoundaryReason</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>QTextBoundaryFinder.NotAtBoundary</tt></td> <td class="topAlign"><tt>0</tt></td> <td class="topAlign">The boundary finder is not at a boundary position.</td> </tr> <tr> <td class="topAlign"><tt>QTextBoundaryFinder.StartWord</tt></td> <td class="topAlign"><tt>1</tt></td> <td class="topAlign">The boundary finder is at the start of a word.</td> </tr> <tr> <td class="topAlign"><tt>QTextBoundaryFinder.EndWord</tt></td> <td class="topAlign"><tt>2</tt></td> <td class="topAlign">The boundary finder is at the end of a word.</td> </tr> </table> <p>The BoundaryReasons type is a typedef for <a href="qflags.html">QFlags</a><BoundaryReason>. It stores an OR combination of BoundaryReason values.</p> <h3 class="fn"><a name="BoundaryType-enum" />QTextBoundaryFinder.BoundaryType</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>QTextBoundaryFinder.Grapheme</tt></td> <td class="topAlign"><tt>0</tt></td> <td class="topAlign">Finds a grapheme which is the smallest boundary. It including letters, punctation marks, numerals and more.</td> </tr> <tr> <td class="topAlign"><tt>QTextBoundaryFinder.Word</tt></td> <td class="topAlign"><tt>1</tt></td> <td class="topAlign">Finds a word.</td> </tr> <tr> <td class="topAlign"><tt>QTextBoundaryFinder.Line</tt></td> <td class="topAlign"><tt>2</tt></td> <td class="topAlign">Finds possible positions for breaking the text into multiple lines.</td> </tr> <tr> <td class="topAlign"><tt>QTextBoundaryFinder.Sentence</tt></td> <td class="topAlign"><tt>3</tt></td> <td class="topAlign">Finds sentence boundaries. These include periods, question marks etc.</td> </tr> </table> <hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QTextBoundaryFinder" />QTextBoundaryFinder.__init__ (<i>self</i>)</h3><p>Constructs an invalid <a href="qtextboundaryfinder.html">QTextBoundaryFinder</a> object.</p> <h3 class="fn"><a name="QTextBoundaryFinder-2" />QTextBoundaryFinder.__init__ (<i>self</i>, <a href="qtextboundaryfinder.html">QTextBoundaryFinder</a> <i>other</i>)</h3><p>Copies the <a href="qtextboundaryfinder.html">QTextBoundaryFinder</a> object, <i>other</i>.</p> <h3 class="fn"><a name="QTextBoundaryFinder-3" />QTextBoundaryFinder.__init__ (<i>self</i>, <a href="qtextboundaryfinder.html#BoundaryType-enum">BoundaryType</a> <i>type</i>, QString <i>string</i>)</h3><p>Creates a <a href="qtextboundaryfinder.html">QTextBoundaryFinder</a> object of <i>type</i> operating on <i>string</i>.</p> <h3 class="fn"><a name="boundaryReasons" /><a href="qtextboundaryfinder-boundaryreasons.html">BoundaryReasons</a> QTextBoundaryFinder.boundaryReasons (<i>self</i>)</h3><p>Returns the reasons for the boundary finder to have chosen the current position as a boundary.</p> <h3 class="fn"><a name="isAtBoundary" />bool QTextBoundaryFinder.isAtBoundary (<i>self</i>)</h3><p>Returns true if the object's <a href="qtextboundaryfinder.html#position">position</a>() is currently at a valid text boundary.</p> <h3 class="fn"><a name="isValid" />bool QTextBoundaryFinder.isValid (<i>self</i>)</h3><p>Returns true if the text boundary finder is valid; otherwise returns false. A default <a href="qtextboundaryfinder.html">QTextBoundaryFinder</a> is invalid.</p> <h3 class="fn"><a name="position" />int QTextBoundaryFinder.position (<i>self</i>)</h3><p>Returns the current position of the <a href="qtextboundaryfinder.html">QTextBoundaryFinder</a>.</p> <p>The range is from 0 (the beginning of the string) to the length of the string inclusive.</p> <p><b>See also</b> <a href="qtextboundaryfinder.html#setPosition">setPosition</a>().</p> <h3 class="fn"><a name="setPosition" />QTextBoundaryFinder.setPosition (<i>self</i>, int <i>position</i>)</h3><p>Sets the current position of the <a href="qtextboundaryfinder.html">QTextBoundaryFinder</a> to <i>position</i>.</p> <p>If <i>position</i> is out of bounds, it will be bound to only valid positions. In this case, valid positions are from 0 to the length of the string inclusive.</p> <p><b>See also</b> <a href="qtextboundaryfinder.html#position">position</a>().</p> <h3 class="fn"><a name="string" />QString QTextBoundaryFinder.string (<i>self</i>)</h3><p>Returns the string the <a href="qtextboundaryfinder.html">QTextBoundaryFinder</a> object operates on.</p> <h3 class="fn"><a name="toEnd" />QTextBoundaryFinder.toEnd (<i>self</i>)</h3><p>Moves the finder to the end of the string. This is equivalent to setPosition(string.length()).</p> <p><b>See also</b> <a href="qtextboundaryfinder.html#setPosition">setPosition</a>() and <a href="qtextboundaryfinder.html#position">position</a>().</p> <h3 class="fn"><a name="toNextBoundary" />int QTextBoundaryFinder.toNextBoundary (<i>self</i>)</h3><p>Moves the <a href="qtextboundaryfinder.html">QTextBoundaryFinder</a> to the next boundary position and returns that position.</p> <p>Returns -1 if there is no next boundary.</p> <h3 class="fn"><a name="toPreviousBoundary" />int QTextBoundaryFinder.toPreviousBoundary (<i>self</i>)</h3><p>Moves the <a href="qtextboundaryfinder.html">QTextBoundaryFinder</a> to the previous boundary position and returns that position.</p> <p>Returns -1 if there is no previous boundary.</p> <h3 class="fn"><a name="toStart" />QTextBoundaryFinder.toStart (<i>self</i>)</h3><p>Moves the finder to the start of the string. This is equivalent to setPosition(0).</p> <p><b>See also</b> <a href="qtextboundaryfinder.html#setPosition">setPosition</a>() and <a href="qtextboundaryfinder.html#position">position</a>().</p> <h3 class="fn"><a name="type" /><a href="qtextboundaryfinder.html#BoundaryType-enum">BoundaryType</a> QTextBoundaryFinder.type (<i>self</i>)</h3><p>Returns the type of the <a href="qtextboundaryfinder.html">QTextBoundaryFinder</a>.</p> <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>