Sophie

Sophie

distrib > Fedora > 14 > x86_64 > by-pkgid > 3f684444755c5ad1181cdd5a97348f3c > files > 1491

PyQt4-devel-4.7.4-2.fc14.i686.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>QString Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
td.postheader { font-family: sans-serif }
tr.address { font-family: sans-serif }
body { background: #ffffff; color: black; }
</style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">&#160;&#160;</td><td class="postheader" valign="center"><a href="../pyqt4ref.html"><font color="#004faf">Home</font></a>&#160;&#183; <a href="classes.html"><font color="#004faf">All Classes</font></a>&#160;&#183; <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QString Class Reference<br /><sup><sup>[<a href="qtcore.html">QtCore</a> module]</sup></sup></h1><p>The QString class provides a Unicode character string. <a href="#details">More...</a></p>
<h3>Types</h3><ul><li><div class="fn" />enum <b><a href="qstring.html#NormalizationForm-enum">NormalizationForm</a></b> { NormalizationForm_D, NormalizationForm_C, NormalizationForm_KD, NormalizationForm_KC }</li><li><div class="fn" />enum <b><a href="qstring.html#SectionFlag-enum">SectionFlag</a></b> { SectionDefault, SectionSkipEmpty, SectionIncludeLeadingSep, SectionIncludeTrailingSep, SectionCaseInsensitiveSeps }</li><li><div class="fn" />class <b><a href="qstring-sectionflags.html">SectionFlags</a></b></li><li><div class="fn" />enum <b><a href="qstring.html#SplitBehavior-enum">SplitBehavior</a></b> { KeepEmptyParts, SkipEmptyParts }</li></ul><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qstring.html#QString">__init__</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qstring.html#QString">__init__</a></b> (<i>self</i>, QKeySequence)</li><li><div class="fn" /><b><a href="qstring.html#QString">__init__</a></b> (<i>self</i>, QScriptString)</li><li><div class="fn" /><b><a href="qstring.html#QString-2">__init__</a></b> (<i>self</i>, int, QChar)</li><li><div class="fn" /><b><a href="qstring.html#QString-3">__init__</a></b> (<i>self</i>, QString)</li><li><div class="fn" /><b><a href="qstring.html#QString-4">__init__</a></b> (<i>self</i>, QByteArray)</li><li><div class="fn" /><b><a href="qstring.html#QString-5">__init__</a></b> (<i>self</i>, QUuid)</li><li><div class="fn" />QString <b><a href="qstring.html#append">append</a></b> (<i>self</i>, QString)</li><li><div class="fn" />QString <b><a href="qstring.html#append-2">append</a></b> (<i>self</i>, QLatin1String)</li><li><div class="fn" />QString <b><a href="qstring.html#append-3">append</a></b> (<i>self</i>, QByteArray)</li><li><div class="fn" />QString <b><a href="qstring.html#arg">arg</a></b> (<i>self</i>, int, int&#160;<i>fieldWidth</i>&#160;=&#160;0, int&#160;<i>base</i>&#160;=&#160;10, QChar&#160;<i>fillChar</i>&#160;=&#160;QLatin1Char(' '))</li><li><div class="fn" />QString <b><a href="qstring.html#arg-2">arg</a></b> (<i>self</i>, float, int&#160;<i>fieldWidth</i>&#160;=&#160;0, str&#160;<i>format</i>&#160;=&#160;'g', int&#160;<i>precision</i>&#160;=&#160;-1, QChar&#160;<i>fillChar</i>&#160;=&#160;QLatin1Char(' '))</li><li><div class="fn" />QString <b><a href="qstring.html#arg-3">arg</a></b> (<i>self</i>, int, int&#160;<i>fieldWidth</i>&#160;=&#160;0, int&#160;<i>base</i>&#160;=&#160;10, QChar&#160;<i>fillChar</i>&#160;=&#160;QLatin1Char(' '))</li><li><div class="fn" />QString <b><a href="qstring.html#arg-4">arg</a></b> (<i>self</i>, int, int&#160;<i>fieldWidth</i>&#160;=&#160;0, int&#160;<i>base</i>&#160;=&#160;10, QChar&#160;<i>fillChar</i>&#160;=&#160;QLatin1Char(' '))</li><li><div class="fn" />QString <b><a href="qstring.html#arg-5">arg</a></b> (<i>self</i>, QString, int&#160;<i>fieldWidth</i>&#160;=&#160;0, QChar&#160;<i>fillChar</i>&#160;=&#160;QLatin1Char(' '))</li><li><div class="fn" />QString <b><a href="qstring.html#arg-6">arg</a></b> (<i>self</i>, QString, QString)</li><li><div class="fn" />QString <b><a href="qstring.html#arg-7">arg</a></b> (<i>self</i>, QString, QString, QString)</li><li><div class="fn" />QString <b><a href="qstring.html#arg-8">arg</a></b> (<i>self</i>, QString, QString, QString, QString)</li><li><div class="fn" />QString <b><a href="qstring.html#arg-9">arg</a></b> (<i>self</i>, QString, QString, QString, QString, QString)</li><li><div class="fn" />QString <b><a href="qstring.html#arg-10">arg</a></b> (<i>self</i>, QString, QString, QString, QString, QString, QString)</li><li><div class="fn" />QString <b><a href="qstring.html#arg-11">arg</a></b> (<i>self</i>, QString, QString, QString, QString, QString, QString, QString)</li><li><div class="fn" />QString <b><a href="qstring.html#arg-12">arg</a></b> (<i>self</i>, QString, QString, QString, QString, QString, QString, QString, QString)</li><li><div class="fn" />QString <b><a href="qstring.html#arg-13">arg</a></b> (<i>self</i>, QString, QString, QString, QString, QString, QString, QString, QString, QString)</li><li><div class="fn" />QChar <b><a href="qstring.html#at">at</a></b> (<i>self</i>, int)</li><li><div class="fn" />int <b><a href="qstring.html#capacity">capacity</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qstring.html#chop">chop</a></b> (<i>self</i>, int)</li><li><div class="fn" /><b><a href="qstring.html#clear">clear</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qstring.html#compare">compare</a></b> (<i>self</i>, QString)</li><li><div class="fn" />int <b><a href="qstring.html#compare-2">compare</a></b> (<i>self</i>, QString, Qt.CaseSensitivity&#160;<i>cs</i>)</li><li><div class="fn" />int <b><a href="qstring.html#compare-3">compare</a></b> (<i>self</i>, QLatin1String, Qt.CaseSensitivity&#160;<i>cs</i>&#160;=&#160;Qt.CaseSensitive)</li><li><div class="fn" />int <b><a href="qstring.html#compare-4">compare</a></b> (<i>self</i>, QStringRef, Qt.CaseSensitivity&#160;<i>cs</i>&#160;=&#160;Qt.CaseSensitive)</li><li><div class="fn" />bool <b><a href="qstring.html#contains">contains</a></b> (<i>self</i>, QString, Qt.CaseSensitivity&#160;<i>cs</i>&#160;=&#160;Qt.CaseSensitive)</li><li><div class="fn" />bool <b><a href="qstring.html#contains-2">contains</a></b> (<i>self</i>, QRegExp)</li><li><div class="fn" />int <b><a href="qstring.html#count">count</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qstring.html#count-2">count</a></b> (<i>self</i>, QString, Qt.CaseSensitivity&#160;<i>cs</i>&#160;=&#160;Qt.CaseSensitive)</li><li><div class="fn" />int <b><a href="qstring.html#count-3">count</a></b> (<i>self</i>, QRegExp)</li><li><div class="fn" />bool <b><a href="qstring.html#endsWith">endsWith</a></b> (<i>self</i>, QString, Qt.CaseSensitivity&#160;<i>cs</i>&#160;=&#160;Qt.CaseSensitive)</li><li><div class="fn" />bool <b><a href="qstring.html#endsWith-2">endsWith</a></b> (<i>self</i>, QLatin1String, Qt.CaseSensitivity&#160;<i>cs</i>&#160;=&#160;Qt.CaseSensitive)</li><li><div class="fn" />QString <b><a href="qstring.html#fill">fill</a></b> (<i>self</i>, QChar, int&#160;<i>size</i>&#160;=&#160;-1)</li><li><div class="fn" />int <b><a href="qstring.html#indexOf">indexOf</a></b> (<i>self</i>, QString, int&#160;<i>from</i>&#160;=&#160;0, Qt.CaseSensitivity&#160;<i>cs</i>&#160;=&#160;Qt.CaseSensitive)</li><li><div class="fn" />int <b><a href="qstring.html#indexOf-2">indexOf</a></b> (<i>self</i>, QLatin1String, int&#160;<i>from</i>&#160;=&#160;0, Qt.CaseSensitivity&#160;<i>cs</i>&#160;=&#160;Qt.CaseSensitive)</li><li><div class="fn" />int <b><a href="qstring.html#indexOf-3">indexOf</a></b> (<i>self</i>, QRegExp, int&#160;<i>from</i>&#160;=&#160;0)</li><li><div class="fn" />QString <b><a href="qstring.html#insert">insert</a></b> (<i>self</i>, int, QString)</li><li><div class="fn" />QString <b><a href="qstring.html#insert-2">insert</a></b> (<i>self</i>, int, QLatin1String)</li><li><div class="fn" />bool <b><a href="qstring.html#isEmpty">isEmpty</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qstring.html#isNull">isNull</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qstring.html#isRightToLeft">isRightToLeft</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qstring.html#isSimpleText">isSimpleText</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qstring.html#lastIndexOf">lastIndexOf</a></b> (<i>self</i>, QString, int&#160;<i>from</i>&#160;=&#160;-1, Qt.CaseSensitivity&#160;<i>cs</i>&#160;=&#160;Qt.CaseSensitive)</li><li><div class="fn" />int <b><a href="qstring.html#lastIndexOf-2">lastIndexOf</a></b> (<i>self</i>, QLatin1String, int&#160;<i>from</i>&#160;=&#160;-1, Qt.CaseSensitivity&#160;<i>cs</i>&#160;=&#160;Qt.CaseSensitive)</li><li><div class="fn" />int <b><a href="qstring.html#lastIndexOf-3">lastIndexOf</a></b> (<i>self</i>, QRegExp, int&#160;<i>from</i>&#160;=&#160;-1)</li><li><div class="fn" />QString <b><a href="qstring.html#left">left</a></b> (<i>self</i>, int)</li><li><div class="fn" />QString <b><a href="qstring.html#leftJustified">leftJustified</a></b> (<i>self</i>, int, QChar&#160;<i>fillChar</i>&#160;=&#160;QLatin1Char(' '), bool&#160;<i>truncate</i>&#160;=&#160;False)</li><li><div class="fn" />int <b><a href="qstring.html#length">length</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qstring.html#localeAwareCompare">localeAwareCompare</a></b> (<i>self</i>, QString)</li><li><div class="fn" />int <b><a href="qstring.html#localeAwareCompare-2">localeAwareCompare</a></b> (<i>self</i>, QStringRef)</li><li><div class="fn" />QString <b><a href="qstring.html#mid">mid</a></b> (<i>self</i>, int, int&#160;<i>n</i>&#160;=&#160;-1)</li><li><div class="fn" />QString <b><a href="qstring.html#normalized">normalized</a></b> (<i>self</i>, NormalizationForm)</li><li><div class="fn" />QString <b><a href="qstring.html#normalized-2">normalized</a></b> (<i>self</i>, NormalizationForm, QChar.UnicodeVersion)</li><li><div class="fn" />QString <b><a href="qstring.html#prepend">prepend</a></b> (<i>self</i>, QString)</li><li><div class="fn" />QString <b><a href="qstring.html#prepend-2">prepend</a></b> (<i>self</i>, QLatin1String)</li><li><div class="fn" />QString <b><a href="qstring.html#prepend-3">prepend</a></b> (<i>self</i>, QByteArray)</li><li><div class="fn" /><b><a href="qstring.html#push_back">push_back</a></b> (<i>self</i>, QString)</li><li><div class="fn" /><b><a href="qstring.html#push_front">push_front</a></b> (<i>self</i>, QString)</li><li><div class="fn" />QString <b><a href="qstring.html#remove">remove</a></b> (<i>self</i>, int, int)</li><li><div class="fn" />QString <b><a href="qstring.html#remove-2">remove</a></b> (<i>self</i>, QString, Qt.CaseSensitivity&#160;<i>cs</i>&#160;=&#160;Qt.CaseSensitive)</li><li><div class="fn" />QString <b><a href="qstring.html#remove-3">remove</a></b> (<i>self</i>, QRegExp)</li><li><div class="fn" />QString <b><a href="qstring.html#repeated">repeated</a></b> (<i>self</i>, int)</li><li><div class="fn" />QString <b><a href="qstring.html#replace">replace</a></b> (<i>self</i>, int, int, QString)</li><li><div class="fn" />QString <b><a href="qstring.html#replace-2">replace</a></b> (<i>self</i>, QString, QString, Qt.CaseSensitivity&#160;<i>cs</i>&#160;=&#160;Qt.CaseSensitive)</li><li><div class="fn" />QString <b><a href="qstring.html#replace-3">replace</a></b> (<i>self</i>, QRegExp, QString)</li><li><div class="fn" />QString <b><a href="qstring.html#replace-4">replace</a></b> (<i>self</i>, QLatin1String, QLatin1String, Qt.CaseSensitivity&#160;<i>cs</i>&#160;=&#160;Qt.CaseSensitive)</li><li><div class="fn" />QString <b><a href="qstring.html#replace-5">replace</a></b> (<i>self</i>, QLatin1String, QString, Qt.CaseSensitivity&#160;<i>cs</i>&#160;=&#160;Qt.CaseSensitive)</li><li><div class="fn" />QString <b><a href="qstring.html#replace-6">replace</a></b> (<i>self</i>, QString, QLatin1String, Qt.CaseSensitivity&#160;<i>cs</i>&#160;=&#160;Qt.CaseSensitive)</li><li><div class="fn" /><b><a href="qstring.html#reserve">reserve</a></b> (<i>self</i>, int)</li><li><div class="fn" /><b><a href="qstring.html#resize">resize</a></b> (<i>self</i>, int)</li><li><div class="fn" />QString <b><a href="qstring.html#right">right</a></b> (<i>self</i>, int)</li><li><div class="fn" />QString <b><a href="qstring.html#rightJustified">rightJustified</a></b> (<i>self</i>, int, QChar&#160;<i>fillChar</i>&#160;=&#160;QLatin1Char(' '), bool&#160;<i>truncate</i>&#160;=&#160;False)</li><li><div class="fn" />QString <b><a href="qstring.html#section">section</a></b> (<i>self</i>, QString, int, int&#160;<i>end</i>&#160;=&#160;-1, SectionFlags&#160;<i>flags</i>&#160;=&#160;QString.SectionDefault)</li><li><div class="fn" />QString <b><a href="qstring.html#section-2">section</a></b> (<i>self</i>, QRegExp, int, int&#160;<i>end</i>&#160;=&#160;-1, SectionFlags&#160;<i>flags</i>&#160;=&#160;QString.SectionDefault)</li><li><div class="fn" />QString <b><a href="qstring.html#setNum">setNum</a></b> (<i>self</i>, int, int&#160;<i>base</i>&#160;=&#160;10)</li><li><div class="fn" />QString <b><a href="qstring.html#setNum-2">setNum</a></b> (<i>self</i>, float, str&#160;<i>format</i>&#160;=&#160;'g', int&#160;<i>precision</i>&#160;=&#160;6)</li><li><div class="fn" />QString <b><a href="qstring.html#setNum-3">setNum</a></b> (<i>self</i>, int, int&#160;<i>base</i>&#160;=&#160;10)</li><li><div class="fn" />QString <b><a href="qstring.html#setNum-4">setNum</a></b> (<i>self</i>, int, int&#160;<i>base</i>&#160;=&#160;10)</li><li><div class="fn" />QString <b><a href="qstring.html#simplified">simplified</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qstring.html#size">size</a></b> (<i>self</i>)</li><li><div class="fn" />QStringList <b><a href="qstring.html#split">split</a></b> (<i>self</i>, QString, SplitBehavior&#160;<i>behavior</i>&#160;=&#160;QString.KeepEmptyParts, Qt.CaseSensitivity&#160;<i>cs</i>&#160;=&#160;Qt.CaseSensitive)</li><li><div class="fn" />QStringList <b><a href="qstring.html#split-2">split</a></b> (<i>self</i>, QRegExp, SplitBehavior&#160;<i>behavior</i>&#160;=&#160;QString.KeepEmptyParts)</li><li><div class="fn" /><b><a href="qstring.html#squeeze">squeeze</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qstring.html#startsWith">startsWith</a></b> (<i>self</i>, QString, Qt.CaseSensitivity&#160;<i>cs</i>&#160;=&#160;Qt.CaseSensitive)</li><li><div class="fn" />bool <b><a href="qstring.html#startsWith-2">startsWith</a></b> (<i>self</i>, QLatin1String, Qt.CaseSensitivity&#160;<i>cs</i>&#160;=&#160;Qt.CaseSensitive)</li><li><div class="fn" />QByteArray <b><a href="qstring.html#toAscii">toAscii</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qstring.html#toCaseFolded">toCaseFolded</a></b> (<i>self</i>)</li><li><div class="fn" />(float, bool&#160;<i>ok</i>) <b><a href="qstring.html#toDouble">toDouble</a></b> (<i>self</i>)</li><li><div class="fn" />(float, bool&#160;<i>ok</i>) <b><a href="qstring.html#toFloat">toFloat</a></b> (<i>self</i>)</li><li><div class="fn" />(int, bool&#160;<i>ok</i>) <b><a href="qstring.html#toInt">toInt</a></b> (<i>self</i>, int&#160;<i>base</i>&#160;=&#160;10)</li><li><div class="fn" />QByteArray <b><a href="qstring.html#toLatin1">toLatin1</a></b> (<i>self</i>)</li><li><div class="fn" />QByteArray <b><a href="qstring.html#toLocal8Bit">toLocal8Bit</a></b> (<i>self</i>)</li><li><div class="fn" />(int, bool&#160;<i>ok</i>) <b><a href="qstring.html#toLong">toLong</a></b> (<i>self</i>, int&#160;<i>base</i>&#160;=&#160;10)</li><li><div class="fn" />(int, bool&#160;<i>ok</i>) <b><a href="qstring.html#toLongLong">toLongLong</a></b> (<i>self</i>, int&#160;<i>base</i>&#160;=&#160;10)</li><li><div class="fn" />QString <b><a href="qstring.html#toLower">toLower</a></b> (<i>self</i>)</li><li><div class="fn" />(int, bool&#160;<i>ok</i>) <b><a href="qstring.html#toShort">toShort</a></b> (<i>self</i>, int&#160;<i>base</i>&#160;=&#160;10)</li><li><div class="fn" />(int, bool&#160;<i>ok</i>) <b><a href="qstring.html#toUInt">toUInt</a></b> (<i>self</i>, int&#160;<i>base</i>&#160;=&#160;10)</li><li><div class="fn" />(int, bool&#160;<i>ok</i>) <b><a href="qstring.html#toULong">toULong</a></b> (<i>self</i>, int&#160;<i>base</i>&#160;=&#160;10)</li><li><div class="fn" />(int, bool&#160;<i>ok</i>) <b><a href="qstring.html#toULongLong">toULongLong</a></b> (<i>self</i>, int&#160;<i>base</i>&#160;=&#160;10)</li><li><div class="fn" />QString <b><a href="qstring.html#toUpper">toUpper</a></b> (<i>self</i>)</li><li><div class="fn" />(int, bool&#160;<i>ok</i>) <b><a href="qstring.html#toUShort">toUShort</a></b> (<i>self</i>, int&#160;<i>base</i>&#160;=&#160;10)</li><li><div class="fn" />QByteArray <b><a href="qstring.html#toUtf8">toUtf8</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qstring.html#trimmed">trimmed</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qstring.html#truncate">truncate</a></b> (<i>self</i>, int)</li></ul><h3>Static Methods</h3><ul><li><div class="fn" />int <b><a href="qstring.html#compare-5">compare</a></b> (QString, QString)</li><li><div class="fn" />int <b><a href="qstring.html#compare-6">compare</a></b> (QString, QString, Qt.CaseSensitivity&#160;<i>cs</i>)</li><li><div class="fn" />int <b><a href="qstring.html#compare-7">compare</a></b> (QString, QLatin1String, Qt.CaseSensitivity&#160;<i>cs</i>&#160;=&#160;Qt.CaseSensitive)</li><li><div class="fn" />int <b><a href="qstring.html#compare-8">compare</a></b> (QLatin1String, QString, Qt.CaseSensitivity&#160;<i>cs</i>&#160;=&#160;Qt.CaseSensitive)</li><li><div class="fn" />int <b><a href="qstring.html#compare-9">compare</a></b> (QString, QStringRef, Qt.CaseSensitivity&#160;<i>cs</i>&#160;=&#160;Qt.CaseSensitive)</li><li><div class="fn" />QString <b><a href="qstring.html#fromAscii">fromAscii</a></b> (str, int&#160;<i>size</i>&#160;=&#160;-1)</li><li><div class="fn" />QString <b><a href="qstring.html#fromLatin1">fromLatin1</a></b> (str, int&#160;<i>size</i>&#160;=&#160;-1)</li><li><div class="fn" />QString <b><a href="qstring.html#fromLocal8Bit">fromLocal8Bit</a></b> (str, int&#160;<i>size</i>&#160;=&#160;-1)</li><li><div class="fn" />QString <b><a href="qstring.html#fromUtf8">fromUtf8</a></b> (str, int&#160;<i>size</i>&#160;=&#160;-1)</li><li><div class="fn" />int <b><a href="qstring.html#localeAwareCompare-3">localeAwareCompare</a></b> (QString, QString)</li><li><div class="fn" />int <b><a href="qstring.html#localeAwareCompare-4">localeAwareCompare</a></b> (QString, QStringRef)</li><li><div class="fn" />QString <b><a href="qstring.html#number">number</a></b> (int, int&#160;<i>base</i>&#160;=&#160;10)</li><li><div class="fn" />QString <b><a href="qstring.html#number-2">number</a></b> (float, str&#160;<i>format</i>&#160;=&#160;'g', int&#160;<i>precision</i>&#160;=&#160;6)</li><li><div class="fn" />QString <b><a href="qstring.html#number-3">number</a></b> (int, int&#160;<i>base</i>&#160;=&#160;10)</li><li><div class="fn" />QString <b><a href="qstring.html#number-4">number</a></b> (int, int&#160;<i>base</i>&#160;=&#160;10)</li></ul><h3>Special Methods</h3><ul><li><div class="fn" />QString <b><a href="qstring.html#__add__">__add__</a></b> (<i>self</i>, QString)</li><li><div class="fn" />QString <b><a href="qstring.html#__add__-2">__add__</a></b> (<i>self</i>, QByteArray)</li><li><div class="fn" />int <b><a href="qstring.html#__contains__">__contains__</a></b> (<i>self</i>, QString&#160;<i>s</i>)</li><li><div class="fn" />bool <b><a href="qstring.html#__eq__">__eq__</a></b> (<i>self</i>, QString)</li><li><div class="fn" />bool <b><a href="qstring.html#__eq__-2">__eq__</a></b> (<i>self</i>, QLatin1String)</li><li><div class="fn" />bool <b><a href="qstring.html#__eq__-3">__eq__</a></b> (<i>self</i>, QByteArray)</li><li><div class="fn" />bool <b><a href="qstring.html#__eq__-4">__eq__</a></b> (<i>self</i>, QStringRef)</li><li><div class="fn" />bool <b><a href="qstring.html#__ge__">__ge__</a></b> (<i>self</i>, QString)</li><li><div class="fn" />bool <b><a href="qstring.html#__ge__-2">__ge__</a></b> (<i>self</i>, QLatin1String)</li><li><div class="fn" />bool <b><a href="qstring.html#__ge__-3">__ge__</a></b> (<i>self</i>, QByteArray)</li><li><div class="fn" />QString <b><a href="qstring.html#__getitem__">__getitem__</a></b> (<i>self</i>, int&#160;<i>i</i>)</li><li><div class="fn" />QString <b><a href="qstring.html#__getitem__-2">__getitem__</a></b> (<i>self</i>, slice&#160;<i>slice</i>)</li><li><div class="fn" />bool <b><a href="qstring.html#__gt__">__gt__</a></b> (<i>self</i>, QString)</li><li><div class="fn" />bool <b><a href="qstring.html#__gt__-2">__gt__</a></b> (<i>self</i>, QLatin1String)</li><li><div class="fn" />bool <b><a href="qstring.html#__gt__-3">__gt__</a></b> (<i>self</i>, QByteArray)</li><li><div class="fn" />int <b><a href="qstring.html#__hash__">__hash__</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qstring.html#__iadd__">__iadd__</a></b> (<i>self</i>, QChar.SpecialCharacter)</li><li><div class="fn" />QString <b><a href="qstring.html#__iadd__-2">__iadd__</a></b> (<i>self</i>, QString)</li><li><div class="fn" />QString <b><a href="qstring.html#__iadd__-3">__iadd__</a></b> (<i>self</i>, QLatin1String)</li><li><div class="fn" />QString <b><a href="qstring.html#__iadd__-4">__iadd__</a></b> (<i>self</i>, QByteArray)</li><li><div class="fn" />QString <b><a href="qstring.html#__imul__">__imul__</a></b> (<i>self</i>, int&#160;<i>m</i>)</li><li><div class="fn" />bool <b><a href="qstring.html#__le__">__le__</a></b> (<i>self</i>, QString)</li><li><div class="fn" />bool <b><a href="qstring.html#__le__-2">__le__</a></b> (<i>self</i>, QLatin1String)</li><li><div class="fn" />bool <b><a href="qstring.html#__le__-3">__le__</a></b> (<i>self</i>, QByteArray)</li><li><div class="fn" /> <b><a href="qstring.html#__len__">__len__</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qstring.html#__lt__">__lt__</a></b> (<i>self</i>, QString)</li><li><div class="fn" />bool <b><a href="qstring.html#__lt__-2">__lt__</a></b> (<i>self</i>, QLatin1String)</li><li><div class="fn" />bool <b><a href="qstring.html#__lt__-3">__lt__</a></b> (<i>self</i>, QByteArray)</li><li><div class="fn" />QString <b><a href="qstring.html#__mul__">__mul__</a></b> (<i>self</i>, int&#160;<i>m</i>)</li><li><div class="fn" />bool <b><a href="qstring.html#__ne__">__ne__</a></b> (<i>self</i>, QString)</li><li><div class="fn" />bool <b><a href="qstring.html#__ne__-2">__ne__</a></b> (<i>self</i>, QLatin1String)</li><li><div class="fn" />bool <b><a href="qstring.html#__ne__-3">__ne__</a></b> (<i>self</i>, QByteArray)</li><li><div class="fn" />bool <b><a href="qstring.html#__ne__-4">__ne__</a></b> (<i>self</i>, QStringRef)</li><li><div class="fn" />str <b><a href="qstring.html#__repr__">__repr__</a></b> (<i>self</i>)</li><li><div class="fn" />str <b><a href="qstring.html#__str__">__str__</a></b> (<i>self</i>)</li><li><div class="fn" />unicode <b><a href="qstring.html#__unicode__">__unicode__</a></b> (<i>self</i>)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>This class can be pickled.</p><p>A Python string or unicode object, a
    <a href="qlatin1string.html">QLatin1String</a> or a
    <a href="qchar.html">QChar</a>
    may be used whenever a
    <a href="qstring.html">QString</a>
    is expected.</p>
  <p>The QString class provides a Unicode character string.</p>
<p>QString stores a string of 16-bit <a href="qchar.html">QChar</a>s, where each <a href="qchar.html">QChar</a> corresponds one Unicode 4.0 character. (Unicode characters with code values above 65535 are stored using surrogate pairs, i.e., two consecutive <a href="qchar.html">QChar</a>s.)</p>
<p><a href="unicode.html#unicode">Unicode</a> is an international standard that supports most of the writing systems in use today. It is a superset of ASCII and Latin-1 (ISO 8859-1), and all the ASCII/Latin-1 characters are available at the same code positions.</p>
<p>Behind the scenes, QString uses <a href="implicit-sharing.html">implicit sharing</a> (copy-on-write) to reduce memory usage and to avoid the needless copying of data. This also helps reduce the inherent overhead of storing 16-bit characters instead of 8-bit characters.</p>
<p>In addition to QString, Qt also provides the <a href="qbytearray.html">QByteArray</a> class to store raw bytes and traditional 8-bit '\0'-terminated strings. For most purposes, QString is the class you want to use. It is used throughout the Qt API, and the Unicode support ensures that your applications will be easy to translate if you want to expand your application's market at some point. The two main cases where <a href="qbytearray.html">QByteArray</a> is appropriate are when you need to store raw binary data, and when memory conservation is critical (e.g., with <a href="qt-embedded-linux.html">Qt for Embedded Linux</a>).</p>
<ul><li><a href="#initializing-a-string">Initializing a String</a></li>
<li><a href="#manipulating-string-data">Manipulating String Data</a></li>
<li><a href="#querying-string-data">Querying String Data</a></li>
<li><a href="#converting-between-8-bit-strings-and-unicode-strings">Converting Between 8-Bit Strings and Unicode Strings</a></li>
<li><a href="#note-for-c-programmers">Note for C Programmers</a></li>
<li><a href="#distinction-between-null-and-empty-strings">Distinction Between Null and Empty Strings</a></li>
<li><a href="#argument-formats">Argument Formats</a></li>
<li><a href="#more-efficient-string-construction">More Efficient String Construction</a></li>
</ul>
<a name="initializing-a-string" />
<h3>Initializing a String</h3>
<p>One way to initialize a QString is simply to pass a <tt>const char *</tt> to its constructor. For example, the following code creates a QString of size 5 containing the data "Hello":</p>
<pre>     QString str = "Hello";</pre>
<p>QString converts the <tt>const char *</tt> data into Unicode using the <a href="qstring.html#fromAscii">fromAscii</a>() function. By default, <a href="qstring.html#fromAscii">fromAscii</a>() treats character above 128 as Latin-1 characters, but this can be changed by calling <a href="qtextcodec.html#setCodecForCStrings">QTextCodec.setCodecForCStrings</a>().</p>
<p>In all of the QString functions that take <tt>const char *</tt> parameters, the <tt>const char *</tt> is interpreted as a classic C-style '\0'-terminated string. It is legal for the <tt>const char *</tt> parameter to be 0.</p>
<p>You can also provide string data as an array of <a href="qchar.html">QChar</a>s:</p>
<pre>     static const QChar data[4] = { 0x0055, 0x006e, 0x10e3, 0x03a3 };
     QString str(data, 4);</pre>
<p>QString makes a deep copy of the <a href="qchar.html">QChar</a> data, so you can modify it later without experiencing side effects. (If for performance reasons you don't want to take a deep copy of the character data, use <a href="qstring.html#fromRawData">QString.fromRawData</a>() instead.)</p>
<p>Another approach is to set the size of the string using <a href="qstring.html#resize">resize</a>() and to initialize the data character per character. QString uses 0-based indexes, just like C++ arrays. To access the character at a particular index position, you can use <a href="qstring.html#operator-5b-5d">operator[]</a>(). On non-const strings, <a href="qstring.html#operator-5b-5d">operator[]</a>() returns a reference to a character that can be used on the left side of an assignment. For example:</p>
<pre>     QString str;
     str.resize(4);

     str[0] = QChar('U');
     str[1] = QChar('n');
     str[2] = QChar(0x10e3);
     str[3] = QChar(0x03a3);</pre>
<p>For read-only access, an alternative syntax is to use the <a href="qstring.html#at">at</a>() function:</p>
<pre>     QString str;

     for (int i = 0; i &lt; str.size(); ++i) {
         if (str.at(i) &gt;= QChar('a') &amp;&amp; str.at(i) &lt;= QChar('f'))
             qDebug() &lt;&lt; "Found character in range [a-f]";
     }</pre>
<p>The <a href="qstring.html#at">at</a>() function can be faster than <a href="qstring.html#operator-5b-5d">operator[]</a>(), because it never causes a <a href="implicit-sharing.html#deep-copy">deep copy</a> to occur. Alternatively, use the <a href="qstring.html#left">left</a>(), <a href="qstring.html#right">right</a>(), or <a href="qstring.html#mid">mid</a>() functions to extract several characters at a time.</p>
<p>A QString can embed '\0' characters (<a href="qchar.html#SpecialCharacter-enum">QChar.Null</a>). The <a href="qstring.html#size">size</a>() function always returns the size of the whole string, including embedded '\0' characters.</p>
<p>After a call to the <a href="qstring.html#resize">resize</a>() function, newly allocated characters have undefined values. To set all the characters in the string to a particular value, use the <a href="qstring.html#fill">fill</a>() function.</p>
<p>QString provides dozens of overloads designed to simplify string usage. For example, if you want to compare a QString with a string literal, you can write code like this and it will work as expected:</p>
<pre>     QString str;

     if (str == "auto" || str == "extern"
             || str == "static" || str == "register") {
         <span class="comment">// ...</span>
     }</pre>
<p>You can also pass string literals to functions that take QStrings as arguments, invoking the QString(const char *) constructor. Similarly, you can pass a QString to a function that takes a <tt>const char *</tt> argument using the <a href="qtcore.html#qPrintable">qPrintable</a>() macro which returns the given QString as a <tt>const char *</tt>. This is equivalent to calling &lt;QString&gt;.<a href="qstring.html#toLocal8Bit">toLocal8Bit</a>().<a href="qstring.html#constData">constData</a>().</p>
<a name="manipulating-string-data" />
<h3>Manipulating String Data</h3>
<p>QString provides the following basic functions for modifying the character data: <a href="qstring.html#append">append</a>(), <a href="qstring.html#prepend">prepend</a>(), <a href="qstring.html#insert">insert</a>(), <a href="qstring.html#replace">replace</a>(), and <a href="qstring.html#remove">remove</a>(). For example:</p>
<pre>     QString str = "and";
     str.prepend("rock ");     <span class="comment">// str == "rock and"</span>
     str.append(" roll");        <span class="comment">// str == "rock and roll"</span>
     str.replace(5, 3, "&amp;");   <span class="comment">// str == "rock &amp; roll"</span></pre>
<p>If you are building a QString gradually and know in advance approximately how many characters the QString will contain, you can call <a href="qstring.html#reserve">reserve</a>(), asking QString to preallocate a certain amount of memory. You can also call <a href="qstring.html#capacity">capacity</a>() to find out how much memory QString actually allocated.</p>
<p>The <a href="qstring.html#replace">replace</a>() and <a href="qstring.html#remove">remove</a>() functions' first two arguments are the position from which to start erasing and the number of characters that should be erased. If you want to replace all occurrences of a particular substring with another, use one of the two-parameter <a href="qstring.html#replace">replace</a>() overloads.</p>
<p>A frequent requirement is to remove whitespace characters from a string ('\n', '\t', ' ', etc.). If you want to remove whitespace from both ends of a QString, use the <a href="qstring.html#trimmed">trimmed</a>() function. If you want to remove whitespace from both ends and replace multiple consecutive whitespaces with a single space character within the string, use <a href="qstring.html#simplified">simplified</a>().</p>
<p>If you want to find all occurrences of a particular character or substring in a QString, use the <a href="qstring.html#indexOf">indexOf</a>() or <a href="qstring.html#lastIndexOf">lastIndexOf</a>() functions. The former searches forward starting from a given index position, the latter searches backward. Both return the index position of the character or substring if they find it; otherwise, they return -1. For example, here's a typical loop that finds all occurrences of a particular substring:</p>
<pre>     QString str = "We must be &lt;b&gt;bold&lt;/b&gt;, very &lt;b&gt;bold&lt;/b&gt;";
     int j = 0;

     while ((j = str.indexOf("&lt;b&gt;", j)) != -1) {
         qDebug() &lt;&lt; "Found &lt;b&gt; tag at index position" &lt;&lt; j;
         ++j;
     }</pre>
<p>QString provides many functions for converting numbers into strings and strings into numbers. See the <a href="qstring.html#arg">arg</a>() functions, the <a href="qstring.html#setNum">setNum</a>() functions, the <a href="qstring.html#number">number</a>() static functions, and the <a href="qstring.html#toInt">toInt</a>(), <a href="qstring.html#toDouble">toDouble</a>(), and similar functions.</p>
<p>To get an upper- or lowercase version of a string use <a href="qstring.html#toUpper">toUpper</a>() or <a href="qstring.html#toLower">toLower</a>().</p>
<p>Lists of strings are handled by the <a href="qstringlist.html">QStringList</a> class. You can split a string into a list of strings using the <a href="qstring.html#split">split</a>() function, and join a list of strings into a single string with an optional separator using <a href="qstringlist.html#join">QStringList.join</a>(). You can obtain a list of strings from a string list that contain a particular substring or that match a particular <a href="qregexp.html">QRegExp</a> using the <a class="compat" href="qlist-qt3.html#find">QStringList.find</a>() function. :</p>
<a name="querying-string-data" />
<h3>Querying String Data</h3>
<p>If you want to see if a QString starts or ends with a particular substring use <a href="qstring.html#startsWith">startsWith</a>() or <a href="qstring.html#endsWith">endsWith</a>(). If you simply want to check whether a QString contains a particular character or substring, use the <a href="qstring.html#contains">contains</a>() function. If you want to find out how many times a particular character or substring occurs in the string, use <a href="qstring.html#count">count</a>().</p>
<p>QStrings can be compared using overloaded operators such as <a href="qstring.html#operator-lt">operator&lt;</a>(), <a href="qstring.html#operator-lt-eq">operator&lt;=</a>(), <a href="qstring.html#operator-eq-eq">operator==</a>(), <a href="qstring.html#operator-gt-eq">operator&gt;=</a>(), and so on. Note that the comparison is based exclusively on the numeric Unicode values of the characters. It is very fast, but is not what a human would expect; the <a href="qstring.html#localeAwareCompare">QString.localeAwareCompare</a>() function is a better choice for sorting user-interface strings.</p>
<p>To obtain a pointer to the actual character data, call <a href="qstring.html#data">data</a>() or <a href="qstring.html#constData">constData</a>(). These functions return a pointer to the beginning of the <a href="qchar.html">QChar</a> data. The pointer is guaranteed to remain valid until a non-const function is called on the QString.</p>
<a name="converting-between-8-bit-strings-and-unicode-strings" />
<h3>Converting Between 8-Bit Strings and Unicode Strings</h3>
<p>QString provides the following four functions that return a <tt>const char *</tt> version of the string as <a href="qbytearray.html">QByteArray</a>: <a href="qstring.html#toAscii">toAscii</a>(), <a href="qstring.html#toLatin1">toLatin1</a>(), <a href="qstring.html#toUtf8">toUtf8</a>(), and <a href="qstring.html#toLocal8Bit">toLocal8Bit</a>().</p>
<ul>
<li><a href="qstring.html#toAscii">toAscii</a>() returns an ASCII encoded 8-bit string.</li>
<li><a href="qstring.html#toLatin1">toLatin1</a>() returns a Latin-1 (ISO 8859-1) encoded 8-bit string.</li>
<li><a href="qstring.html#toUtf8">toUtf8</a>() returns a UTF-8 encoded 8-bit string. UTF-8 is a superset of ASCII that supports the entire Unicode character set through multibyte sequences.</li>
<li><a href="qstring.html#toLocal8Bit">toLocal8Bit</a>() returns an 8-bit string using the system's local encoding.</li>
</ul>
<p>To convert from one of these encodings, QString provides <a href="qstring.html#fromAscii">fromAscii</a>(), <a href="qstring.html#fromLatin1">fromLatin1</a>(), <a href="qstring.html#fromUtf8">fromUtf8</a>(), and <a href="qstring.html#fromLocal8Bit">fromLocal8Bit</a>(). Other encodings are supported through the <a href="qtextcodec.html">QTextCodec</a> class.</p>
<p>As mentioned above, QString provides a lot of functions and operators that make it easy to interoperate with <tt>const char *</tt> strings. But this functionality is a double-edged sword: It makes QString more convenient to use if all strings are ASCII or Latin-1, but there is always the risk that an implicit conversion from or to <tt>const char *</tt> is done using the wrong 8-bit encoding. To minimize these risks, you can turn off these implicit conversions by defining the following two preprocessor symbols:</p>
<ul>
<li><tt>QT_NO_CAST_FROM_ASCII</tt> disables automatic conversions from ASCII to Unicode.</li>
<li><tt>QT_NO_CAST_TO_ASCII</tt> disables automatic conversion from QString to ASCII.</li>
</ul>
<p>One way to define these preprocessor symbols globally for your application is to add the following entry to your <a href="qmake-project-files.html">qmake project file</a>:</p>
<pre> DEFINES += QT_NO_CAST_FROM_ASCII \
            QT_NO_CAST_TO_ASCII</pre>
<p>You then need to explicitly call <a href="qstring.html#fromAscii">fromAscii</a>(), <a href="qstring.html#fromLatin1">fromLatin1</a>(), <a href="qstring.html#fromUtf8">fromUtf8</a>(), or <a href="qstring.html#fromLocal8Bit">fromLocal8Bit</a>() to construct a QString from an 8-bit string, or use the lightweight <a href="qlatin1string.html">QLatin1String</a> class, for example:</p>
<pre> QString url = QLatin1String("http:<span class="comment">//www.unicode.org/");</span></pre>
<p>Similarly, you must call <a href="qstring.html#toAscii">toAscii</a>(), <a href="qstring.html#toLatin1">toLatin1</a>(), <a href="qstring.html#toUtf8">toUtf8</a>(), or <a href="qstring.html#toLocal8Bit">toLocal8Bit</a>() explicitly to convert the QString to an 8-bit string. (Other encodings are supported through the <a href="qtextcodec.html">QTextCodec</a> class.)</p>
<p><table align="center" border="0" cellpadding="2" cellspacing="1" class="generic" width="100 %">
<tr class="odd" valign="top"><td><a name="note-for-c-programmers" />
<h3>Note for C Programmers</h3>
<p>Due to C++'s type system and the fact that QString is <a href="implicit-sharing.html#implicitly-shared">implicitly shared</a>, QStrings may be treated like <tt>int</tt>s or other basic types. For example:</p>
<pre>     QString Widget.boolToString(bool b)
     {
         QString result;
         if (b)
             result = "True";
         else
             result = "False";
         return result;
     }</pre>
<p>The <tt>result</tt> variable, is a normal variable allocated on the stack. When <tt>return</tt> is called, and because we're returning by value, the copy constructor is called and a copy of the string is returned. No actual copying takes place thanks to the implicit sharing.</p>
</td></tr>
</table></p>
<a name="distinction-between-null-and-empty-strings" />
<h3>Distinction Between Null and Empty Strings</h3>
<p>For historical reasons, QString distinguishes between a null string and an empty string. A <i>null</i> string is a string that is initialized using QString's default constructor or by passing (const char *)0 to the constructor. An <i>empty</i> string is any string with size 0. A null string is always empty, but an empty string isn't necessarily null:</p>
<pre>     QString().isNull();               <span class="comment">// returns true</span>
     QString().isEmpty();              <span class="comment">// returns true</span>

     QString("").isNull();             <span class="comment">// returns false</span>
     QString("").isEmpty();            <span class="comment">// returns true</span>

     QString("abc").isNull();          <span class="comment">// returns false</span>
     QString("abc").isEmpty();         <span class="comment">// returns false</span></pre>
<p>All functions except <a href="qstring.html#isNull">isNull</a>() treat null strings the same as empty strings. For example, <a href="qstring.html#toAscii">toAscii</a>().<a href="qstring.html#constData">constData</a>() returns a pointer to a '\0' character for a null string (<i>not</i> a null pointer), and <a href="qstring.html#QString">QString</a>() compares equal to QString(""). We recommend that you always use the <a href="qstring.html#isEmpty">isEmpty</a>() function and avoid <a href="qstring.html#isNull">isNull</a>().</p>
<a name="argument-formats" />
<h3>Argument Formats</h3>
<p>In member functions where an argument <i>format</i> can be specified (e.g., <a href="qstring.html#arg">arg</a>(), <a href="qstring.html#number">number</a>()), the argument <i>format</i> can be one of the following:</p>
<p><table align="center" border="0" cellpadding="2" cellspacing="1" class="generic">
<thead><tr class="qt-style" valign="top"><th>Format</th><th>Meaning</th></tr></thead>
<tr class="odd" valign="top"><td><tt>e</tt></td><td>format as [-]9.9e[+|-]999</td></tr>
<tr class="even" valign="top"><td><tt>E</tt></td><td>format as [-]9.9E[+|-]999</td></tr>
<tr class="odd" valign="top"><td><tt>f</tt></td><td>format as [-]9.9</td></tr>
<tr class="even" valign="top"><td><tt>g</tt></td><td>use <tt>e</tt> or <tt>f</tt> format, whichever is the most concise</td></tr>
<tr class="odd" valign="top"><td><tt>G</tt></td><td>use <tt>E</tt> or <tt>f</tt> format, whichever is the most concise</td></tr>
</table></p>
<p>A <i>precision</i> is also specified with the argument <i>format</i>. For the 'e', 'E', and 'f' formats, the <i>precision</i> represents the number of digits <i>after</i> the decimal point. For the 'g' and 'G' formats, the <i>precision</i> represents the maximum number of significant digits (trailing zeroes are omitted).</p>
<a name="more-efficient-string-construction" />
<h3>More Efficient String Construction</h3>
<p>Using the QString <tt>'+'</tt> operator, it is easy to construct a complex string from multiple substrings. You will often write code like this:</p>
<pre>     QString foo;
     QString type = "long";

     foo-&gt;setText(QLatin1String("vector&lt;") + type + QLatin1String("&gt;.iterator"));

     if (foo.startsWith("(" + type + ") 0x"))
         ...</pre>
<p>There is nothing wrong with either of these string constructions, but there are a few hidden inefficiencies. Beginning with Qt 4.6, you can eliminate them.</p>
<p>First, multiple uses of the <tt>'+'</tt> operator usually means multiple memory allocations. When concatenating <i>n</i> substrings, where <i>n &gt; 2</i>, there can be as many as <i>n - 1</i> calls to the memory allocator.</p>
<p>Second, <a href="qlatin1string.html">QLatin1String</a> does not store its length internally but calls <a href="qtcore.html#qstrlen">qstrlen</a>() when it needs to know its length.</p>
<p>In 4.6, an internal template class <tt>QStringBuilder</tt> has been added along with a few helper functions. This class is marked internal and does not appear in the documentation, because you aren't meant to instantiate it in your code. Its use will be automatic, as described below. The class is found in <tt>src/corelib/tools/qstringbuilder.cpp</tt> if you want to have a look at it.</p>
<p><tt>QStringBuilder</tt> uses expression templates and reimplements the <tt>'%'</tt> operator so that when you use <tt>'%'</tt> for string concatenation instead of <tt>'+'</tt>, multiple substring concatenations will be postponed until the final result is about to be assigned to a QString. At this point, the amount of memory required for the final result is known. The memory allocator is then called <i>once</i> to get the required space, and the substrings are copied into it one by one.</p>
<p><tt>QLatin1Literal</tt> is a second internal class that can replace <a href="qlatin1string.html">QLatin1String</a>, which can't be changed for compatibility reasons. <tt>QLatin1Literal</tt> stores its length, thereby saving time when <tt>QStringBuilder</tt> computes the amount of memory required for the final string.</p>
<p>Additional efficiency is gained by inlining and reduced reference counting (the QString created from a <tt>QStringBuilder</tt> typically has a ref count of 1, whereas <a href="qstring.html#append">QString.append</a>() needs an extra test).</p>
<p>There are three ways you can access this improved method of string construction. The straightforward way is to include <tt>QStringBuilder</tt> wherever you want to use it, and use the <tt>'%'</tt> operator instead of <tt>'+'</tt> when concatenating strings:</p>
<pre>     #include &lt;QStringBuilder&gt;

     QString hello("hello");
     QStringRef el(&amp;hello, 2, 3);
     QLatin1String world("world");
     QString message =  hello % el % world % QChar('!');</pre>
<p>A more global approach is to include this define:</p>
<pre>     #define QT_USE_FAST_CONCATENATION</pre>
<p>and use <tt>'%'</tt> instead of <tt>'+'</tt> for string concatenation everywhere. The third approach, which is the most convenient but not entirely source compatible, is to include two defines:</p>
<pre>     #define QT_USE_FAST_CONCATENATION
     #define QT_USE_FAST_OPERATOR_PLUS</pre>
<p>and the <tt>'+'</tt> will automatically be performed as the <tt>QStringBuilder</tt> <tt>'%'</tt> everywhere.</p>
<p>See also <a href="qstring.html#fromRawData">fromRawData</a>(), <a href="qchar.html">QChar</a>, <a href="qlatin1string.html">QLatin1String</a>, <a href="qbytearray.html">QByteArray</a>, and <a href="qstringref.html">QStringRef</a>.</p>
<hr /><h2>Type Documentation</h2><h3 class="fn"><a name="NormalizationForm-enum" />QString.NormalizationForm</h3><p>This enum describes the various normalized forms of Unicode text.</p>
<p><table border="1" cellpadding="2" cellspacing="1" class="valuelist" width="100%">
<tr><th width="25%">Constant</th><th width="15%">Value</th><th width="60%">Description</th></tr>
<tr><td valign="top"><tt>QString.NormalizationForm_D</tt></td><td align="center" valign="top"><tt>0</tt></td><td valign="top">Canonical Decomposition</td></tr>
<tr><td valign="top"><tt>QString.NormalizationForm_C</tt></td><td align="center" valign="top"><tt>1</tt></td><td valign="top">Canonical Decomposition followed by Canonical Composition</td></tr>
<tr><td valign="top"><tt>QString.NormalizationForm_KD</tt></td><td align="center" valign="top"><tt>2</tt></td><td valign="top">Compatibility Decomposition</td></tr>
<tr><td valign="top"><tt>QString.NormalizationForm_KC</tt></td><td align="center" valign="top"><tt>3</tt></td><td valign="top">Compatibility Decomposition followed by Canonical Composition</td></tr>
</table></p>
<p>See also <a href="qstring.html#normalized">normalized</a>() and <a href="http://www.unicode.org/reports/tr15/">Unicode Standard Annex #15</a>.</p>
<a name="//apple_ref/cpp/tag/QString/SectionFlag" />
<a name="//apple_ref/cpp/econst/QString/SectionDefault" />
<a name="//apple_ref/cpp/econst/QString/SectionSkipEmpty" />
<a name="//apple_ref/cpp/econst/QString/SectionIncludeLeadingSep" />
<a name="//apple_ref/cpp/econst/QString/SectionIncludeTrailingSep" />
<a name="//apple_ref/cpp/econst/QString/SectionCaseInsensitiveSeps" />
<a name="//apple_ref/cpp/tdef/QString/SectionFlags" />
<h3 class="fn"><a name="SectionFlag-enum" />QString.SectionFlag</h3><p>This enum specifies flags that can be used to affect various aspects of the <a href="qstring.html#section">section</a>() function's behavior with respect to separators and empty fields.</p>
<p><table border="1" cellpadding="2" cellspacing="1" class="valuelist" width="100%">
<tr><th width="25%">Constant</th><th width="15%">Value</th><th width="60%">Description</th></tr>
<tr><td valign="top"><tt>QString.SectionDefault</tt></td><td align="center" valign="top"><tt>0x00</tt></td><td valign="top">Empty fields are counted, leading and trailing separators are not included, and the separator is compared case sensitively.</td></tr>
<tr><td valign="top"><tt>QString.SectionSkipEmpty</tt></td><td align="center" valign="top"><tt>0x01</tt></td><td valign="top">Treat empty fields as if they don't exist, i.e. they are not considered as far as <i>start</i> and <i>end</i> are concerned.</td></tr>
<tr><td valign="top"><tt>QString.SectionIncludeLeadingSep</tt></td><td align="center" valign="top"><tt>0x02</tt></td><td valign="top">Include the leading separator (if any) in the result string.</td></tr>
<tr><td valign="top"><tt>QString.SectionIncludeTrailingSep</tt></td><td align="center" valign="top"><tt>0x04</tt></td><td valign="top">Include the trailing separator (if any) in the result string.</td></tr>
<tr><td valign="top"><tt>QString.SectionCaseInsensitiveSeps</tt></td><td align="center" valign="top"><tt>0x08</tt></td><td valign="top">Compare the separator case-insensitively.</td></tr>
</table></p>
<p>The SectionFlags type is a typedef for <a href="qflags.html">QFlags</a>&lt;SectionFlag&gt;. It stores an OR combination of SectionFlag values.</p>
<p>See also <a href="qstring.html#section">section</a>().</p>
<a name="//apple_ref/cpp/tag/QString/SplitBehavior" />
<a name="//apple_ref/cpp/econst/QString/KeepEmptyParts" />
<a name="//apple_ref/cpp/econst/QString/SkipEmptyParts" />
<h3 class="fn"><a name="SplitBehavior-enum" />QString.SplitBehavior</h3><p>This enum specifies how the <a href="qstring.html#split">split</a>() function should behave with respect to empty strings.</p>
<p><table border="1" cellpadding="2" cellspacing="1" class="valuelist" width="100%">
<tr><th width="25%">Constant</th><th width="15%">Value</th><th width="60%">Description</th></tr>
<tr><td valign="top"><tt>QString.KeepEmptyParts</tt></td><td align="center" valign="top"><tt>0</tt></td><td valign="top">If a field is empty, keep it in the result.</td></tr>
<tr><td valign="top"><tt>QString.SkipEmptyParts</tt></td><td align="center" valign="top"><tt>1</tt></td><td valign="top">If a field is empty, don't include it in the result.</td></tr>
</table></p>
<p>See also <a href="qstring.html#split">split</a>().</p>
<a name="//apple_ref/cpp/tdef/QString/const_iterator" />
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QString" />QString.__init__ (<i>self</i>)</h3><p>Constructs a null string. Null strings are also empty.</p>
<p>See also <a href="qstring.html#isEmpty">isEmpty</a>().</p>
<h3 class="fn"><a name="QString" />QString.__init__ (<i>self</i>, <a href="qkeysequence.html">QKeySequence</a>)</h3><p>This method is only available if the QtGui module is imported.</p><p>Constructs a null string. Null strings are also empty.</p>
<p>See also <a href="qstring.html#isEmpty">isEmpty</a>().</p>
<h3 class="fn"><a name="QString" />QString.__init__ (<i>self</i>, <a href="qscriptstring.html">QScriptString</a>)</h3><p>This method is only available if the QtScript module is imported.</p><p>Constructs a null string. Null strings are also empty.</p>
<p>See also <a href="qstring.html#isEmpty">isEmpty</a>().</p>
<h3 class="fn"><a name="QString-2" />QString.__init__ (<i>self</i>, int, QChar)</h3><p>Constructs a string initialized with the first <i>size</i> characters of the <a href="qchar.html">QChar</a> array <i>unicode</i>.</p>
<p><a href="qstring.html">QString</a> makes a deep copy of the string data. The unicode data is copied as is and the Byte Order Mark is preserved if present.</p>
<h3 class="fn"><a name="QString-3" />QString.__init__ (<i>self</i>, QString)</h3><p>Constructs a string of size 1 containing the character <i>ch</i>.</p>
<h3 class="fn"><a name="QString-4" />QString.__init__ (<i>self</i>, <a href="qbytearray.html">QByteArray</a>)</h3><p>Constructs a string of the given <i>size</i> with every character set to <i>ch</i>.</p>
<p>See also <a href="qstring.html#fill">fill</a>().</p>
<h3 class="fn"><a name="QString-5" />QString.__init__ (<i>self</i>, <a href="quuid.html">QUuid</a>)</h3><p>Constructs a copy of the Latin-1 string <i>str</i>.</p>
<p>See also <a href="qstring.html#fromLatin1">fromLatin1</a>().</p>
<h3 class="fn"><a name="append" />QString QString.append (<i>self</i>, QString)</h3><p>Appends the string <i>str</i> onto the end of this string.</p>
<p>Example:</p>
<pre>     QString x = "free";
     QString y = "dom";

     x.append(y);
     <span class="comment">// x == "freedom"</span></pre>
<p>This is the same as using the <a href="qstring.html#insert">insert</a>() function:</p>
<pre>     x.insert(x.size(), y);</pre>
<p>The append() function is typically very fast (<a href="containers.html#constant-time">constant time</a>), because <a href="qstring.html">QString</a> preallocates extra space at the end of the string data so it can grow without reallocating the entire string each time.</p>
<p>See also <a href="qstring.html#operator-2b-eq">operator+=</a>(), <a href="qstring.html#prepend">prepend</a>(), and <a href="qstring.html#insert">insert</a>().</p>
<h3 class="fn"><a name="append-2" />QString QString.append (<i>self</i>, <a href="qlatin1string.html">QLatin1String</a>)</h3><p>Appends the given string <i>reference</i> to this string and returns the result.</p>
<p>This function was introduced in Qt 4.4.</p>
<h3 class="fn"><a name="append-3" />QString QString.append (<i>self</i>, <a href="qbytearray.html">QByteArray</a>)</h3><p>This function overloads <a href="qstring.html#append">append</a>().</p>
<p>Appends the Latin-1 string <i>str</i> to this string.</p>
<h3 class="fn"><a name="arg" />QString QString.arg (<i>self</i>, int, int&#160;<i>fieldWidth</i>&#160;=&#160;0, int&#160;<i>base</i>&#160;=&#160;10, QChar&#160;<i>fillChar</i>&#160;=&#160;QLatin1Char(' '))</h3><p>Returns a copy of this string with the lowest numbered place marker replaced by string <i>a</i>, i.e., <tt>%1</tt>, <tt>%2</tt>, ..., <tt>%99</tt>.</p>
<p><i>fieldWidth</i> specifies the minimum amount of space that argument <i>a</i> shall occupy. If <i>a</i> requires less space than <i>fieldWidth</i>, it is padded to <i>fieldWidth</i> with character <i>fillChar</i>. A positive <i>fieldWidth</i> produces right-aligned text. A negative <i>fieldWidth</i> produces left-aligned text.</p>
<p>This example shows how we might create a <tt>status</tt> string for reporting progress while processing a list of files:</p>
<pre>     QString i;           <span class="comment">// current file's number</span>
     QString total;       <span class="comment">// number of files to process</span>
     QString fileName;    <span class="comment">// current file's name</span>

     QString status = QString("Processing file %1 of %2: %3")
                     .arg(i).arg(total).arg(fileName);</pre>
<p>First, <tt>arg(i)</tt> replaces <tt>%1</tt>. Then <tt>arg(total)</tt> replaces <tt>%2</tt>. Finally, <tt>arg(fileName)</tt> replaces <tt>%3</tt>.</p>
<p>One advantage of using arg() over <a href="qstring.html#sprintf">sprintf</a>() is that the order of the numbered place markers can change, if the application's strings are translated into other languages, but each arg() will still replace the lowest numbered unreplaced place marker, no matter where it appears. Also, if place marker <tt>%i</tt> appears more than once in the string, the arg() replaces all of them.</p>
<p>If there is no unreplaced place marker remaining, a warning message is output and the result is undefined. Place marker numbers must be in the range 1 to 99.</p>
<h3 class="fn"><a name="arg-2" />QString QString.arg (<i>self</i>, float, int&#160;<i>fieldWidth</i>&#160;=&#160;0, str&#160;<i>format</i>&#160;=&#160;'g', int&#160;<i>precision</i>&#160;=&#160;-1, QChar&#160;<i>fillChar</i>&#160;=&#160;QLatin1Char(' '))</h3><p>This function overloads <a href="qstring.html#arg">arg</a>().</p>
<p>This is the same as <tt>str.arg(a1).arg(a2)</tt>, except that the strings <i>a1</i> and <i>a2</i> are replaced in one pass. This can make a difference if <i>a1</i> contains e.g. <tt>%1</tt>:</p>
<pre>     QString str;
     str = "%1 %2";

     str.arg("%1f", "Hello");        <span class="comment">// returns "%1f Hello"</span>
     str.arg("%1f").arg("Hello");    <span class="comment">// returns "Hellof %2"</span></pre>
<h3 class="fn"><a name="arg-3" />QString QString.arg (<i>self</i>, int, int&#160;<i>fieldWidth</i>&#160;=&#160;0, int&#160;<i>base</i>&#160;=&#160;10, QChar&#160;<i>fillChar</i>&#160;=&#160;QLatin1Char(' '))</h3><p>This function overloads <a href="qstring.html#arg">arg</a>().</p>
<p>This is the same as calling <tt>str.arg(a1).arg(a2).arg(a3)</tt>, except that the strings <i>a1</i>, <i>a2</i> and <i>a3</i> are replaced in one pass.</p>
<h3 class="fn"><a name="arg-4" />QString QString.arg (<i>self</i>, int, int&#160;<i>fieldWidth</i>&#160;=&#160;0, int&#160;<i>base</i>&#160;=&#160;10, QChar&#160;<i>fillChar</i>&#160;=&#160;QLatin1Char(' '))</h3><p>This function overloads <a href="qstring.html#arg">arg</a>().</p>
<p>This is the same as calling <tt>str.arg(a1).arg(a2).arg(a3).arg(a4)</tt>, except that the strings <i>a1</i>, <i>a2</i>, <i>a3</i> and <i>a4</i> are replaced in one pass.</p>
<h3 class="fn"><a name="arg-5" />QString QString.arg (<i>self</i>, QString, int&#160;<i>fieldWidth</i>&#160;=&#160;0, QChar&#160;<i>fillChar</i>&#160;=&#160;QLatin1Char(' '))</h3><p>This function overloads <a href="qstring.html#arg">arg</a>().</p>
<p>This is the same as calling <tt>str.arg(a1).arg(a2).arg(a3).arg(a4).arg(a5)</tt>, except that the strings <i>a1</i>, <i>a2</i>, <i>a3</i>, <i>a4</i>, and <i>a5</i> are replaced in one pass.</p>
<h3 class="fn"><a name="arg-6" />QString QString.arg (<i>self</i>, QString, QString)</h3><p>This function overloads <a href="qstring.html#arg">arg</a>().</p>
<p>This is the same as calling <tt>str.arg(a1).arg(a2).arg(a3).arg(a4).arg(a5).arg(a6))</tt>, except that the strings <i>a1</i>, <i>a2</i>, <i>a3</i>, <i>a4</i>, <i>a5</i>, and <i>a6</i> are replaced in one pass.</p>
<h3 class="fn"><a name="arg-7" />QString QString.arg (<i>self</i>, QString, QString, QString)</h3><p>This function overloads <a href="qstring.html#arg">arg</a>().</p>
<p>This is the same as calling <tt>str.arg(a1).arg(a2).arg(a3).arg(a4).arg(a5).arg(a6).arg(a7)</tt>, except that the strings <i>a1</i>, <i>a2</i>, <i>a3</i>, <i>a4</i>, <i>a5</i>, <i>a6</i>, and <i>a7</i> are replaced in one pass.</p>
<h3 class="fn"><a name="arg-8" />QString QString.arg (<i>self</i>, QString, QString, QString, QString)</h3><p>This function overloads <a href="qstring.html#arg">arg</a>().</p>
<p>This is the same as calling <tt>str.arg(a1).arg(a2).arg(a3).arg(a4).arg(a5).arg(a6).arg(a7).arg(a8)</tt>, except that the strings <i>a1</i>, <i>a2</i>, <i>a3</i>, <i>a4</i>, <i>a5</i>, <i>a6</i>, <i>a7</i>, and <i>a8</i> are replaced in one pass.</p>
<h3 class="fn"><a name="arg-9" />QString QString.arg (<i>self</i>, QString, QString, QString, QString, QString)</h3><p>This function overloads <a href="qstring.html#arg">arg</a>().</p>
<p>This is the same as calling <tt>str.arg(a1).arg(a2).arg(a3).arg(a4).arg(a5).arg(a6).arg(a7).arg(a8).arg(a9)</tt>, except that the strings <i>a1</i>, <i>a2</i>, <i>a3</i>, <i>a4</i>, <i>a5</i>, <i>a6</i>, <i>a7</i>, <i>a8</i>, and <i>a9</i> are replaced in one pass.</p>
<h3 class="fn"><a name="arg-10" />QString QString.arg (<i>self</i>, QString, QString, QString, QString, QString, QString)</h3><p>This function overloads <a href="qstring.html#arg">arg</a>().</p>
<p>The <i>a</i> argument is expressed in base <i>base</i>, which is 10 by default and must be between 2 and 36. For bases other than 10, <i>a</i> is treated as an unsigned integer.</p>
<p><i>fieldWidth</i> specifies the minimum amount of space that <i>a</i> is padded to and filled with the character <i>fillChar</i>. A positive value produces right-aligned text; a negative value produces left-aligned text.</p>
<p>The '%' can be followed by an 'L', in which case the sequence is replaced with a localized representation of <i>a</i>. The conversion uses the default locale, set by <a href="qlocale.html#setDefault">QLocale.setDefault</a>(). If no default locale was specified, the "C" locale is used. The 'L' flag is ignored if <i>base</i> is not 10.</p>
<pre>     QString str;
     str = QString("Decimal 63 is %1 in hexadecimal")
             .arg(63, 0, 16);
     <span class="comment">// str == "Decimal 63 is 3f in hexadecimal"</span>

     QLocale.setDefault(QLocale(QLocale.English, QLocale.UnitedStates));
     str = QString("%1 %L2 %L3")
             .arg(12345)
             .arg(12345)
             .arg(12345, 0, 16);
     <span class="comment">// str == "12345 12,345 3039"</span></pre>
<p>If <i>fillChar</i> is '0' (the number 0, ASCII 48), the locale's zero is used. For negative numbers, zero padding might appear before the minus sign.</p>
<h3 class="fn"><a name="arg-11" />QString QString.arg (<i>self</i>, QString, QString, QString, QString, QString, QString, QString)</h3><p>This function overloads <a href="qstring.html#arg">arg</a>().</p>
<p>The <i>base</i> argument specifies the base to use when converting the integer <i>a</i> into a string. The base must be between 2 and 36.</p>
<p>If <i>fillChar</i> is '0' (the number 0, ASCII 48), the locale's zero is used. For negative numbers, zero padding might appear before the minus sign.</p>
<h3 class="fn"><a name="arg-12" />QString QString.arg (<i>self</i>, QString, QString, QString, QString, QString, QString, QString, QString)</h3><p>This function overloads <a href="qstring.html#arg">arg</a>().</p>
<p><i>fieldWidth</i> specifies the minimum amount of space that <i>a</i> is padded to and filled with the character <i>fillChar</i>. A positive value produces right-aligned text; a negative value produces left-aligned text.</p>
<p>The <i>a</i> argument is expressed in the given <i>base</i>, which is 10 by default and must be between 2 and 36.</p>
<p>The '%' can be followed by an 'L', in which case the sequence is replaced with a localized representation of <i>a</i>. The conversion uses the default locale. The default locale is determined from the system's locale settings at application startup. It can be changed using <a href="qlocale.html#setDefault">QLocale.setDefault</a>(). The 'L' flag is ignored if <i>base</i> is not 10.</p>
<pre>     QString str;
     str = QString("Decimal 63 is %1 in hexadecimal")
             .arg(63, 0, 16);
     <span class="comment">// str == "Decimal 63 is 3f in hexadecimal"</span>

     QLocale.setDefault(QLocale(QLocale.English, QLocale.UnitedStates));
     str = QString("%1 %L2 %L3")
             .arg(12345)
             .arg(12345)
             .arg(12345, 0, 16);
     <span class="comment">// str == "12345 12,345 3039"</span></pre>
<p>If <i>fillChar</i> is '0' (the number 0, ASCII 48), the locale's zero is used. For negative numbers, zero padding might appear before the minus sign.</p>
<h3 class="fn"><a name="arg-13" />QString QString.arg (<i>self</i>, QString, QString, QString, QString, QString, QString, QString, QString, QString)</h3><p>This function overloads <a href="qstring.html#arg">arg</a>().</p>
<p><i>fieldWidth</i> specifies the minimum amount of space that <i>a</i> is padded to and filled with the character <i>fillChar</i>. A positive value produces right-aligned text; a negative value produces left-aligned text.</p>
<p>The <i>base</i> argument specifies the base to use when converting the integer <i>a</i> to a string. The base must be between 2 and 36, with 8 giving octal, 10 decimal, and 16 hexadecimal numbers.</p>
<p>If <i>fillChar</i> is '0' (the number 0, ASCII 48), the locale's zero is used. For negative numbers, zero padding might appear before the minus sign.</p>
<h3 class="fn"><a name="at" />QChar QString.at (<i>self</i>, int)</h3><p>Returns the character at the given index <i>position</i> in the string.</p>
<p>The <i>position</i> must be a valid index position in the string (i.e., 0 &lt;= <i>position</i> &lt; <a href="qstring.html#size">size</a>()).</p>
<p>See also <a href="qstring.html#operator-5b-5d">operator[]</a>().</p>
<a name="//apple_ref/cpp/instm/QString/begin" />
<h3 class="fn"><a name="capacity" />int QString.capacity (<i>self</i>)</h3><p>Returns the maximum number of characters that can be stored in the string without forcing a reallocation.</p>
<p>The sole purpose of this function is to provide a means of fine tuning <a href="qstring.html">QString</a>'s memory usage. In general, you will rarely ever need to call this function. If you want to know how many characters are in the string, call <a href="qstring.html#size">size</a>().</p>
<p>See also <a href="qstring.html#reserve">reserve</a>() and <a href="qstring.html#squeeze">squeeze</a>().</p>
<a name="//apple_ref/cpp/instm/QString/chop" />
<h3 class="fn"><a name="chop" />QString.chop (<i>self</i>, int)</h3><p>Removes <i>n</i> characters from the end of the string.</p>
<p>If <i>n</i> is greater than <a href="qstring.html#size">size</a>(), the result is an empty string.</p>
<p>Example:</p>
<pre>     QString str("LOGOUT\r\n");
     str.chop(2);
     <span class="comment">// str == "LOGOUT"</span></pre>
<p>If you want to remove characters from the <i>beginning</i> of the string, use <a href="qstring.html#remove">remove</a>() instead.</p>
<p>See also <a href="qstring.html#truncate">truncate</a>(), <a href="qstring.html#resize">resize</a>(), and <a href="qstring.html#remove">remove</a>().</p>
<a name="//apple_ref/cpp/instm/QString/clear" />
<h3 class="fn"><a name="clear" />QString.clear (<i>self</i>)</h3><p>Clears the contents of the string and makes it empty.</p>
<p>See also <a href="qstring.html#resize">resize</a>() and <a href="qstring.html#isEmpty">isEmpty</a>().</p>
<a name="//apple_ref/cpp/clm/QString/compare" />
<h3 class="fn"><a name="compare" />int QString.compare (<i>self</i>, QString)</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>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>Case sensitive comparison is based exclusively on the numeric Unicode values of the characters and is very fast, but is not what a human would expect. Consider sorting user-visible strings with <a href="qstring.html#localeAwareCompare">localeAwareCompare</a>().</p>
<pre>     int x = QString.compare("aUtO", "AuTo", Qt.CaseInsensitive);  <span class="comment">// x == 0</span>
     int y = QString.compare("auto", "Car", Qt.CaseSensitive);     <span class="comment">// y &gt; 0</span>
     int z = QString.compare("auto", "Car", Qt.CaseInsensitive);   <span class="comment">// z &lt; 0</span></pre>
<p>This function was introduced in Qt 4.2.</p>
<p>See also <a href="qstring.html#operator-eq-eq">operator==</a>(), <a href="qstring.html#operator-lt">operator&lt;</a>(), and <a href="qstring.html#operator-gt">operator&gt;</a>().</p>
<h3 class="fn"><a name="compare-2" />int QString.compare (<i>self</i>, QString, <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitivity</a>&#160;<i>cs</i>)</h3><p>This function overloads <a href="qstring.html#compare">compare</a>().</p>
<p>Performs a case sensitive compare of <i>s1</i> and <i>s2</i>.</p>
<h3 class="fn"><a name="compare-3" />int QString.compare (<i>self</i>, <a href="qlatin1string.html">QLatin1String</a>, <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitivity</a>&#160;<i>cs</i>&#160;=&#160;Qt.CaseSensitive)</h3><p>This function overloads <a href="qstring.html#compare">compare</a>().</p>
<p>Performs a comparison of <i>s1</i> and <i>s2</i>, using the case sensitivity setting <i>cs</i>.</p>
<p>This function was introduced in Qt 4.2.</p>
<h3 class="fn"><a name="compare-4" />int QString.compare (<i>self</i>, QStringRef, <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitivity</a>&#160;<i>cs</i>&#160;=&#160;Qt.CaseSensitive)</h3><p>This function overloads <a href="qstring.html#compare">compare</a>().</p>
<p>Performs a comparison of <i>s1</i> and <i>s2</i>, using the case sensitivity setting <i>cs</i>.</p>
<p>This function was introduced in Qt 4.2.</p>
<h3 class="fn"><a name="compare-5" />int QString.compare (QString, QString)</h3><p>This function overloads <a href="qstring.html#compare">compare</a>().</p>
<p>Lexically 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 other string.</p>
<p>Equivalent to <tt>compare(*this, other)</tt>.</p>
<h3 class="fn"><a name="compare-6" />int QString.compare (QString, QString, <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitivity</a>&#160;<i>cs</i>)</h3><p>This function overloads <a href="qstring.html#compare">compare</a>().</p>
<p>Same as compare(*this, <i>other</i>, <i>cs</i>).</p>
<p>This function was introduced in Qt 4.2.</p>
<h3 class="fn"><a name="compare-7" />int QString.compare (QString, <a href="qlatin1string.html">QLatin1String</a>, <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitivity</a>&#160;<i>cs</i>&#160;=&#160;Qt.CaseSensitive)</h3><p>This function overloads <a href="qstring.html#compare">compare</a>().</p>
<p>Same as compare(*this, <i>other</i>, <i>cs</i>).</p>
<p>This function was introduced in Qt 4.2.</p>
<h3 class="fn"><a name="compare-8" />int QString.compare (<a href="qlatin1string.html">QLatin1String</a>, QString, <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitivity</a>&#160;<i>cs</i>&#160;=&#160;Qt.CaseSensitive)</h3><p>This function overloads <a href="qstring.html#compare">compare</a>().</p>
<p>Compares the string reference, <i>ref</i>, with the string and returns an integer less than, equal to, or greater than zero if the string is less than, equal to, or greater than <i>ref</i>.</p>
<h3 class="fn"><a name="compare-9" />int QString.compare (QString, QStringRef, <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitivity</a>&#160;<i>cs</i>&#160;=&#160;Qt.CaseSensitive)</h3><p>This function overloads <a href="qstring.html#compare">compare</a>().</p>
<a name="//apple_ref/cpp/instm/QString/constBegin" />
<h3 class="fn"><a name="contains" />bool QString.contains (<i>self</i>, QString, <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitivity</a>&#160;<i>cs</i>&#160;=&#160;Qt.CaseSensitive)</h3><p>Returns true if this string 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>Example:</p>
<pre>     QString str = "Peter Pan";
     str.contains("peter", Qt.CaseInsensitive);    <span class="comment">// returns true</span></pre>
<p>See also <a href="qstring.html#indexOf">indexOf</a>() and <a href="qstring.html#count">count</a>().</p>
<h3 class="fn"><a name="contains-2" />bool QString.contains (<i>self</i>, <a href="qregexp.html">QRegExp</a>)</h3><h3 class="fn"><a name="count" />int QString.count (<i>self</i>)</h3><p>Returns the number of (potentially overlapping) occurrences of the string <i>str</i> in this string.</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>See also <a href="qstring.html#contains">contains</a>() and <a href="qstring.html#indexOf">indexOf</a>().</p>
<h3 class="fn"><a name="count-2" />int QString.count (<i>self</i>, QString, <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitivity</a>&#160;<i>cs</i>&#160;=&#160;Qt.CaseSensitive)</h3><p>This function overloads <a href="qstring.html#count">count</a>().</p>
<p>Returns the number of occurrences of character <i>ch</i> in the string.</p>
<h3 class="fn"><a name="count-3" />int QString.count (<i>self</i>, <a href="qregexp.html">QRegExp</a>)</h3><p>This function overloads <a href="qstring.html#count">count</a>().</p>
<p>Returns the number of times the regular expression <i>rx</i> matches in the string.</p>
<p>This function counts overlapping matches, so in the example below, there are four instances of "ana" or "ama":</p>
<pre>     QString str = "banana and panama";
     str.count(QRegExp("a[nm]a"));    <span class="comment">// returns 4</span></pre>
<h3 class="fn"><a name="endsWith" />bool QString.endsWith (<i>self</i>, QString, <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitivity</a>&#160;<i>cs</i>&#160;=&#160;Qt.CaseSensitive)</h3><p>Returns true if the string ends with <i>s</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>
<pre>     QString str = "Bananas";
     str.endsWith("anas");         <span class="comment">// returns true</span>
     str.endsWith("pple");         <span class="comment">// returns false</span></pre>
<p>See also <a href="qstring.html#startsWith">startsWith</a>().</p>
<h3 class="fn"><a name="endsWith-2" />bool QString.endsWith (<i>self</i>, <a href="qlatin1string.html">QLatin1String</a>, <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitivity</a>&#160;<i>cs</i>&#160;=&#160;Qt.CaseSensitive)</h3><h3 class="fn"><a name="fill" />QString QString.fill (<i>self</i>, QChar, int&#160;<i>size</i>&#160;=&#160;-1)</h3><p>Sets every character in the string to character <i>ch</i>. If <i>size</i> is different from -1 (default), the string is resized to <i>size</i> beforehand.</p>
<p>Example:</p>
<pre>     QString str = "Berlin";
     str.fill('z');
     <span class="comment">// str == "zzzzzz"</span>

     str.fill('A', 2);
     <span class="comment">// str == "AA"</span></pre>
<p>See also <a href="qstring.html#resize">resize</a>().</p>
<a name="//apple_ref/cpp/clm/QString/fromAscii" />
<h3 class="fn"><a name="fromAscii" />QString QString.fromAscii (str, int&#160;<i>size</i>&#160;=&#160;-1)</h3><p>Returns a <a href="qstring.html">QString</a> initialized with the first <i>size</i> characters of the 8-bit ASCII string <i>str</i>.</p>
<p>If <i>size</i> is -1 (default), it is taken to be qstrlen(<i>str</i>).</p>
<p>If a codec has been set using <a href="qtextcodec.html#setCodecForCStrings">QTextCodec.setCodecForCStrings</a>(), it is used to convert <i>str</i> to Unicode; otherwise this function does the same as <a href="qstring.html#fromLatin1">fromLatin1</a>().</p>
<p>See also <a href="qstring.html#toAscii">toAscii</a>(), <a href="qstring.html#fromLatin1">fromLatin1</a>(), <a href="qstring.html#fromUtf8">fromUtf8</a>(), and <a href="qstring.html#fromLocal8Bit">fromLocal8Bit</a>().</p>
<a name="//apple_ref/cpp/clm/QString/fromLatin1" />
<h3 class="fn"><a name="fromLatin1" />QString QString.fromLatin1 (str, int&#160;<i>size</i>&#160;=&#160;-1)</h3><p>Returns a <a href="qstring.html">QString</a> initialized with the first <i>size</i> characters of the Latin-1 string <i>str</i>.</p>
<p>If <i>size</i> is -1 (default), it is taken to be qstrlen(<i>str</i>).</p>
<p>See also <a href="qstring.html#toLatin1">toLatin1</a>(), <a href="qstring.html#fromAscii">fromAscii</a>(), <a href="qstring.html#fromUtf8">fromUtf8</a>(), and <a href="qstring.html#fromLocal8Bit">fromLocal8Bit</a>().</p>
<a name="//apple_ref/cpp/clm/QString/fromLocal8Bit" />
<h3 class="fn"><a name="fromLocal8Bit" />QString QString.fromLocal8Bit (str, int&#160;<i>size</i>&#160;=&#160;-1)</h3><p>Returns a <a href="qstring.html">QString</a> initialized with the first <i>size</i> characters of the 8-bit string <i>str</i>.</p>
<p>If <i>size</i> is -1 (default), it is taken to be qstrlen(<i>str</i>).</p>
<p><a href="qtextcodec.html#codecForLocale">QTextCodec.codecForLocale</a>() is used to perform the conversion from Unicode.</p>
<p>See also <a href="qstring.html#toLocal8Bit">toLocal8Bit</a>(), <a href="qstring.html#fromAscii">fromAscii</a>(), <a href="qstring.html#fromLatin1">fromLatin1</a>(), and <a href="qstring.html#fromUtf8">fromUtf8</a>().</p>
<a name="//apple_ref/cpp/clm/QString/fromRawData" />
<h3 class="fn"><a name="fromUtf8" />QString QString.fromUtf8 (str, int&#160;<i>size</i>&#160;=&#160;-1)</h3><p>Returns a <a href="qstring.html">QString</a> initialized with the first <i>size</i> bytes of the UTF-8 string <i>str</i>.</p>
<p>If <i>size</i> is -1 (default), it is taken to be qstrlen(<i>str</i>).</p>
<p>See also <a href="qstring.html#toUtf8">toUtf8</a>(), <a href="qstring.html#fromAscii">fromAscii</a>(), <a href="qstring.html#fromLatin1">fromLatin1</a>(), and <a href="qstring.html#fromLocal8Bit">fromLocal8Bit</a>().</p>
<a name="//apple_ref/cpp/clm/QString/fromUtf16" />
<h3 class="fn"><a name="indexOf" />int QString.indexOf (<i>self</i>, QString, int&#160;<i>from</i>&#160;=&#160;0, <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitivity</a>&#160;<i>cs</i>&#160;=&#160;Qt.CaseSensitive)</h3><p>Returns the index position of the first occurrence of the string <i>str</i> in this string, 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>Example:</p>
<pre>     QString x = "sticky question";
     QString y = "sti";
     x.indexOf(y);               <span class="comment">// returns 0</span>
     x.indexOf(y, 1);            <span class="comment">// returns 10</span>
     x.indexOf(y, 10);           <span class="comment">// returns 10</span>
     x.indexOf(y, 11);           <span class="comment">// returns -1</span></pre>
<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>See also <a href="qstring.html#lastIndexOf">lastIndexOf</a>(), <a href="qstring.html#contains">contains</a>(), and <a href="qstring.html#count">count</a>().</p>
<h3 class="fn"><a name="indexOf-2" />int QString.indexOf (<i>self</i>, <a href="qlatin1string.html">QLatin1String</a>, int&#160;<i>from</i>&#160;=&#160;0, <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitivity</a>&#160;<i>cs</i>&#160;=&#160;Qt.CaseSensitive)</h3><p>Returns the index position of the first occurrence of the string <i>str</i> in this string, 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>Example:</p>
<pre>     QString x = "sticky question";
     QString y = "sti";
     x.indexOf(y);               <span class="comment">// returns 0</span>
     x.indexOf(y, 1);            <span class="comment">// returns 10</span>
     x.indexOf(y, 10);           <span class="comment">// returns 10</span>
     x.indexOf(y, 11);           <span class="comment">// returns -1</span></pre>
<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.5.</p>
<p>See also <a href="qstring.html#lastIndexOf">lastIndexOf</a>(), <a href="qstring.html#contains">contains</a>(), and <a href="qstring.html#count">count</a>().</p>
<h3 class="fn"><a name="indexOf-3" />int QString.indexOf (<i>self</i>, <a href="qregexp.html">QRegExp</a>, int&#160;<i>from</i>&#160;=&#160;0)</h3><p>This function overloads <a href="qstring.html#indexOf">indexOf</a>().</p>
<p>Returns the index position of the first occurrence of the character <i>ch</i> in the string, searching forward from index position <i>from</i>. Returns -1 if <i>ch</i> could not be found.</p>
<h3 class="fn"><a name="insert" />QString QString.insert (<i>self</i>, int, QString)</h3><p>Inserts the string <i>str</i> at the given index <i>position</i> and returns a reference to this string.</p>
<p>Example:</p>
<pre>     QString str = "Meal";
     str.insert(1, QString("ontr"));
     <span class="comment">// str == "Montreal"</span></pre>
<p>If the given <i>position</i> is greater than <a href="qstring.html#size">size</a>(), the array is first extended using <a href="qstring.html#resize">resize</a>().</p>
<p>See also <a href="qstring.html#append">append</a>(), <a href="qstring.html#prepend">prepend</a>(), <a href="qstring.html#replace">replace</a>(), and <a href="qstring.html#remove">remove</a>().</p>
<h3 class="fn"><a name="insert-2" />QString QString.insert (<i>self</i>, int, <a href="qlatin1string.html">QLatin1String</a>)</h3><p>This function overloads <a href="qstring.html#insert">insert</a>().</p>
<p>Inserts the Latin-1 string <i>str</i> at the given index <i>position</i>.</p>
<h3 class="fn"><a name="isEmpty" />bool QString.isEmpty (<i>self</i>)</h3><p>Returns true if the string has no characters; otherwise returns false.</p>
<p>Example:</p>
<pre>     QString().isEmpty();            <span class="comment">// returns true</span>
     QString("").isEmpty();          <span class="comment">// returns true</span>
     QString("x").isEmpty();         <span class="comment">// returns false</span>
     QString("abc").isEmpty();       <span class="comment">// returns false</span></pre>
<p>See also <a href="qstring.html#size">size</a>().</p>
<a name="//apple_ref/cpp/instm/QString/isNull" />
<h3 class="fn"><a name="isNull" />bool QString.isNull (<i>self</i>)</h3><p>Returns true if this string is null; otherwise returns false.</p>
<p>Example:</p>
<pre>     QString().isNull();             <span class="comment">// returns true</span>
     QString("").isNull();           <span class="comment">// returns false</span>
     QString("abc").isNull();        <span class="comment">// returns false</span></pre>
<p>Qt makes a distinction between null strings and empty strings for historical reasons. For most applications, what matters is whether or not a string contains any data, and this can be determined using the <a href="qstring.html#isEmpty">isEmpty</a>() function.</p>
<p>See also <a href="qstring.html#isEmpty">isEmpty</a>().</p>
<a name="//apple_ref/cpp/instm/QString/lastIndexOf" />
<h3 class="fn"><a name="isRightToLeft" />bool QString.isRightToLeft (<i>self</i>)</h3><h3 class="fn"><a name="isSimpleText" />bool QString.isSimpleText (<i>self</i>)</h3><h3 class="fn"><a name="lastIndexOf" />int QString.lastIndexOf (<i>self</i>, QString, int&#160;<i>from</i>&#160;=&#160;-1, <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitivity</a>&#160;<i>cs</i>&#160;=&#160;Qt.CaseSensitive)</h3><p>Returns the index position of the last occurrence of the string <i>str</i> in this string, 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>Example:</p>
<pre>     QString x = "crazy azimuths";
     QString y = "az";
     x.lastIndexOf(y);           <span class="comment">// returns 6</span>
     x.lastIndexOf(y, 6);        <span class="comment">// returns 6</span>
     x.lastIndexOf(y, 5);        <span class="comment">// returns 2</span>
     x.lastIndexOf(y, 1);        <span class="comment">// returns -1</span></pre>
<p>See also <a href="qstring.html#indexOf">indexOf</a>(), <a href="qstring.html#contains">contains</a>(), and <a href="qstring.html#count">count</a>().</p>
<h3 class="fn"><a name="lastIndexOf-2" />int QString.lastIndexOf (<i>self</i>, <a href="qlatin1string.html">QLatin1String</a>, int&#160;<i>from</i>&#160;=&#160;-1, <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitivity</a>&#160;<i>cs</i>&#160;=&#160;Qt.CaseSensitive)</h3><p>Returns the index position of the last occurrence of the string <i>str</i> in this string, 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>Example:</p>
<pre>     QString x = "crazy azimuths";
     QString y = "az";
     x.lastIndexOf(y);           <span class="comment">// returns 6</span>
     x.lastIndexOf(y, 6);        <span class="comment">// returns 6</span>
     x.lastIndexOf(y, 5);        <span class="comment">// returns 2</span>
     x.lastIndexOf(y, 1);        <span class="comment">// returns -1</span></pre>
<p>This function was introduced in Qt 4.5.</p>
<p>See also <a href="qstring.html#indexOf">indexOf</a>(), <a href="qstring.html#contains">contains</a>(), and <a href="qstring.html#count">count</a>().</p>
<h3 class="fn"><a name="lastIndexOf-3" />int QString.lastIndexOf (<i>self</i>, <a href="qregexp.html">QRegExp</a>, int&#160;<i>from</i>&#160;=&#160;-1)</h3><p>This function overloads <a href="qstring.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>
<h3 class="fn"><a name="left" />QString QString.left (<i>self</i>, int)</h3><p>Returns a substring that contains the <i>n</i> leftmost characters of the string.</p>
<p>The entire string is returned if <i>n</i> is greater than <a href="qstring.html#size">size</a>() or less than zero.</p>
<pre>     QString x = "Pineapple";
     QString y = x.left(4);      <span class="comment">// y == "Pine"</span></pre>
<p>See also <a href="qstring.html#right">right</a>(), <a href="qstring.html#mid">mid</a>(), and <a href="qstring.html#startsWith">startsWith</a>().</p>
<a name="//apple_ref/cpp/instm/QString/leftJustified" />
<h3 class="fn"><a name="leftJustified" />QString QString.leftJustified (<i>self</i>, int, QChar&#160;<i>fillChar</i>&#160;=&#160;QLatin1Char(' '), bool&#160;<i>truncate</i>&#160;=&#160;False)</h3><p>Returns a string of size <i>width</i> that contains this string padded by the <i>fill</i> character.</p>
<p>If <i>truncate</i> is false and the <a href="qstring.html#size">size</a>() of the string is more than <i>width</i>, then the returned string is a copy of the string.</p>
<pre>     QString s = "apple";
     QString t = s.leftJustified(8, '.');    <span class="comment">// t == "apple..."</span></pre>
<p>If <i>truncate</i> is true and the <a href="qstring.html#size">size</a>() of the string is more than <i>width</i>, then any characters in a copy of the string after position <i>width</i> are removed, and the copy is returned.</p>
<pre>     QString str = "Pineapple";
     str = str.leftJustified(5, '.', true);    <span class="comment">// str == "Pinea"</span></pre>
<p>See also <a href="qstring.html#rightJustified">rightJustified</a>().</p>
<a name="//apple_ref/cpp/instm/QString/leftRef" />
<h3 class="fn"><a name="length" />int QString.length (<i>self</i>)</h3><p>Returns the number of characters in this string. Equivalent to <a href="qstring.html#size">size</a>().</p>
<p>See also <a class="compat" href="qstring-qt3.html#setLength">setLength</a>().</p>
<a name="//apple_ref/cpp/clm/QString/localeAwareCompare" />
<h3 class="fn"><a name="localeAwareCompare" />int QString.localeAwareCompare (<i>self</i>, QString)</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 since Qt 4.3, this function compares according the "Order for sorted lists" setting in the International prefereces panel.</p>
<p>See also <a href="qstring.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 QString.localeAwareCompare (<i>self</i>, QStringRef)</h3><p>This function overloads <a href="qstring.html#localeAwareCompare">localeAwareCompare</a>().</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>Same as <tt>localeAwareCompare(*this, other)</tt>.</p>
<p>This function was introduced in Qt 4.5.</p>
<h3 class="fn"><a name="localeAwareCompare-3" />int QString.localeAwareCompare (QString, QString)</h3><p>This function overloads <a href="qstring.html#localeAwareCompare">localeAwareCompare</a>().</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-4" />int QString.localeAwareCompare (QString, QStringRef)</h3><p>This function overloads <a href="qstring.html#localeAwareCompare">localeAwareCompare</a>().</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>Same as <tt>localeAwareCompare(*this, other)</tt>.</p>
<a name="//apple_ref/cpp/instm/QString/mid" />
<h3 class="fn"><a name="mid" />QString QString.mid (<i>self</i>, int, int&#160;<i>n</i>&#160;=&#160;-1)</h3><p>Returns a string that contains <i>n</i> characters of this string, starting at the specified <i>position</i> index.</p>
<p>Returns a null string if the <i>position</i> index exceeds the length of the string. If there are less than <i>n</i> characters available in the string starting at the given <i>position</i>, or if <i>n</i> is -1 (default), the function returns all characters that are available from the specified <i>position</i>.</p>
<p>Example:</p>
<pre>     QString x = "Nine pineapples";
     QString y = x.mid(5, 4);            <span class="comment">// y == "pine"</span>
     QString z = x.mid(5);               <span class="comment">// z == "pineapples"</span></pre>
<p>See also <a href="qstring.html#left">left</a>() and <a href="qstring.html#right">right</a>().</p>
<a name="//apple_ref/cpp/instm/QString/midRef" />
<h3 class="fn"><a name="normalized" />QString QString.normalized (<i>self</i>, <a href="qstring.html#NormalizationForm-enum">NormalizationForm</a>)</h3><p>Returns the string in the given Unicode normalization <i>mode</i>.</p>
<h3 class="fn"><a name="normalized-2" />QString QString.normalized (<i>self</i>, <a href="qstring.html#NormalizationForm-enum">NormalizationForm</a>, <a href="qchar.html#UnicodeVersion-enum">QChar.UnicodeVersion</a>)</h3><p>This is an overloaded function.</p>
<p>Returns the string in the given Unicode normalization <i>mode</i>, according to the given <i>version</i> of the Unicode standard.</p>
<a name="//apple_ref/cpp/clm/QString/number" />
<h3 class="fn"><a name="number" />QString QString.number (int, int&#160;<i>base</i>&#160;=&#160;10)</h3><p>Returns a string equivalent of the number <i>n</i> according to the specified <i>base</i>.</p>
<p>The base is 10 by default and must be between 2 and 36. For bases other than 10, <i>n</i> is treated as an unsigned integer.</p>
<pre>     long a = 63;
     QString s = QString.number(a, 16);             <span class="comment">// s == "3f"</span>
     QString t = QString.number(a, 16).toUpper();     <span class="comment">// t == "3F"</span></pre>
<p>See also <a href="qstring.html#setNum">setNum</a>().</p>
<h3 class="fn"><a name="number-2" />QString QString.number (float, str&#160;<i>format</i>&#160;=&#160;'g', int&#160;<i>precision</i>&#160;=&#160;6)</h3><p>Returns a string equivalent of the number <i>n</i>, formatted according to the specified <i>format</i> and <i>precision</i>. See <a href="qstring.html#argument-formats">Argument Formats</a> for details.</p>
<p>Unlike <a href="qlocale.html#toString">QLocale.toString</a>(), this function does not honor the user's locale settings.</p>
<p>See also <a href="qstring.html#setNum">setNum</a>() and <a href="qlocale.html#toString">QLocale.toString</a>().</p>
<h3 class="fn"><a name="number-3" />QString QString.number (int, int&#160;<i>base</i>&#160;=&#160;10)</h3><p>This is an overloaded function.</p>
<h3 class="fn"><a name="number-4" />QString QString.number (int, int&#160;<i>base</i>&#160;=&#160;10)</h3><p>This is an overloaded function.</p>
<h3 class="fn"><a name="prepend" />QString QString.prepend (<i>self</i>, QString)</h3><p>Prepends the string <i>str</i> to the beginning of this string and returns a reference to this string.</p>
<p>Example:</p>
<pre>     QString x = "ship";
     QString y = "air";
     x.prepend(y);
     <span class="comment">// x == "airship"</span></pre>
<p>See also <a href="qstring.html#append">append</a>() and <a href="qstring.html#insert">insert</a>().</p>
<h3 class="fn"><a name="prepend-2" />QString QString.prepend (<i>self</i>, <a href="qlatin1string.html">QLatin1String</a>)</h3><p>This function overloads <a href="qstring.html#prepend">prepend</a>().</p>
<p>Prepends the Latin-1 string <i>str</i> to this string.</p>
<h3 class="fn"><a name="prepend-3" />QString QString.prepend (<i>self</i>, <a href="qbytearray.html">QByteArray</a>)</h3><p>This function overloads <a href="qstring.html#prepend">prepend</a>().</p>
<p>Prepends the byte array <i>ba</i> to this string. The byte array is converted to Unicode using the <a href="qstring.html#fromAscii">fromAscii</a>() function.</p>
<p>You can disable this function by defining <tt>QT_NO_CAST_FROM_ASCII</tt> when you compile your applications. This can be useful if you want to ensure that all user-visible strings go through <a href="qobject.html#tr">QObject.tr</a>(), for example.</p>
<h3 class="fn"><a name="push_back" />QString.push_back (<i>self</i>, QString)</h3><p>This function is provided for STL compatibility, appending the given <i>other</i> string onto the end of this string. It is equivalent to <tt>append(other)</tt>.</p>
<p>See also <a href="qstring.html#append">append</a>().</p>
<h3 class="fn"><a name="push_front" />QString.push_front (<i>self</i>, QString)</h3><p>This function is provided for STL compatibility, prepending the given <i>other</i> string to the beginning of this string. It is equivalent to <tt>prepend(other)</tt>.</p>
<p>See also <a href="qstring.html#prepend">prepend</a>().</p>
<h3 class="fn"><a name="remove" />QString QString.remove (<i>self</i>, int, int)</h3><p>Removes <i>n</i> characters from the string, starting at the given <i>position</i> index, and returns a reference to the string.</p>
<p>If the specified <i>position</i> index is within the string, but <i>position</i> + <i>n</i> is beyond the end of the string, the string is truncated at the specified <i>position</i>.</p>
<pre>     QString s = "Montreal";
     s.remove(1, 4);
     <span class="comment">// s == "Meal"</span></pre>
<p>See also <a href="qstring.html#insert">insert</a>() and <a href="qstring.html#replace">replace</a>().</p>
<h3 class="fn"><a name="remove-2" />QString QString.remove (<i>self</i>, QString, <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitivity</a>&#160;<i>cs</i>&#160;=&#160;Qt.CaseSensitive)</h3><p>Removes every occurrence of the character <i>ch</i> in this string, and returns a reference to this string.</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>Example:</p>
<pre>     QString t = "Ali Baba";
     t.remove(QChar('a'), Qt.CaseInsensitive);
     <span class="comment">// t == "li Bb"</span></pre>
<p>This is the same as <tt>replace(ch, "", cs)</tt>.</p>
<p>See also <a href="qstring.html#replace">replace</a>().</p>
<h3 class="fn"><a name="remove-3" />QString QString.remove (<i>self</i>, <a href="qregexp.html">QRegExp</a>)</h3><p>Removes every occurrence of the given <i>str</i> string in this string, and returns a reference to this string.</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 is the same as <tt>replace(str, "", cs)</tt>.</p>
<p>See also <a href="qstring.html#replace">replace</a>().</p>
<h3 class="fn"><a name="repeated" />QString QString.repeated (<i>self</i>, int)</h3><p>Returns a copy of this string repeated the specified number of <i>times</i>.</p>
<p>If <i>times</i> is less than 1, an empty string is returned.</p>
<p>Example:</p>
<pre> QString str("ab");
 str.repeated(4);            <span class="comment">// returns "abababab"</span></pre>
<p>This function was introduced in Qt 4.5.</p>
<a name="//apple_ref/cpp/instm/QString/replace" />
<h3 class="fn"><a name="replace" />QString QString.replace (<i>self</i>, int, int, QString)</h3><p>Replaces <i>n</i> characters beginning at index <i>position</i> with the string <i>after</i> and returns a reference to this string.</p>
<p>Example:</p>
<pre>     QString x = "Say yes!";
     QString y = "no";
     x.replace(4, 3, y);
     <span class="comment">// x == "Say no</span>!"</pre>
<p>See also <a href="qstring.html#insert">insert</a>() and <a href="qstring.html#remove">remove</a>().</p>
<h3 class="fn"><a name="replace-2" />QString QString.replace (<i>self</i>, QString, QString, <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitivity</a>&#160;<i>cs</i>&#160;=&#160;Qt.CaseSensitive)</h3><h3 class="fn"><a name="replace-3" />QString QString.replace (<i>self</i>, <a href="qregexp.html">QRegExp</a>, QString)</h3><h3 class="fn"><a name="replace-4" />QString QString.replace (<i>self</i>, <a href="qlatin1string.html">QLatin1String</a>, <a href="qlatin1string.html">QLatin1String</a>, <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitivity</a>&#160;<i>cs</i>&#160;=&#160;Qt.CaseSensitive)</h3><h3 class="fn"><a name="replace-5" />QString QString.replace (<i>self</i>, <a href="qlatin1string.html">QLatin1String</a>, QString, <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitivity</a>&#160;<i>cs</i>&#160;=&#160;Qt.CaseSensitive)</h3><h3 class="fn"><a name="replace-6" />QString QString.replace (<i>self</i>, QString, <a href="qlatin1string.html">QLatin1String</a>, <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitivity</a>&#160;<i>cs</i>&#160;=&#160;Qt.CaseSensitive)</h3><p>This function overloads <a href="qstring.html#replace">replace</a>().</p>
<p>Replaces <i>n</i> characters beginning at index <i>position</i> with the first <i>size</i> characters of the <a href="qchar.html">QChar</a> array <i>unicode</i> and returns a reference to this string.</p>
<h3 class="fn"><a name="reserve" />QString.reserve (<i>self</i>, int)</h3><p>Attempts to allocate memory for at least <i>size</i> characters. If you know in advance how large the string will be, you can call this function, and if you resize the string often you are likely to get better performance. If <i>size</i> is an underestimate, the worst that will happen is that the <a href="qstring.html">QString</a> will be a bit slower.</p>
<p>The sole purpose of this function is to provide a means of fine tuning <a href="qstring.html">QString</a>'s memory usage. In general, you will rarely ever need to call this function. If you want to change the size of the string, call <a href="qstring.html#resize">resize</a>().</p>
<p>This function is useful for code that needs to build up a long string and wants to avoid repeated reallocation. In this example, we want to add to the string until some condition is true, and we're fairly sure that size is large enough to make a call to reserve() worthwhile:</p>
<pre>     QString result;
     int maxSize;
     bool condition;
     QChar nextChar;

     result.reserve(maxSize);

     while (condition)
         result.append(nextChar);

     result.squeeze();</pre>
<p>See also <a href="qstring.html#squeeze">squeeze</a>() and <a href="qstring.html#capacity">capacity</a>().</p>
<a name="//apple_ref/cpp/instm/QString/resize" />
<h3 class="fn"><a name="resize" />QString.resize (<i>self</i>, int)</h3><p>Sets the size of the string to <i>size</i> characters.</p>
<p>If <i>size</i> is greater than the current size, the string is extended to make it <i>size</i> characters long with the extra characters added to the end. The new characters are uninitialized.</p>
<p>If <i>size</i> is less than the current size, characters are removed from the end.</p>
<p>Example:</p>
<pre>     QString s = "Hello world";
     s.resize(5);
     <span class="comment">// s == "Hello"</span>

     s.resize(8);
     <span class="comment">// s == "Hello???" (where ? stands for any character)</span></pre>
<p>If you want to append a certain number of identical characters to the string, use <a href="qstring.html#operator-2b-eq">operator+=</a>() as follows rather than resize():</p>
<pre>     QString t = "Hello";
     t += QString(10, 'X');
     <span class="comment">// t == "HelloXXXXXXXXXX"</span></pre>
<p>If you want to expand the string so that it reaches a certain width and fill the new positions with a particular character, use the <a href="qstring.html#leftJustified">leftJustified</a>() function:</p>
<p>If <i>size</i> is negative, it is equivalent to passing zero.</p>
<pre>     QString r = "Hello";
     r = r.leftJustified(10, ' ');
     <span class="comment">// r == "Hello     "</span></pre>
<p>See also <a href="qstring.html#truncate">truncate</a>() and <a href="qstring.html#reserve">reserve</a>().</p>
<a name="//apple_ref/cpp/instm/QString/right" />
<h3 class="fn"><a name="right" />QString QString.right (<i>self</i>, int)</h3><p>Returns a substring that contains the <i>n</i> rightmost characters of the string.</p>
<p>The entire string is returned if <i>n</i> is greater than <a href="qstring.html#size">size</a>() or less than zero.</p>
<pre>     QString x = "Pineapple";
     QString y = x.right(5);      <span class="comment">// y == "apple"</span></pre>
<p>See also <a href="qstring.html#left">left</a>(), <a href="qstring.html#mid">mid</a>(), and <a href="qstring.html#endsWith">endsWith</a>().</p>
<a name="//apple_ref/cpp/instm/QString/rightJustified" />
<h3 class="fn"><a name="rightJustified" />QString QString.rightJustified (<i>self</i>, int, QChar&#160;<i>fillChar</i>&#160;=&#160;QLatin1Char(' '), bool&#160;<i>truncate</i>&#160;=&#160;False)</h3><p>Returns a string of <a href="qstring.html#size">size</a>() <i>width</i> that contains the <i>fill</i> character followed by the string. For example:</p>
<pre>     QString s = "apple";
     QString t = s.rightJustified(8, '.');    <span class="comment">// t == "...apple"</span></pre>
<p>If <i>truncate</i> is false and the <a href="qstring.html#size">size</a>() of the string is more than <i>width</i>, then the returned string is a copy of the string.</p>
<p>If <i>truncate</i> is true and the <a href="qstring.html#size">size</a>() of the string is more than <i>width</i>, then the resulting string is truncated at position <i>width</i>.</p>
<pre>     QString str = "Pineapple";
     str = str.rightJustified(5, '.', true);    <span class="comment">// str == "Pinea"</span></pre>
<p>See also <a href="qstring.html#leftJustified">leftJustified</a>().</p>
<a name="//apple_ref/cpp/instm/QString/rightRef" />
<h3 class="fn"><a name="section" />QString QString.section (<i>self</i>, QString, int, int&#160;<i>end</i>&#160;=&#160;-1, <a href="qstring-sectionflags.html">SectionFlags</a>&#160;<i>flags</i>&#160;=&#160;QString.SectionDefault)</h3><p>This function returns a section of the string.</p>
<p>This string is treated as a sequence of fields separated by the character, <i>sep</i>. The returned string consists of the fields from position <i>start</i> to position <i>end</i> inclusive. If <i>end</i> is not specified, all fields from position <i>start</i> to the end of the string are included. Fields are numbered 0, 1, 2, etc., counting from the left, and -1, -2, etc., counting from right to left.</p>
<p>The <i>flags</i> argument can be used to affect some aspects of the function's behavior, e.g. whether to be case sensitive, whether to skip empty fields and how to deal with leading and trailing separators; see <a href="qstring.html#SectionFlag-enum">SectionFlags</a>.</p>
<pre>     QString str;
     QString csv = "forename,middlename,surname,phone";
     QString path = "/usr/local/bin/myapp"; <span class="comment">// First field is empty</span>
     QString.SectionFlag flag = QString.SectionSkipEmpty;

     str = csv.section(',', 2, 2);   <span class="comment">// str == "surname"</span>
     str = path.section('/', 3, 4);  <span class="comment">// str == "bin/myapp"</span>
     str = path.section('/', 3, 3, flag); <span class="comment">// str == "myapp"</span></pre>
<p>If <i>start</i> or <i>end</i> is negative, we count fields from the right of the string, the right-most field being -1, the one from right-most field being -2, and so on.</p>
<pre>     str = csv.section(',', -3, -2);  <span class="comment">// str == "middlename,surname"</span>
     str = path.section('/', -1); <span class="comment">// str == "myapp"</span></pre>
<p>See also <a href="qstring.html#split">split</a>().</p>
<h3 class="fn"><a name="section-2" />QString QString.section (<i>self</i>, <a href="qregexp.html">QRegExp</a>, int, int&#160;<i>end</i>&#160;=&#160;-1, <a href="qstring-sectionflags.html">SectionFlags</a>&#160;<i>flags</i>&#160;=&#160;QString.SectionDefault)</h3><p>This function overloads <a href="qstring.html#section">section</a>().</p>
<pre>     QString str;
     QString data = "forename**middlename**surname**phone";

     str = data.section("**", 2, 2); <span class="comment">// str == "surname"</span>
     str = data.section("**", -3, -2); <span class="comment">// str == "middlename**surname"</span></pre>
<p>See also <a href="qstring.html#split">split</a>().</p>
<h3 class="fn"><a name="setNum" />QString QString.setNum (<i>self</i>, int, int&#160;<i>base</i>&#160;=&#160;10)</h3><p>Sets the string to the printed value of <i>n</i> in the specified <i>base</i>, and returns a reference to the string.</p>
<p>The base is 10 by default and must be between 2 and 36. For bases other than 10, <i>n</i> is treated as an unsigned integer.</p>
<pre>     QString str;
     str.setNum(1234);       <span class="comment">// str == "1234"</span></pre>
<p>The formatting always uses <a href="qlocale.html#Language-enum">QLocale.C</a>, i.e., English/UnitedStates. To get a localized string representation of a number, use <a href="qlocale.html#toString">QLocale.toString</a>() with the appropriate locale.</p>
<h3 class="fn"><a name="setNum-2" />QString QString.setNum (<i>self</i>, float, str&#160;<i>format</i>&#160;=&#160;'g', int&#160;<i>precision</i>&#160;=&#160;6)</h3><p>This is an overloaded function.</p>
<h3 class="fn"><a name="setNum-3" />QString QString.setNum (<i>self</i>, int, int&#160;<i>base</i>&#160;=&#160;10)</h3><p>This is an overloaded function.</p>
<h3 class="fn"><a name="setNum-4" />QString QString.setNum (<i>self</i>, int, int&#160;<i>base</i>&#160;=&#160;10)</h3><p>This is an overloaded function.</p>
<h3 class="fn"><a name="simplified" />QString QString.simplified (<i>self</i>)</h3><p>Returns a string that has whitespace removed from the start and the end, and that has each sequence of internal whitespace replaced with a single space.</p>
<p>Whitespace means any character for which <a href="qchar.html#isSpace">QChar.isSpace</a>() returns true. This includes the ASCII characters '\t', '\n', '\v', '\f', '\r', and ' '.</p>
<p>Example:</p>
<pre>     QString str = "  lots\t of\nwhitespace\r\n ";
     str = str.simplified();
     <span class="comment">// str == "lots of whitespace";</span></pre>
<p>See also <a href="qstring.html#trimmed">trimmed</a>().</p>
<a name="//apple_ref/cpp/instm/QString/size" />
<h3 class="fn"><a name="size" />int QString.size (<i>self</i>)</h3><p>Returns the number of characters in this string.</p>
<p>The last character in the string is at position size() - 1. In addition, <a href="qstring.html">QString</a> ensures that the character at position size() is always '\0', so that you can use the return value of <a href="qstring.html#data">data</a>() and <a href="qstring.html#constData">constData</a>() as arguments to functions that expect '\0'-terminated strings.</p>
<p>Example:</p>
<pre>     QString str = "World";
     int n = str.size();         <span class="comment">// n == 5</span>
     str.data()[0];              <span class="comment">// returns 'W'</span>
     str.data()[4];              <span class="comment">// returns 'd'</span>
     str.data()[5];              <span class="comment">// returns '\0'</span></pre>
<p>See also <a href="qstring.html#isEmpty">isEmpty</a>() and <a href="qstring.html#resize">resize</a>().</p>
<a name="//apple_ref/cpp/instm/QString/split" />
<h3 class="fn"><a name="split" />QStringList QString.split (<i>self</i>, QString, <a href="qstring.html#SplitBehavior-enum">SplitBehavior</a>&#160;<i>behavior</i>&#160;=&#160;QString.KeepEmptyParts, <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitivity</a>&#160;<i>cs</i>&#160;=&#160;Qt.CaseSensitive)</h3><p>Splits the string into substrings wherever <i>sep</i> occurs, and returns the list of those strings. If <i>sep</i> does not match anywhere in the string, split() returns a single-element list containing this string.</p>
<p><i>cs</i> specifies whether <i>sep</i> should be matched case sensitively or case insensitively.</p>
<p>If <i>behavior</i> is <a href="qstring.html#SplitBehavior-enum">QString.SkipEmptyParts</a>, empty entries don't appear in the result. By default, empty entries are kept.</p>
<p>Example:</p>
<pre>     QString str = "a,,b,c";

     QStringList list1 = str.split(",");
     <span class="comment">// list1: [ "a", "", "b", "c" ]</span>

     QStringList list2 = str.split(",", QString.SkipEmptyParts);
     <span class="comment">// list2: [ "a", "b", "c" ]</span></pre>
<p>See also <a href="qstringlist.html#join">QStringList.join</a>() and <a href="qstring.html#section">section</a>().</p>
<h3 class="fn"><a name="split-2" />QStringList QString.split (<i>self</i>, <a href="qregexp.html">QRegExp</a>, <a href="qstring.html#SplitBehavior-enum">SplitBehavior</a>&#160;<i>behavior</i>&#160;=&#160;QString.KeepEmptyParts)</h3><p>This is an overloaded function.</p>
<h3 class="fn"><a name="squeeze" />QString.squeeze (<i>self</i>)</h3><p>Releases any memory not required to store the character data.</p>
<p>The sole purpose of this function is to provide a means of fine tuning <a href="qstring.html">QString</a>'s memory usage. In general, you will rarely ever need to call this function.</p>
<p>See also <a href="qstring.html#reserve">reserve</a>() and <a href="qstring.html#capacity">capacity</a>().</p>
<a name="//apple_ref/cpp/instm/QString/startsWith" />
<h3 class="fn"><a name="startsWith" />bool QString.startsWith (<i>self</i>, QString, <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitivity</a>&#160;<i>cs</i>&#160;=&#160;Qt.CaseSensitive)</h3><p>Returns true if the string starts with <i>s</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>
<pre>     QString str = "Bananas";
     str.startsWith("Ban");     <span class="comment">// returns true</span>
     str.startsWith("Car");     <span class="comment">// returns false</span></pre>
<p>See also <a href="qstring.html#endsWith">endsWith</a>().</p>
<h3 class="fn"><a name="startsWith-2" />bool QString.startsWith (<i>self</i>, <a href="qlatin1string.html">QLatin1String</a>, <a href="qt.html#CaseSensitivity-enum">Qt.CaseSensitivity</a>&#160;<i>cs</i>&#160;=&#160;Qt.CaseSensitive)</h3><h3 class="fn"><a name="toAscii" /><a href="qbytearray.html">QByteArray</a> QString.toAscii (<i>self</i>)</h3><p>Returns an 8-bit ASCII 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="qstring.html#toLatin1">toLatin1</a>().</p>
<p>See also <a href="qstring.html#fromAscii">fromAscii</a>(), <a href="qstring.html#toLatin1">toLatin1</a>(), <a href="qstring.html#toUtf8">toUtf8</a>(), <a href="qstring.html#toLocal8Bit">toLocal8Bit</a>(), and <a href="qtextcodec.html">QTextCodec</a>.</p>
<a name="//apple_ref/cpp/instm/QString/toCaseFolded" />
<h3 class="fn"><a name="toCaseFolded" />QString QString.toCaseFolded (<i>self</i>)</h3><p>Returns the case folded equivalent of the string. For most Unicode characters this is the same as <a href="qstring.html#toLower">toLower</a>().</p>
<a name="//apple_ref/cpp/instm/QString/toDouble" />
<h3 class="fn"><a name="toDouble" />(float, bool&#160;<i>ok</i>) QString.toDouble (<i>self</i>)</h3><p>Returns the string converted to a <tt>double</tt> value.</p>
<p>Returns 0.0 if the conversion fails.</p>
<p>If a conversion error occurs, <tt>*</tt><i>ok</i> is set to false; otherwise <tt>*</tt><i>ok</i> is set to true.</p>
<pre>     QString str = "1234.56";
     double val = str.toDouble();   <span class="comment">// val == 1234.56</span></pre>
<p>Various string formats for floating point numbers can be converted to double values:</p>
<pre>     bool ok;
     double d;

     d = QString( "1234.56e-02" ).toDouble(&amp;ok); <span class="comment">// ok == true, d == 12.3456</span></pre>
<p>This function tries to interpret the string according to the current locale. The current locale is determined from the system at application startup and can be changed by calling <a href="qlocale.html#setDefault">QLocale.setDefault</a>(). If the string cannot be interpreted according to the current locale, this function falls back on the "C" locale.</p>
<pre>     QLocale.setDefault(QLocale.C);
     d = QString( "1234,56" ).toDouble(&amp;ok); <span class="comment">// ok == false</span>
     d = QString( "1234.56" ).toDouble(&amp;ok); <span class="comment">// ok == true, d == 1234.56</span>

     QLocale.setDefault(QLocale.German);
     d = QString( "1234,56" ).toDouble(&amp;ok); <span class="comment">// ok == true, d == 1234.56</span>
     d = QString( "1234.56" ).toDouble(&amp;ok); <span class="comment">// ok == true, d == 1234.56</span></pre>
<p>Due to the ambiguity between the decimal point and thousands group separator in various locales, this function does not handle thousands group separators. If you need to convert such numbers, see <a href="qlocale.html#toDouble">QLocale.toDouble</a>().</p>
<pre>     QLocale.setDefault(QLocale.C);
     d = QString( "1234,56" ).toDouble(&amp;ok); <span class="comment">// ok == false</span></pre>
<p>See also <a href="qstring.html#number">number</a>(), <a href="qlocale.html#setDefault">QLocale.setDefault</a>(), <a href="qlocale.html#toDouble">QLocale.toDouble</a>(), and <a href="qstring.html#trimmed">trimmed</a>().</p>
<a name="//apple_ref/cpp/instm/QString/toFloat" />
<h3 class="fn"><a name="toFloat" />(float, bool&#160;<i>ok</i>) QString.toFloat (<i>self</i>)</h3><p>Returns the string converted to a <tt>float</tt> value.</p>
<p>If a conversion error occurs, *<i>ok</i> is set to false; otherwise *<i>ok</i> is set to true. Returns 0.0 if the conversion fails.</p>
<p>Example:</p>
<pre>     QString str1 = "1234.56";
     str1.toFloat();             <span class="comment">// returns 1234.56</span>

     bool ok;
     QString str2 = "R2D2";
     str2.toFloat(&amp;ok);          <span class="comment">// returns 0.0, sets ok to false</span></pre>
<p>See also <a href="qstring.html#number">number</a>(), <a href="qstring.html#toDouble">toDouble</a>(), and <a href="qstring.html#toInt">toInt</a>().</p>
<a name="//apple_ref/cpp/instm/QString/toInt" />
<h3 class="fn"><a name="toInt" />(int, bool&#160;<i>ok</i>) QString.toInt (<i>self</i>, int&#160;<i>base</i>&#160;=&#160;10)</h3><p>Returns the string converted to an <tt>int</tt> using base <i>base</i>, which is 10 by default and must be between 2 and 36, or 0. Returns 0 if the conversion fails.</p>
<p>If a conversion error occurs, *<i>ok</i> is set to false; otherwise *<i>ok</i> is set to true.</p>
<p>If <i>base</i> is 0, the C language convention is used: If the string begins with "0x", base 16 is used; if the string begins with "0", base 8 is used; otherwise, base 10 is used.</p>
<p>Example:</p>
<pre>     QString str = "FF";
     bool ok;
     int hex = str.toInt(&amp;ok, 16);       <span class="comment">// hex == 255, ok == true</span>
     int dec = str.toInt(&amp;ok, 10);       <span class="comment">// dec == 0, ok == false</span></pre>
<p>See also <a href="qstring.html#number">number</a>(), <a href="qstring.html#toUInt">toUInt</a>(), and <a href="qstring.html#toDouble">toDouble</a>().</p>
<a name="//apple_ref/cpp/instm/QString/toLatin1" />
<h3 class="fn"><a name="toLatin1" /><a href="qbytearray.html">QByteArray</a> QString.toLatin1 (<i>self</i>)</h3><p>Returns a Latin-1 representation of the string as a <a href="qbytearray.html">QByteArray</a>. The returned byte array is undefined if the string contains non-Latin1 characters.</p>
<p>See also <a href="qstring.html#fromLatin1">fromLatin1</a>(), <a href="qstring.html#toAscii">toAscii</a>(), <a href="qstring.html#toUtf8">toUtf8</a>(), <a href="qstring.html#toLocal8Bit">toLocal8Bit</a>(), and <a href="qtextcodec.html">QTextCodec</a>.</p>
<a name="//apple_ref/cpp/instm/QString/toLocal8Bit" />
<h3 class="fn"><a name="toLocal8Bit" /><a href="qbytearray.html">QByteArray</a> QString.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.</p>
<p>See also <a href="qstring.html#fromLocal8Bit">fromLocal8Bit</a>(), <a href="qstring.html#toAscii">toAscii</a>(), <a href="qstring.html#toLatin1">toLatin1</a>(), <a href="qstring.html#toUtf8">toUtf8</a>(), and <a href="qtextcodec.html">QTextCodec</a>.</p>
<a name="//apple_ref/cpp/instm/QString/toLong" />
<h3 class="fn"><a name="toLong" />(int, bool&#160;<i>ok</i>) QString.toLong (<i>self</i>, int&#160;<i>base</i>&#160;=&#160;10)</h3><p>Returns the string converted to a <tt>long</tt> using base <i>base</i>, which is 10 by default and must be between 2 and 36, or 0. Returns 0 if the conversion fails.</p>
<p>If a conversion error occurs, *<i>ok</i> is set to false; otherwise *<i>ok</i> is set to true.</p>
<p>If <i>base</i> is 0, the C language convention is used: If the string begins with "0x", base 16 is used; if the string begins with "0", base 8 is used; otherwise, base 10 is used.</p>
<p>Example:</p>
<pre>     QString str = "FF";
     bool ok;

     long hex = str.toLong(&amp;ok, 16);     <span class="comment">// hex == 255, ok == true</span>
     long dec = str.toLong(&amp;ok, 10);     <span class="comment">// dec == 0, ok == false</span></pre>
<p>See also <a href="qstring.html#number">number</a>(), <a href="qstring.html#toULong">toULong</a>(), and <a href="qstring.html#toInt">toInt</a>().</p>
<a name="//apple_ref/cpp/instm/QString/toLongLong" />
<h3 class="fn"><a name="toLongLong" />(int, bool&#160;<i>ok</i>) QString.toLongLong (<i>self</i>, int&#160;<i>base</i>&#160;=&#160;10)</h3><p>Returns the string converted to a <tt>long long</tt> using base <i>base</i>, which is 10 by default and must be between 2 and 36, or 0. Returns 0 if the conversion fails.</p>
<p>If a conversion error occurs, *<i>ok</i> is set to false; otherwise *<i>ok</i> is set to true.</p>
<p>If <i>base</i> is 0, the C language convention is used: If the string begins with "0x", base 16 is used; if the string begins with "0", base 8 is used; otherwise, base 10 is used.</p>
<p>Example:</p>
<pre>     QString str = "FF";
     bool ok;

     long hex = str.toLongLong(&amp;ok, 16);      <span class="comment">// hex == 255, ok == true</span>
     long dec = str.toLongLong(&amp;ok, 10);      <span class="comment">// dec == 0, ok == false</span></pre>
<p>See also <a href="qstring.html#number">number</a>(), <a href="qstring.html#toULongLong">toULongLong</a>(), and <a href="qstring.html#toInt">toInt</a>().</p>
<a name="//apple_ref/cpp/instm/QString/toLower" />
<h3 class="fn"><a name="toLower" />QString QString.toLower (<i>self</i>)</h3><p>Returns a lowercase copy of the string.</p>
<pre>     QString str = "Qt by NOKIA";
     str = str.toLower();        <span class="comment">// str == "qt by nokia"</span></pre>
<p>See also <a href="qstring.html#toUpper">toUpper</a>().</p>
<a name="//apple_ref/cpp/instm/QString/toShort" />
<h3 class="fn"><a name="toShort" />(int, bool&#160;<i>ok</i>) QString.toShort (<i>self</i>, int&#160;<i>base</i>&#160;=&#160;10)</h3><p>Returns the string converted to a <tt>short</tt> using base <i>base</i>, which is 10 by default and must be between 2 and 36, or 0. Returns 0 if the conversion fails.</p>
<p>If a conversion error occurs, *<i>ok</i> is set to false; otherwise *<i>ok</i> is set to true.</p>
<p>If <i>base</i> is 0, the C language convention is used: If the string begins with "0x", base 16 is used; if the string begins with "0", base 8 is used; otherwise, base 10 is used.</p>
<p>Example:</p>
<pre>     QString str = "FF";
     bool ok;

     short hex = str.toShort(&amp;ok, 16);   <span class="comment">// hex == 255, ok == true</span>
     short dec = str.toShort(&amp;ok, 10);   <span class="comment">// dec == 0, ok == false</span></pre>
<p>See also <a href="qstring.html#number">number</a>(), <a href="qstring.html#toUShort">toUShort</a>(), and <a href="qstring.html#toInt">toInt</a>().</p>
<a name="//apple_ref/cpp/instm/QString/toStdString" />
<h3 class="fn"><a name="toUInt" />(int, bool&#160;<i>ok</i>) QString.toUInt (<i>self</i>, int&#160;<i>base</i>&#160;=&#160;10)</h3><p>Returns the string converted to an <tt>unsigned int</tt> using base <i>base</i>, which is 10 by default and must be between 2 and 36, or 0. Returns 0 if the conversion fails.</p>
<p>If a conversion error occurs, *<i>ok</i> is set to false; otherwise *<i>ok</i> is set to true.</p>
<p>If <i>base</i> is 0, the C language convention is used: If the string begins with "0x", base 16 is used; if the string begins with "0", base 8 is used; otherwise, base 10 is used.</p>
<p>Example:</p>
<pre>     QString str = "FF";
     bool ok;

     uint hex = str.toUInt(&amp;ok, 16);     <span class="comment">// hex == 255, ok == true</span>
     uint dec = str.toUInt(&amp;ok, 10);     <span class="comment">// dec == 0, ok == false</span></pre>
<p>See also <a href="qstring.html#number">number</a>() and <a href="qstring.html#toInt">toInt</a>().</p>
<a name="//apple_ref/cpp/instm/QString/toULong" />
<h3 class="fn"><a name="toULong" />(int, bool&#160;<i>ok</i>) QString.toULong (<i>self</i>, int&#160;<i>base</i>&#160;=&#160;10)</h3><p>Returns the string converted to an <tt>unsigned long</tt> using base <i>base</i>, which is 10 by default and must be between 2 and 36, or 0. Returns 0 if the conversion fails.</p>
<p>If a conversion error occurs, *<i>ok</i> is set to false; otherwise *<i>ok</i> is set to true.</p>
<p>If <i>base</i> is 0, the C language convention is used: If the string begins with "0x", base 16 is used; if the string begins with "0", base 8 is used; otherwise, base 10 is used.</p>
<p>Example:</p>
<pre>     QString str = "FF";
     bool ok;

     ulong hex = str.toULong(&amp;ok, 16);   <span class="comment">// hex == 255, ok == true</span>
     ulong dec = str.toULong(&amp;ok, 10);   <span class="comment">// dec == 0, ok == false</span></pre>
<p>See also <a href="qstring.html#number">number</a>().</p>
<a name="//apple_ref/cpp/instm/QString/toULongLong" />
<h3 class="fn"><a name="toULongLong" />(int, bool&#160;<i>ok</i>) QString.toULongLong (<i>self</i>, int&#160;<i>base</i>&#160;=&#160;10)</h3><p>Returns the string converted to an <tt>unsigned long long</tt> using base <i>base</i>, which is 10 by default and must be between 2 and 36, or 0. Returns 0 if the conversion fails.</p>
<p>If a conversion error occurs, *<i>ok</i> is set to false; otherwise *<i>ok</i> is set to true.</p>
<p>If <i>base</i> is 0, the C language convention is used: If the string begins with "0x", base 16 is used; if the string begins with "0", base 8 is used; otherwise, base 10 is used.</p>
<p>Example:</p>
<pre>     QString str = "FF";
     bool ok;

     unsigned long hex = str.toULongLong(&amp;ok, 16);    <span class="comment">// hex == 255, ok == true</span>
     unsigned long dec = str.toULongLong(&amp;ok, 10);    <span class="comment">// dec == 0, ok == false</span></pre>
<p>See also <a href="qstring.html#number">number</a>() and <a href="qstring.html#toLongLong">toLongLong</a>().</p>
<a name="//apple_ref/cpp/instm/QString/toUShort" />
<h3 class="fn"><a name="toUpper" />QString QString.toUpper (<i>self</i>)</h3><p>Returns an uppercase copy of the string.</p>
<pre>     QString str = "TeXt";
     str = str.toUpper();        <span class="comment">// str == "TEXT"</span></pre>
<p>See also <a href="qstring.html#toLower">toLower</a>().</p>
<a name="//apple_ref/cpp/instm/QString/toUtf8" />
<h3 class="fn"><a name="toUShort" />(int, bool&#160;<i>ok</i>) QString.toUShort (<i>self</i>, int&#160;<i>base</i>&#160;=&#160;10)</h3><p>Returns the string converted to an <tt>unsigned short</tt> using base <i>base</i>, which is 10 by default and must be between 2 and 36, or 0. Returns 0 if the conversion fails.</p>
<p>If a conversion error occurs, *<i>ok</i> is set to false; otherwise *<i>ok</i> is set to true.</p>
<p>If <i>base</i> is 0, the C language convention is used: If the string begins with "0x", base 16 is used; if the string begins with "0", base 8 is used; otherwise, base 10 is used.</p>
<p>Example:</p>
<pre>     QString str = "FF";
     bool ok;

     ushort hex = str.toUShort(&amp;ok, 16);     <span class="comment">// hex == 255, ok == true</span>
     ushort dec = str.toUShort(&amp;ok, 10);     <span class="comment">// dec == 0, ok == false</span></pre>
<p>See also <a href="qstring.html#number">number</a>() and <a href="qstring.html#toShort">toShort</a>().</p>
<a name="//apple_ref/cpp/instm/QString/toUcs4" />
<h3 class="fn"><a name="toUtf8" /><a href="qbytearray.html">QByteArray</a> QString.toUtf8 (<i>self</i>)</h3><p>Returns a UTF-8 representation of the string as a <a href="qbytearray.html">QByteArray</a>.</p>
<p>See also <a href="qstring.html#fromUtf8">fromUtf8</a>(), <a href="qstring.html#toAscii">toAscii</a>(), <a href="qstring.html#toLatin1">toLatin1</a>(), <a href="qstring.html#toLocal8Bit">toLocal8Bit</a>(), and <a href="qtextcodec.html">QTextCodec</a>.</p>
<a name="//apple_ref/cpp/instm/QString/toWCharArray" />
<h3 class="fn"><a name="trimmed" />QString QString.trimmed (<i>self</i>)</h3><p>Returns a string that has whitespace removed from the start and the end.</p>
<p>Whitespace means any character for which <a href="qchar.html#isSpace">QChar.isSpace</a>() returns true. This includes the ASCII characters '\t', '\n', '\v', '\f', '\r', and ' '.</p>
<p>Example:</p>
<pre>     QString str = "  lots\t of\nwhitespace\r\n ";
     str = str.trimmed();
     <span class="comment">// str == "lots\t of\nwhitespace"</span></pre>
<p>Unlike <a href="qstring.html#simplified">simplified</a>(), trimmed() leaves internal whitespace alone.</p>
<p>See also <a href="qstring.html#simplified">simplified</a>().</p>
<a name="//apple_ref/cpp/instm/QString/truncate" />
<h3 class="fn"><a name="truncate" />QString.truncate (<i>self</i>, int)</h3><p>Truncates the string at the given <i>position</i> index.</p>
<p>If the specified <i>position</i> index is beyond the end of the string, nothing happens.</p>
<p>Example:</p>
<pre>     QString str = "Vladivostok";
     str.truncate(4);
     <span class="comment">// str == "Vlad"</span></pre>
<p>If <i>position</i> is negative, it is equivalent to passing zero.</p>
<p>See also <a href="qstring.html#chop">chop</a>(), <a href="qstring.html#resize">resize</a>(), and <a href="qstring.html#left">left</a>().</p>
<a name="//apple_ref/cpp/instm/QString/unicode" />
<h3 class="fn"><a name="__add__" />QString QString.__add__ (<i>self</i>, QString)</h3><h3 class="fn"><a name="__add__-2" />QString QString.__add__ (<i>self</i>, <a href="qbytearray.html">QByteArray</a>)</h3><h3 class="fn"><a name="__contains__" />int QString.__contains__ (<i>self</i>, QString&#160;<i>s</i>)</h3><h3 class="fn"><a name="__eq__" />bool QString.__eq__ (<i>self</i>, QString)</h3><h3 class="fn"><a name="__eq__-2" />bool QString.__eq__ (<i>self</i>, <a href="qlatin1string.html">QLatin1String</a>)</h3><h3 class="fn"><a name="__eq__-3" />bool QString.__eq__ (<i>self</i>, <a href="qbytearray.html">QByteArray</a>)</h3><h3 class="fn"><a name="__eq__-4" />bool QString.__eq__ (<i>self</i>, QStringRef)</h3><h3 class="fn"><a name="__ge__" />bool QString.__ge__ (<i>self</i>, QString)</h3><h3 class="fn"><a name="__ge__-2" />bool QString.__ge__ (<i>self</i>, <a href="qlatin1string.html">QLatin1String</a>)</h3><h3 class="fn"><a name="__ge__-3" />bool QString.__ge__ (<i>self</i>, <a href="qbytearray.html">QByteArray</a>)</h3><h3 class="fn"><a name="__getitem__" />QString QString.__getitem__ (<i>self</i>, int&#160;<i>i</i>)</h3><h3 class="fn"><a name="__getitem__-2" />QString QString.__getitem__ (<i>self</i>, slice&#160;<i>slice</i>)</h3><h3 class="fn"><a name="__gt__" />bool QString.__gt__ (<i>self</i>, QString)</h3><h3 class="fn"><a name="__gt__-2" />bool QString.__gt__ (<i>self</i>, <a href="qlatin1string.html">QLatin1String</a>)</h3><h3 class="fn"><a name="__gt__-3" />bool QString.__gt__ (<i>self</i>, <a href="qbytearray.html">QByteArray</a>)</h3><h3 class="fn"><a name="__hash__" />int QString.__hash__ (<i>self</i>)</h3><h3 class="fn"><a name="__iadd__" />QString QString.__iadd__ (<i>self</i>, <a href="qchar.html#SpecialCharacter-enum">QChar.SpecialCharacter</a>)</h3><h3 class="fn"><a name="__iadd__-2" />QString QString.__iadd__ (<i>self</i>, QString)</h3><h3 class="fn"><a name="__iadd__-3" />QString QString.__iadd__ (<i>self</i>, <a href="qlatin1string.html">QLatin1String</a>)</h3><h3 class="fn"><a name="__iadd__-4" />QString QString.__iadd__ (<i>self</i>, <a href="qbytearray.html">QByteArray</a>)</h3><h3 class="fn"><a name="__imul__" />QString QString.__imul__ (<i>self</i>, int&#160;<i>m</i>)</h3><h3 class="fn"><a name="__le__" />bool QString.__le__ (<i>self</i>, QString)</h3><h3 class="fn"><a name="__le__-2" />bool QString.__le__ (<i>self</i>, <a href="qlatin1string.html">QLatin1String</a>)</h3><h3 class="fn"><a name="__le__-3" />bool QString.__le__ (<i>self</i>, <a href="qbytearray.html">QByteArray</a>)</h3><h3 class="fn"><a name="__len__" /> QString.__len__ (<i>self</i>)</h3><h3 class="fn"><a name="__lt__" />bool QString.__lt__ (<i>self</i>, QString)</h3><h3 class="fn"><a name="__lt__-2" />bool QString.__lt__ (<i>self</i>, <a href="qlatin1string.html">QLatin1String</a>)</h3><h3 class="fn"><a name="__lt__-3" />bool QString.__lt__ (<i>self</i>, <a href="qbytearray.html">QByteArray</a>)</h3><h3 class="fn"><a name="__mul__" />QString QString.__mul__ (<i>self</i>, int&#160;<i>m</i>)</h3><h3 class="fn"><a name="__ne__" />bool QString.__ne__ (<i>self</i>, QString)</h3><h3 class="fn"><a name="__ne__-2" />bool QString.__ne__ (<i>self</i>, <a href="qlatin1string.html">QLatin1String</a>)</h3><h3 class="fn"><a name="__ne__-3" />bool QString.__ne__ (<i>self</i>, <a href="qbytearray.html">QByteArray</a>)</h3><h3 class="fn"><a name="__ne__-4" />bool QString.__ne__ (<i>self</i>, QStringRef)</h3><h3 class="fn"><a name="__repr__" />str QString.__repr__ (<i>self</i>)</h3><h3 class="fn"><a name="__str__" />str QString.__str__ (<i>self</i>)</h3><h3 class="fn"><a name="__unicode__" />unicode QString.__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&#160;4.7.4 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> 2010</td><td align="right" width="25%">Qt&#160;4.6.3</td></tr></table></div></address></body></html>