<?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>QStringRef 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">QStringRef Class Reference<br /><sup><sup>[<a href="qtcore.html">QtCore</a> module]</sup></sup></h1><p>The QStringRef class provides a thin wrapper around <a href="qstring.html">QString</a> substrings. <a href="#details">More...</a></p> <h3>Methods</h3><ul><li><div class="fn" /><b><a href="qstringref.html#QStringRef">__init__</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qstringref.html#QStringRef-2">__init__</a></b> (<i>self</i>, QString <i>aString</i>, int <i>aPosition</i>, int <i>aSize</i>)</li><li><div class="fn" /><b><a href="qstringref.html#QStringRef-3">__init__</a></b> (<i>self</i>, QString <i>aString</i>)</li><li><div class="fn" /><b><a href="qstringref.html#QStringRef-4">__init__</a></b> (<i>self</i>, QStringRef <i>other</i>)</li><li><div class="fn" />QStringRef <b><a href="qstringref.html#appendTo">appendTo</a></b> (<i>self</i>, QString <i>string</i>)</li><li><div class="fn" />QChar <b><a href="qstringref.html#at">at</a></b> (<i>self</i>, int <i>i</i>)</li><li><div class="fn" /><b><a href="qstringref.html#clear">clear</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qstringref.html#compare">compare</a></b> (<i>self</i>, QString <i>other</i>, Qt.CaseSensitivity <i>cs</i> = Qt.CaseSensitive)</li><li><div class="fn" />int <b><a href="qstringref.html#compare-2">compare</a></b> (<i>self</i>, QStringRef <i>other</i>, Qt.CaseSensitivity <i>cs</i> = Qt.CaseSensitive)</li><li><div class="fn" />int <b><a href="qstringref.html#compare-3">compare</a></b> (<i>self</i>, QLatin1String <i>other</i>, Qt.CaseSensitivity <i>cs</i> = Qt.CaseSensitive)</li><li><div class="fn" />QChar <b><a href="qstringref.html#constData">constData</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qstringref.html#contains">contains</a></b> (<i>self</i>, QString <i>str</i>, Qt.CaseSensitivity <i>cs</i> = Qt.CaseSensitive)</li><li><div class="fn" />bool <b><a href="qstringref.html#contains-2">contains</a></b> (<i>self</i>, QLatin1String <i>str</i>, Qt.CaseSensitivity <i>cs</i> = Qt.CaseSensitive)</li><li><div class="fn" />bool <b><a href="qstringref.html#contains-3">contains</a></b> (<i>self</i>, QStringRef <i>str</i>, Qt.CaseSensitivity <i>cs</i> = Qt.CaseSensitive)</li><li><div class="fn" />int <b><a href="qstringref.html#count">count</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qstringref.html#count-2">count</a></b> (<i>self</i>, QString <i>str</i>, Qt.CaseSensitivity <i>cs</i> = Qt.CaseSensitive)</li><li><div class="fn" />int <b><a href="qstringref.html#count-3">count</a></b> (<i>self</i>, QStringRef <i>str</i>, Qt.CaseSensitivity <i>cs</i> = Qt.CaseSensitive)</li><li><div class="fn" />QChar <b><a href="qstringref.html#data">data</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qstringref.html#endsWith">endsWith</a></b> (<i>self</i>, QString <i>str</i>, Qt.CaseSensitivity <i>cs</i> = Qt.CaseSensitive)</li><li><div class="fn" />bool <b><a href="qstringref.html#endsWith-2">endsWith</a></b> (<i>self</i>, QLatin1String <i>str</i>, Qt.CaseSensitivity <i>cs</i> = Qt.CaseSensitive)</li><li><div class="fn" />bool <b><a href="qstringref.html#endsWith-3">endsWith</a></b> (<i>self</i>, QStringRef <i>str</i>, Qt.CaseSensitivity <i>cs</i> = Qt.CaseSensitive)</li><li><div class="fn" />int <b><a href="qstringref.html#indexOf">indexOf</a></b> (<i>self</i>, QString <i>str</i>, int <i>from</i> = 0, Qt.CaseSensitivity <i>cs</i> = Qt.CaseSensitive)</li><li><div class="fn" />int <b><a href="qstringref.html#indexOf-2">indexOf</a></b> (<i>self</i>, QLatin1String <i>str</i>, int <i>from</i> = 0, Qt.CaseSensitivity <i>cs</i> = Qt.CaseSensitive)</li><li><div class="fn" />int <b><a href="qstringref.html#indexOf-3">indexOf</a></b> (<i>self</i>, QStringRef <i>str</i>, int <i>from</i> = 0, Qt.CaseSensitivity <i>cs</i> = Qt.CaseSensitive)</li><li><div class="fn" />bool <b><a href="qstringref.html#isEmpty">isEmpty</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qstringref.html#isNull">isNull</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qstringref.html#lastIndexOf">lastIndexOf</a></b> (<i>self</i>, QString <i>str</i>, int <i>from</i> = -1, Qt.CaseSensitivity <i>cs</i> = Qt.CaseSensitive)</li><li><div class="fn" />int <b><a href="qstringref.html#lastIndexOf-2">lastIndexOf</a></b> (<i>self</i>, QLatin1String <i>str</i>, int <i>from</i> = -1, Qt.CaseSensitivity <i>cs</i> = Qt.CaseSensitive)</li><li><div class="fn" />int <b><a href="qstringref.html#lastIndexOf-3">lastIndexOf</a></b> (<i>self</i>, QStringRef <i>str</i>, int <i>from</i> = -1, Qt.CaseSensitivity <i>cs</i> = Qt.CaseSensitive)</li><li><div class="fn" />int <b><a href="qstringref.html#length">length</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qstringref.html#localeAwareCompare">localeAwareCompare</a></b> (<i>self</i>, QString <i>s</i>)</li><li><div class="fn" />int <b><a href="qstringref.html#localeAwareCompare-2">localeAwareCompare</a></b> (<i>self</i>, QStringRef <i>s</i>)</li><li><div class="fn" />int <b><a href="qstringref.html#position">position</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qstringref.html#size">size</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qstringref.html#startsWith">startsWith</a></b> (<i>self</i>, QString <i>str</i>, Qt.CaseSensitivity <i>cs</i> = Qt.CaseSensitive)</li><li><div class="fn" />bool <b><a href="qstringref.html#startsWith-2">startsWith</a></b> (<i>self</i>, QLatin1String <i>str</i>, Qt.CaseSensitivity <i>cs</i> = Qt.CaseSensitive)</li><li><div class="fn" />bool <b><a href="qstringref.html#startsWith-3">startsWith</a></b> (<i>self</i>, QStringRef <i>str</i>, Qt.CaseSensitivity <i>cs</i> = Qt.CaseSensitive)</li><li><div class="fn" />QString <b><a href="qstringref.html#string">string</a></b> (<i>self</i>)</li><li><div class="fn" />QByteArray <b><a href="qstringref.html#toAscii">toAscii</a></b> (<i>self</i>)</li><li><div class="fn" />QByteArray <b><a href="qstringref.html#toLatin1">toLatin1</a></b> (<i>self</i>)</li><li><div class="fn" />QByteArray <b><a href="qstringref.html#toLocal8Bit">toLocal8Bit</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qstringref.html#toString">toString</a></b> (<i>self</i>)</li><li><div class="fn" />list-of-int <b><a href="qstringref.html#toUcs4">toUcs4</a></b> (<i>self</i>)</li><li><div class="fn" />QByteArray <b><a href="qstringref.html#toUtf8">toUtf8</a></b> (<i>self</i>)</li><li><div class="fn" />QChar <b><a href="qstringref.html#unicode">unicode</a></b> (<i>self</i>)</li></ul><h3>Static Methods</h3><ul><li><div class="fn" />int <b><a href="qstringref.html#compare-4">compare</a></b> (QStringRef <i>s1</i>, QString <i>s2</i>, Qt.CaseSensitivity <i>cs</i> = Qt.CaseSensitive)</li><li><div class="fn" />int <b><a href="qstringref.html#compare-5">compare</a></b> (QStringRef <i>s1</i>, QStringRef <i>s2</i>, Qt.CaseSensitivity <i>cs</i> = Qt.CaseSensitive)</li><li><div class="fn" />int <b><a href="qstringref.html#compare-6">compare</a></b> (QStringRef <i>s1</i>, QLatin1String <i>s2</i>, Qt.CaseSensitivity <i>cs</i> = Qt.CaseSensitive)</li><li><div class="fn" />int <b><a href="qstringref.html#localeAwareCompare-3">localeAwareCompare</a></b> (QStringRef <i>s1</i>, QString <i>s2</i>)</li><li><div class="fn" />int <b><a href="qstringref.html#localeAwareCompare-4">localeAwareCompare</a></b> (QStringRef <i>s1</i>, QStringRef <i>s2</i>)</li></ul><h3>Special Methods</h3><ul><li><div class="fn" />bool <b><a href="qstringref.html#__eq__">__eq__</a></b> (<i>self</i>, QStringRef <i>s2</i>)</li><li><div class="fn" />bool <b><a href="qstringref.html#__eq__-2">__eq__</a></b> (<i>self</i>, QString <i>s2</i>)</li><li><div class="fn" />bool <b><a href="qstringref.html#__eq__-3">__eq__</a></b> (<i>self</i>, QLatin1String <i>s2</i>)</li><li><div class="fn" />bool <b><a href="qstringref.html#__ge__">__ge__</a></b> (<i>self</i>, QStringRef <i>s2</i>)</li><li><div class="fn" />bool <b><a href="qstringref.html#__gt__">__gt__</a></b> (<i>self</i>, QStringRef <i>s2</i>)</li><li><div class="fn" />bool <b><a href="qstringref.html#__le__">__le__</a></b> (<i>self</i>, QStringRef <i>s2</i>)</li><li><div class="fn" /> <b><a href="qstringref.html#__len__">__len__</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qstringref.html#__lt__">__lt__</a></b> (<i>self</i>, QStringRef <i>s2</i>)</li><li><div class="fn" />bool <b><a href="qstringref.html#__ne__">__ne__</a></b> (<i>self</i>, QStringRef <i>s2</i>)</li><li><div class="fn" />bool <b><a href="qstringref.html#__ne__-2">__ne__</a></b> (<i>self</i>, QString <i>s2</i>)</li><li><div class="fn" />bool <b><a href="qstringref.html#__ne__-3">__ne__</a></b> (<i>self</i>, QLatin1String <i>s2</i>)</li><li><div class="fn" />str <b><a href="qstringref.html#__str__">__str__</a></b> (<i>self</i>)</li><li><div class="fn" />unicode <b><a href="qstringref.html#__unicode__">__unicode__</a></b> (<i>self</i>)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QStringRef class provides a thin wrapper around <a href="qstring.html">QString</a> substrings.</p> <p>QStringRef provides a read-only subset of the <a href="qstring.html">QString</a> API.</p> <p>A string reference explicitly references a portion of a <a href="qstringref.html#string">string</a>() with a given <a href="qstringref.html#size">size</a>(), starting at a specific <a href="qstringref.html#position">position</a>(). Calling <a href="qstringref.html#toString">toString</a>() returns a copy of the data as a real <a href="qstring.html">QString</a> instance.</p> <p>This class is designed to improve the performance of substring handling when manipulating substrings obtained from existing <a href="qstring.html">QString</a> instances. QStringRef avoids the memory allocation and reference counting overhead of a standard <a href="qstring.html">QString</a> by simply referencing a part of the original string. This can prove to be advantageous in low level code, such as that used in a parser, at the expense of potentially more complex code.</p> <p>For most users, there are no semantic benefits to using QStringRef instead of <a href="qstring.html">QString</a> since QStringRef requires attention to be paid to memory management issues, potentially making code more complex to write and maintain.</p> <p><b>Warning:</b> A QStringRef is only valid as long as the referenced string exists. If the original string is deleted, the string reference points to an invalid memory location.</p> <p>We suggest that you only use this class in stable code where profiling has clearly identified that performance improvements can be made by replacing standard string operations with the optimized substring handling provided by this class.</p> <hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QStringRef" />QStringRef.__init__ (<i>self</i>)</h3><p>Constructs an empty string reference.</p> <h3 class="fn"><a name="QStringRef-2" />QStringRef.__init__ (<i>self</i>, QString <i>aString</i>, int <i>aPosition</i>, int <i>aSize</i>)</h3><p>Constructs a string reference to the range of characters in the given <i>string</i> specified by the starting <i>position</i> and <i>length</i> in characters.</p> <p><b>Warning:</b> This function exists to improve performance as much as possible, and performs no bounds checking. For program correctness, <i>position</i> and <i>length</i> must describe a valid substring of <i>string</i>.</p> <p>This means that the starting <i>position</i> must be positive or 0 and smaller than <i>string</i>'s length, and <i>length</i> must be positive or 0 but smaller than the string's length minus the starting <i>position</i>; i.e, 0 <= position < string-><a href="qstringref.html#length">length</a>() and 0 <= length <= string-><a href="qstringref.html#length">length</a>() - position must both be satisfied.</p> <h3 class="fn"><a name="QStringRef-3" />QStringRef.__init__ (<i>self</i>, QString <i>aString</i>)</h3><p>Constructs a string reference to the given <i>string</i>.</p> <h3 class="fn"><a name="QStringRef-4" />QStringRef.__init__ (<i>self</i>, QStringRef <i>other</i>)</h3><p>Constructs a copy of the <i>other</i> string reference.</p> <h3 class="fn"><a name="appendTo" />QStringRef QStringRef.appendTo (<i>self</i>, QString <i>string</i>)</h3><p>Appends the string reference to <i>string</i>, and returns a new reference to the combined string data.</p> <h3 class="fn"><a name="at" />QChar QStringRef.at (<i>self</i>, int <i>i</i>)</h3><p>Returns the character at the given index <i>position</i> in the string reference.</p> <p>The <i>position</i> must be a valid index position in the string (i.e., 0 <= <i>position</i> < <a href="qstringref.html#size">size</a>()).</p> <h3 class="fn"><a name="clear" />QStringRef.clear (<i>self</i>)</h3><p>Clears the contents of the string reference by making it null and empty.</p> <p><b>See also</b> <a href="qstringref.html#isEmpty">isEmpty</a>() and <a href="qstringref.html#isNull">isNull</a>().</p> <h3 class="fn"><a name="compare" />int QStringRef.compare (<i>self</i>, QString <i>other</i>, <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitivity</a> <i>cs</i> = Qt.CaseSensitive)</h3><p>Compares the string <i>s1</i> with the string <i>s2</i> and returns an integer less than, equal to, or greater than zero if <i>s1</i> is less than, equal to, or greater than <i>s2</i>.</p> <p>If <i>cs</i> is <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitive</a>, the comparison is case sensitive; otherwise the comparison is case insensitive.</p> <p>This function was introduced in Qt 4.5.</p> <h3 class="fn"><a name="compare-2" />int QStringRef.compare (<i>self</i>, QStringRef <i>other</i>, <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitivity</a> <i>cs</i> = Qt.CaseSensitive)</h3><p>This is an overloaded function.</p> <p>Compares the string <i>s1</i> with the string <i>s2</i> and returns an integer less than, equal to, or greater than zero if <i>s1</i> is less than, equal to, or greater than <i>s2</i>.</p> <p>If <i>cs</i> is <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitive</a>, the comparison is case sensitive; otherwise the comparison is case insensitive.</p> <p>This function was introduced in Qt 4.5.</p> <h3 class="fn"><a name="compare-3" />int QStringRef.compare (<i>self</i>, <a href="qlatin1string.html">QLatin1String</a> <i>other</i>, <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitivity</a> <i>cs</i> = Qt.CaseSensitive)</h3><p>This is an overloaded function.</p> <p>Compares the string <i>s1</i> with the string <i>s2</i> and returns an integer less than, equal to, or greater than zero if <i>s1</i> is less than, equal to, or greater than <i>s2</i>.</p> <p>If <i>cs</i> is <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitive</a>, the comparison is case sensitive; otherwise the comparison is case insensitive.</p> <p>This function was introduced in Qt 4.5.</p> <h3 class="fn"><a name="compare-4" />int QStringRef.compare (QStringRef <i>s1</i>, QString <i>s2</i>, <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitivity</a> <i>cs</i> = Qt.CaseSensitive)</h3><p>This is an overloaded function.</p> <p>Compares this string with the <i>other</i> string and returns an integer less than, equal to, or greater than zero if this string is less than, equal to, or greater than the <i>other</i> string.</p> <p>If <i>cs</i> is <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitive</a>, the comparison is case sensitive; otherwise the comparison is case insensitive.</p> <p>Equivalent to <tt>compare(*this, other, cs)</tt>.</p> <p>This function was introduced in Qt 4.5.</p> <p><b>See also</b> <a href="qstring.html#compare">QString.compare</a>().</p> <h3 class="fn"><a name="compare-5" />int QStringRef.compare (QStringRef <i>s1</i>, QStringRef <i>s2</i>, <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitivity</a> <i>cs</i> = Qt.CaseSensitive)</h3><p>This is an overloaded function.</p> <p>Compares this string with the <i>other</i> string and returns an integer less than, equal to, or greater than zero if this string is less than, equal to, or greater than the <i>other</i> string.</p> <p>If <i>cs</i> is <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitive</a>, the comparison is case sensitive; otherwise the comparison is case insensitive.</p> <p>Equivalent to <tt>compare(*this, other, cs)</tt>.</p> <p>This function was introduced in Qt 4.5.</p> <p><b>See also</b> <a href="qstring.html#compare">QString.compare</a>().</p> <h3 class="fn"><a name="compare-6" />int QStringRef.compare (QStringRef <i>s1</i>, <a href="qlatin1string.html">QLatin1String</a> <i>s2</i>, <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitivity</a> <i>cs</i> = Qt.CaseSensitive)</h3><p>This is an overloaded function.</p> <p>Compares this string with the <i>other</i> string and returns an integer less than, equal to, or greater than zero if this string is less than, equal to, or greater than the <i>other</i> string.</p> <p>If <i>cs</i> is <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitive</a>, the comparison is case sensitive; otherwise the comparison is case insensitive.</p> <p>Equivalent to <tt>compare(*this, other, cs)</tt>.</p> <p>This function was introduced in Qt 4.5.</p> <p><b>See also</b> <a href="qstring.html#compare">QString.compare</a>().</p> <h3 class="fn"><a name="constData" />QChar QStringRef.constData (<i>self</i>)</h3><p>Same as <a href="qstringref.html#unicode">unicode</a>().</p> <h3 class="fn"><a name="contains" />bool QStringRef.contains (<i>self</i>, QString <i>str</i>, <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitivity</a> <i>cs</i> = Qt.CaseSensitive)</h3><p>Returns true if this string reference contains an occurrence of the string <i>str</i>; otherwise returns false.</p> <p>If <i>cs</i> is <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitive</a> (default), the search is case sensitive; otherwise the search is case insensitive.</p> <p>This function was introduced in Qt 4.8.</p> <p><b>See also</b> <a href="qstringref.html#indexOf">indexOf</a>() and <a href="qstringref.html#count">count</a>().</p> <h3 class="fn"><a name="contains-2" />bool QStringRef.contains (<i>self</i>, <a href="qlatin1string.html">QLatin1String</a> <i>str</i>, <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitivity</a> <i>cs</i> = Qt.CaseSensitive)</h3><p>This function overloads <a href="qstringref.html#contains">contains</a>().</p> <p>Returns true if this string contains an occurrence of the character <i>ch</i>; otherwise returns false.</p> <p>If <i>cs</i> is <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitive</a> (default), the search is case sensitive; otherwise the search is case insensitive.</p> <p>This function was introduced in Qt 4.8.</p> <h3 class="fn"><a name="contains-3" />bool QStringRef.contains (<i>self</i>, QStringRef <i>str</i>, <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitivity</a> <i>cs</i> = Qt.CaseSensitive)</h3><p>This function overloads <a href="qstringref.html#contains">contains</a>().</p> <p>Returns true if this string reference contains an occurrence of the string reference <i>str</i>; otherwise returns false.</p> <p>If <i>cs</i> is <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitive</a> (default), the search is case sensitive; otherwise the search is case insensitive.</p> <p>This function was introduced in Qt 4.8.</p> <p><b>See also</b> <a href="qstringref.html#indexOf">indexOf</a>() and <a href="qstringref.html#count">count</a>().</p> <h3 class="fn"><a name="count" />int QStringRef.count (<i>self</i>)</h3><p>Returns the number of characters referred to by the string reference. Equivalent to <a href="qstringref.html#size">size</a>() and <a href="qstringref.html#length">length</a>().</p> <p><b>See also</b> <a href="qstringref.html#position">position</a>() and <a href="qstringref.html#string">string</a>().</p> <h3 class="fn"><a name="count-2" />int QStringRef.count (<i>self</i>, QString <i>str</i>, <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitivity</a> <i>cs</i> = Qt.CaseSensitive)</h3><p>Returns the number of (potentially overlapping) occurrences of the string <i>str</i> in this string reference.</p> <p>If <i>cs</i> is <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitive</a> (default), the search is case sensitive; otherwise the search is case insensitive.</p> <p>This function was introduced in Qt 4.8.</p> <p><b>See also</b> <a href="qstring.html#count">QString.count</a>(), <a href="qstringref.html#contains">contains</a>(), and <a href="qstringref.html#indexOf">indexOf</a>().</p> <h3 class="fn"><a name="count-3" />int QStringRef.count (<i>self</i>, QStringRef <i>str</i>, <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitivity</a> <i>cs</i> = Qt.CaseSensitive)</h3><p>This function overloads <a href="qstringref.html#count">count</a>().</p> <p>Returns the number of occurrences of the character <i>ch</i> in the string reference.</p> <p>If <i>cs</i> is <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitive</a> (default), the search is case sensitive; otherwise the search is case insensitive.</p> <p>This function was introduced in Qt 4.8.</p> <p><b>See also</b> <a href="qstring.html#count">QString.count</a>(), <a href="qstringref.html#contains">contains</a>(), and <a href="qstringref.html#indexOf">indexOf</a>().</p> <h3 class="fn"><a name="data" />QChar QStringRef.data (<i>self</i>)</h3><p>Same as <a href="qstringref.html#unicode">unicode</a>().</p> <h3 class="fn"><a name="endsWith" />bool QStringRef.endsWith (<i>self</i>, QString <i>str</i>, <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitivity</a> <i>cs</i> = Qt.CaseSensitive)</h3><p>Returns true if the string reference ends with <i>str</i>; otherwise returns false.</p> <p>If <i>cs</i> is <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitive</a> (default), the search is case sensitive; otherwise the search is case insensitive.</p> <p>This function was introduced in Qt 4.8.</p> <p><b>See also</b> <a href="qstring.html#endsWith">QString.endsWith</a>() and <a href="qstringref.html#startsWith">startsWith</a>().</p> <h3 class="fn"><a name="endsWith-2" />bool QStringRef.endsWith (<i>self</i>, <a href="qlatin1string.html">QLatin1String</a> <i>str</i>, <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitivity</a> <i>cs</i> = Qt.CaseSensitive)</h3><p>This function overloads <a href="qstringref.html#endsWith">endsWith</a>().</p> <p>Returns true if the string reference ends with <i>ch</i>; otherwise returns false.</p> <p>If <i>cs</i> is <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitive</a> (default), the search is case sensitive; otherwise the search is case insensitive.</p> <p>This function was introduced in Qt 4.8.</p> <p><b>See also</b> <a href="qstring.html#endsWith">QString.endsWith</a>() and <a href="qstringref.html#endsWith">endsWith</a>().</p> <h3 class="fn"><a name="endsWith-3" />bool QStringRef.endsWith (<i>self</i>, QStringRef <i>str</i>, <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitivity</a> <i>cs</i> = Qt.CaseSensitive)</h3><p>This function overloads <a href="qstringref.html#endsWith">endsWith</a>().</p> <p>This function was introduced in Qt 4.8.</p> <p><b>See also</b> <a href="qstring.html#endsWith">QString.endsWith</a>() and <a href="qstringref.html#endsWith">endsWith</a>().</p> <h3 class="fn"><a name="indexOf" />int QStringRef.indexOf (<i>self</i>, QString <i>str</i>, int <i>from</i> = 0, <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitivity</a> <i>cs</i> = Qt.CaseSensitive)</h3><p>Returns the index position of the first occurrence of the string <i>str</i> in this string reference, searching forward from index position <i>from</i>. Returns -1 if <i>str</i> is not found.</p> <p>If <i>cs</i> is <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitive</a> (default), the search is case sensitive; otherwise the search is case insensitive.</p> <p>If <i>from</i> is -1, the search starts at the last character; if it is -2, at the next to last character and so on.</p> <p>This function was introduced in Qt 4.8.</p> <p><b>See also</b> <a href="qstring.html#indexOf">QString.indexOf</a>(), <a href="qstringref.html#lastIndexOf">lastIndexOf</a>(), <a href="qstringref.html#contains">contains</a>(), and <a href="qstringref.html#count">count</a>().</p> <h3 class="fn"><a name="indexOf-2" />int QStringRef.indexOf (<i>self</i>, <a href="qlatin1string.html">QLatin1String</a> <i>str</i>, int <i>from</i> = 0, <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitivity</a> <i>cs</i> = Qt.CaseSensitive)</h3><p>Returns the index position of the first occurrence of the string <i>str</i> in this string reference, searching forward from index position <i>from</i>. Returns -1 if <i>str</i> is not found.</p> <p>If <i>cs</i> is <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitive</a> (default), the search is case sensitive; otherwise the search is case insensitive.</p> <p>If <i>from</i> is -1, the search starts at the last character; if it is -2, at the next to last character and so on.</p> <p>This function was introduced in Qt 4.8.</p> <p><b>See also</b> <a href="qstring.html#indexOf">QString.indexOf</a>(), <a href="qstringref.html#lastIndexOf">lastIndexOf</a>(), <a href="qstringref.html#contains">contains</a>(), and <a href="qstringref.html#count">count</a>().</p> <h3 class="fn"><a name="indexOf-3" />int QStringRef.indexOf (<i>self</i>, QStringRef <i>str</i>, int <i>from</i> = 0, <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitivity</a> <i>cs</i> = Qt.CaseSensitive)</h3><p>This function overloads <a href="qstringref.html#indexOf">indexOf</a>().</p> <p>Returns the index position of the first occurrence of the character <i>ch</i> in the string reference, searching forward from index position <i>from</i>. Returns -1 if <i>ch</i> could not be found.</p> <p>This function was introduced in Qt 4.8.</p> <p><b>See also</b> <a href="qstring.html#indexOf">QString.indexOf</a>(), <a href="qstringref.html#lastIndexOf">lastIndexOf</a>(), <a href="qstringref.html#contains">contains</a>(), and <a href="qstringref.html#count">count</a>().</p> <h3 class="fn"><a name="isEmpty" />bool QStringRef.isEmpty (<i>self</i>)</h3><p>Returns true if the string reference has no characters; otherwise returns false.</p> <p>A string reference is empty if its size is zero.</p> <p><b>See also</b> <a href="qstringref.html#size">size</a>().</p> <h3 class="fn"><a name="isNull" />bool QStringRef.isNull (<i>self</i>)</h3><p>Returns true if <a href="qstringref.html#string">string</a>() returns a null pointer or a pointer to a null string; otherwise returns true.</p> <p><b>See also</b> <a href="qstringref.html#size">size</a>().</p> <h3 class="fn"><a name="lastIndexOf" />int QStringRef.lastIndexOf (<i>self</i>, QString <i>str</i>, int <i>from</i> = -1, <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitivity</a> <i>cs</i> = Qt.CaseSensitive)</h3><p>Returns the index position of the last occurrence of the string <i>str</i> in this string reference, searching backward from index position <i>from</i>. If <i>from</i> is -1 (default), the search starts at the last character; if <i>from</i> is -2, at the next to last character and so on. Returns -1 if <i>str</i> is not found.</p> <p>If <i>cs</i> is <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitive</a> (default), the search is case sensitive; otherwise the search is case insensitive.</p> <p>This function was introduced in Qt 4.8.</p> <p><b>See also</b> <a href="qstring.html#lastIndexOf">QString.lastIndexOf</a>(), <a href="qstringref.html#indexOf">indexOf</a>(), <a href="qstringref.html#contains">contains</a>(), and <a href="qstringref.html#count">count</a>().</p> <h3 class="fn"><a name="lastIndexOf-2" />int QStringRef.lastIndexOf (<i>self</i>, <a href="qlatin1string.html">QLatin1String</a> <i>str</i>, int <i>from</i> = -1, <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitivity</a> <i>cs</i> = Qt.CaseSensitive)</h3><p>This function overloads <a href="qstringref.html#lastIndexOf">lastIndexOf</a>().</p> <p>Returns the index position of the last occurrence of the character <i>ch</i>, searching backward from position <i>from</i>.</p> <p>This function was introduced in Qt 4.8.</p> <p><b>See also</b> <a href="qstring.html#lastIndexOf">QString.lastIndexOf</a>(), <a href="qstringref.html#indexOf">indexOf</a>(), <a href="qstringref.html#contains">contains</a>(), and <a href="qstringref.html#count">count</a>().</p> <h3 class="fn"><a name="lastIndexOf-3" />int QStringRef.lastIndexOf (<i>self</i>, QStringRef <i>str</i>, int <i>from</i> = -1, <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitivity</a> <i>cs</i> = Qt.CaseSensitive)</h3><p>This function overloads <a href="qstringref.html#lastIndexOf">lastIndexOf</a>().</p> <p>Returns the index position of the last occurrence of the string <i>str</i> in this string reference, searching backward from index position <i>from</i>. If <i>from</i> is -1 (default), the search starts at the last character; if <i>from</i> is -2, at the next to last character and so on. Returns -1 if <i>str</i> is not found.</p> <p>If <i>cs</i> is <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitive</a> (default), the search is case sensitive; otherwise the search is case insensitive.</p> <p>This function was introduced in Qt 4.8.</p> <p><b>See also</b> <a href="qstring.html#lastIndexOf">QString.lastIndexOf</a>(), <a href="qstringref.html#indexOf">indexOf</a>(), <a href="qstringref.html#contains">contains</a>(), and <a href="qstringref.html#count">count</a>().</p> <h3 class="fn"><a name="length" />int QStringRef.length (<i>self</i>)</h3><p>Returns the number of characters referred to by the string reference. Equivalent to <a href="qstringref.html#size">size</a>() and <a href="qstringref.html#count">count</a>().</p> <p><b>See also</b> <a href="qstringref.html#position">position</a>() and <a href="qstringref.html#string">string</a>().</p> <h3 class="fn"><a name="localeAwareCompare" />int QStringRef.localeAwareCompare (<i>self</i>, QString <i>s</i>)</h3><p>Compares <i>s1</i> with <i>s2</i> and returns an integer less than, equal to, or greater than zero if <i>s1</i> is less than, equal to, or greater than <i>s2</i>.</p> <p>The comparison is performed in a locale- and also platform-dependent manner. Use this function to present sorted lists of strings to the user.</p> <p>On Mac OS X, this function compares according the "Order for sorted lists" setting in the International prefereces panel.</p> <p>This function was introduced in Qt 4.5.</p> <p><b>See also</b> <a href="qstringref.html#compare">compare</a>() and <a class="compat" href="qtextcodec-qt3.html#locale">QTextCodec.locale</a>().</p> <h3 class="fn"><a name="localeAwareCompare-2" />int QStringRef.localeAwareCompare (<i>self</i>, QStringRef <i>s</i>)</h3><p>This is an overloaded function.</p> <p>Compares <i>s1</i> with <i>s2</i> and returns an integer less than, equal to, or greater than zero if <i>s1</i> is less than, equal to, or greater than <i>s2</i>.</p> <p>The comparison is performed in a locale- and also platform-dependent manner. Use this function to present sorted lists of strings to the user.</p> <p>This function was introduced in Qt 4.5.</p> <h3 class="fn"><a name="localeAwareCompare-3" />int QStringRef.localeAwareCompare (QStringRef <i>s1</i>, QString <i>s2</i>)</h3><p>This is an overloaded function.</p> <p>Compares this string with the <i>other</i> string and returns an integer less than, equal to, or greater than zero if this string is less than, equal to, or greater than the <i>other</i> string.</p> <p>The comparison is performed in a locale- and also platform-dependent manner. Use this function to present sorted lists of strings to the user.</p> <p>This function was introduced in Qt 4.5.</p> <h3 class="fn"><a name="localeAwareCompare-4" />int QStringRef.localeAwareCompare (QStringRef <i>s1</i>, QStringRef <i>s2</i>)</h3><p>This is an overloaded function.</p> <p>Compares this string with the <i>other</i> string and returns an integer less than, equal to, or greater than zero if this string is less than, equal to, or greater than the <i>other</i> string.</p> <p>The comparison is performed in a locale- and also platform-dependent manner. Use this function to present sorted lists of strings to the user.</p> <p>This function was introduced in Qt 4.5.</p> <h3 class="fn"><a name="position" />int QStringRef.position (<i>self</i>)</h3><p>Returns the starting position in the referenced string that is referred to by the string reference.</p> <p><b>See also</b> <a href="qstringref.html#size">size</a>() and <a href="qstringref.html#string">string</a>().</p> <h3 class="fn"><a name="size" />int QStringRef.size (<i>self</i>)</h3><p>Returns the number of characters referred to by the string reference. Equivalent to <a href="qstringref.html#length">length</a>() and <a href="qstringref.html#count">count</a>().</p> <p><b>See also</b> <a href="qstringref.html#position">position</a>() and <a href="qstringref.html#string">string</a>().</p> <h3 class="fn"><a name="startsWith" />bool QStringRef.startsWith (<i>self</i>, QString <i>str</i>, <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitivity</a> <i>cs</i> = Qt.CaseSensitive)</h3><p>Returns true if the string reference starts with <i>str</i>; otherwise returns false.</p> <p>If <i>cs</i> is <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitive</a> (default), the search is case sensitive; otherwise the search is case insensitive.</p> <p>This function was introduced in Qt 4.8.</p> <p><b>See also</b> <a href="qstring.html#startsWith">QString.startsWith</a>() and <a href="qstringref.html#endsWith">endsWith</a>().</p> <h3 class="fn"><a name="startsWith-2" />bool QStringRef.startsWith (<i>self</i>, <a href="qlatin1string.html">QLatin1String</a> <i>str</i>, <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitivity</a> <i>cs</i> = Qt.CaseSensitive)</h3><p>This function overloads <a href="qstringref.html#startsWith">startsWith</a>().</p> <p>This function was introduced in Qt 4.8.</p> <p><b>See also</b> <a href="qstring.html#startsWith">QString.startsWith</a>() and <a href="qstringref.html#endsWith">endsWith</a>().</p> <h3 class="fn"><a name="startsWith-3" />bool QStringRef.startsWith (<i>self</i>, QStringRef <i>str</i>, <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitivity</a> <i>cs</i> = Qt.CaseSensitive)</h3><p>This function overloads <a href="qstringref.html#startsWith">startsWith</a>().</p> <p>This function was introduced in Qt 4.8.</p> <p><b>See also</b> <a href="qstring.html#startsWith">QString.startsWith</a>() and <a href="qstringref.html#endsWith">endsWith</a>().</p> <h3 class="fn"><a name="string" />QString QStringRef.string (<i>self</i>)</h3><p>Returns a pointer to the string referred to by the string reference, or 0 if it does not reference a string.</p> <p><b>See also</b> <a href="qstringref.html#unicode">unicode</a>().</p> <h3 class="fn"><a name="toAscii" /><a href="qbytearray.html">QByteArray</a> QStringRef.toAscii (<i>self</i>)</h3><p>Returns an 8-bit representation of the string as a <a href="qbytearray.html">QByteArray</a>.</p> <p>If a codec has been set using <a href="qtextcodec.html#setCodecForCStrings">QTextCodec.setCodecForCStrings</a>(), it is used to convert Unicode to 8-bit char; otherwise this function does the same as <a href="qstringref.html#toLatin1">toLatin1</a>().</p> <p>Note that, despite the name, this function does not necessarily return an US-ASCII (ANSI X3.4-1986) string and its result may not be US-ASCII compatible.</p> <p>This function was introduced in Qt 4.8.</p> <p><b>See also</b> <a href="qstringref.html#toLatin1">toLatin1</a>(), <a href="qstringref.html#toUtf8">toUtf8</a>(), <a href="qstringref.html#toLocal8Bit">toLocal8Bit</a>(), and <a href="qtextcodec.html">QTextCodec</a>.</p> <h3 class="fn"><a name="toLatin1" /><a href="qbytearray.html">QByteArray</a> QStringRef.toLatin1 (<i>self</i>)</h3><p>Returns a Latin-1 representation of the string as a <a href="qbytearray.html">QByteArray</a>.</p> <p>The returned byte array is undefined if the string contains non-Latin1 characters. Those characters may be suppressed or replaced with a question mark.</p> <p>This function was introduced in Qt 4.8.</p> <p><b>See also</b> <a href="qstringref.html#toAscii">toAscii</a>(), <a href="qstringref.html#toUtf8">toUtf8</a>(), <a href="qstringref.html#toLocal8Bit">toLocal8Bit</a>(), and <a href="qtextcodec.html">QTextCodec</a>.</p> <h3 class="fn"><a name="toLocal8Bit" /><a href="qbytearray.html">QByteArray</a> QStringRef.toLocal8Bit (<i>self</i>)</h3><p>Returns the local 8-bit representation of the string as a <a href="qbytearray.html">QByteArray</a>. The returned byte array is undefined if the string contains characters not supported by the local 8-bit encoding.</p> <p><a href="qtextcodec.html#codecForLocale">QTextCodec.codecForLocale</a>() is used to perform the conversion from Unicode. If the locale encoding could not be determined, this function does the same as <a href="qstringref.html#toLatin1">toLatin1</a>().</p> <p>If this string contains any characters that cannot be encoded in the locale, the returned byte array is undefined. Those characters may be suppressed or replaced by another.</p> <p>This function was introduced in Qt 4.8.</p> <p><b>See also</b> <a href="qstringref.html#toAscii">toAscii</a>(), <a href="qstringref.html#toLatin1">toLatin1</a>(), <a href="qstringref.html#toUtf8">toUtf8</a>(), and <a href="qtextcodec.html">QTextCodec</a>.</p> <h3 class="fn"><a name="toString" />QString QStringRef.toString (<i>self</i>)</h3><p>Returns a copy of the string reference as a <a href="qstring.html">QString</a> object.</p> <p>If the string reference is not a complete reference of the string (meaning that <a href="qstringref.html#position">position</a>() is 0 and <a href="qstringref.html#size">size</a>() equals <a href="qstringref.html#string">string</a>()-><a href="qstringref.html#size">size</a>()), this function will allocate a new string to return.</p> <p><b>See also</b> <a href="qstringref.html#string">string</a>().</p> <h3 class="fn"><a name="toUcs4" />list-of-int QStringRef.toUcs4 (<i>self</i>)</h3><p>Returns a UCS-4/UTF-32 representation of the string as a <a href="qvector.html">QVector</a><uint>.</p> <p>UCS-4 is a Unicode codec and is lossless. All characters from this string can be encoded in UCS-4.</p> <p>This function was introduced in Qt 4.8.</p> <p><b>See also</b> <a href="qstringref.html#toAscii">toAscii</a>(), <a href="qstringref.html#toLatin1">toLatin1</a>(), <a href="qstringref.html#toLocal8Bit">toLocal8Bit</a>(), and <a href="qtextcodec.html">QTextCodec</a>.</p> <h3 class="fn"><a name="toUtf8" /><a href="qbytearray.html">QByteArray</a> QStringRef.toUtf8 (<i>self</i>)</h3><p>Returns a UTF-8 representation of the string as a <a href="qbytearray.html">QByteArray</a>.</p> <p>UTF-8 is a Unicode codec and can represent all characters in a Unicode string like <a href="qstring.html">QString</a>.</p> <p>However, in the Unicode range, there are certain codepoints that are not considered characters. The Unicode standard reserves the last two codepoints in each Unicode Plane (U+FFFE, U+FFFF, U+1FFFE, U+1FFFF, U+2FFFE, etc.), as well as 16 codepoints in the range U+FDD0..U+FDDF, inclusive, as non-characters. If any of those appear in the string, they may be discarded and will not appear in the UTF-8 representation, or they may be replaced by one or more replacement characters.</p> <p>This function was introduced in Qt 4.8.</p> <p><b>See also</b> <a href="qstringref.html#toAscii">toAscii</a>(), <a href="qstringref.html#toLatin1">toLatin1</a>(), <a href="qstringref.html#toLocal8Bit">toLocal8Bit</a>(), and <a href="qtextcodec.html">QTextCodec</a>.</p> <h3 class="fn"><a name="unicode" />QChar QStringRef.unicode (<i>self</i>)</h3><p>Returns a Unicode representation of the string reference. Since the data stems directly from the referenced string, it is not null-terminated unless the string reference includes the string's null terminator.</p> <p><b>See also</b> <a href="qstringref.html#string">string</a>().</p> <h3 class="fn"><a name="__eq__" />bool QStringRef.__eq__ (<i>self</i>, QStringRef <i>s2</i>)</h3><h3 class="fn"><a name="__eq__-2" />bool QStringRef.__eq__ (<i>self</i>, QString <i>s2</i>)</h3><h3 class="fn"><a name="__eq__-3" />bool QStringRef.__eq__ (<i>self</i>, <a href="qlatin1string.html">QLatin1String</a> <i>s2</i>)</h3><h3 class="fn"><a name="__ge__" />bool QStringRef.__ge__ (<i>self</i>, QStringRef <i>s2</i>)</h3><h3 class="fn"><a name="__gt__" />bool QStringRef.__gt__ (<i>self</i>, QStringRef <i>s2</i>)</h3><h3 class="fn"><a name="__le__" />bool QStringRef.__le__ (<i>self</i>, QStringRef <i>s2</i>)</h3><h3 class="fn"><a name="__len__" /> QStringRef.__len__ (<i>self</i>)</h3><h3 class="fn"><a name="__lt__" />bool QStringRef.__lt__ (<i>self</i>, QStringRef <i>s2</i>)</h3><h3 class="fn"><a name="__ne__" />bool QStringRef.__ne__ (<i>self</i>, QStringRef <i>s2</i>)</h3><h3 class="fn"><a name="__ne__-2" />bool QStringRef.__ne__ (<i>self</i>, QString <i>s2</i>)</h3><h3 class="fn"><a name="__ne__-3" />bool QStringRef.__ne__ (<i>self</i>, <a href="qlatin1string.html">QLatin1String</a> <i>s2</i>)</h3><h3 class="fn"><a name="__str__" />str QStringRef.__str__ (<i>self</i>)</h3><h3 class="fn"><a name="__unicode__" />unicode QStringRef.__unicode__ (<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>