<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <!-- /tmp/qt-3.0-reggie-28534/qt-x11-free-3.0.2/src/tools/qstring.cpp:12386 --> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>QString Class</title> <style type="text/css"><!-- h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; } a:link { color: #004faf; text-decoration: none } a:visited { color: #672967; text-decoration: none } body { background: #ffffff; color: black; } --></style> </head> <body> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr bgcolor="#E5E5E5"> <td valign=center> <a href="index.html"> <font color="#004faf">Home</font></a> | <a href="classes.html"> <font color="#004faf">All Classes</font></a> | <a href="mainclasses.html"> <font color="#004faf">Main Classes</font></a> | <a href="annotated.html"> <font color="#004faf">Annotated</font></a> | <a href="groups.html"> <font color="#004faf">Grouped Classes</font></a> | <a href="functions.html"> <font color="#004faf">Functions</font></a> </td> <td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QString Class Reference</h1> <p>The QString class provides an abstraction of Unicode text and the classic C null-terminated char array. <a href="#details">More...</a> <p><tt>#include <<a href="qstring-h.html">qstring.h</a>></tt> <p><a href="qstring-members.html">List of all member functions.</a> <h2>Public Members</h2> <ul> <li><div class=fn><a href="#QString"><b>QString</b></a> ()</div></li> <li><div class=fn><a href="#QString-2"><b>QString</b></a> ( QChar ch )</div></li> <li><div class=fn><a href="#QString-3"><b>QString</b></a> ( const QString & s )</div></li> <li><div class=fn><a href="#QString-4"><b>QString</b></a> ( const QByteArray & ba )</div></li> <li><div class=fn><a href="#QString-5"><b>QString</b></a> ( const QChar * unicode, uint length )</div></li> <li><div class=fn><a href="#QString-6"><b>QString</b></a> ( const char * str )</div></li> <li><div class=fn><a href="#~QString"><b>~QString</b></a> ()</div></li> <li><div class=fn>QString & <a href="#operator-eq-2"><b>operator=</b></a> ( const QString & s )</div></li> <li><div class=fn>QString & <a href="#operator-eq-3"><b>operator=</b></a> ( const char * str )</div></li> <li><div class=fn>QString & <a href="#operator-eq-4"><b>operator=</b></a> ( const QCString & cs )</div></li> <li><div class=fn>QString & <a href="#operator-eq"><b>operator=</b></a> ( QChar c )</div></li> <li><div class=fn>QString & <a href="#operator-eq-5"><b>operator=</b></a> ( char c )</div></li> <li><div class=fn>bool <a href="#isNull"><b>isNull</b></a> () const</div></li> <li><div class=fn>bool <a href="#isEmpty"><b>isEmpty</b></a> () const</div></li> <li><div class=fn>uint <a href="#length"><b>length</b></a> () const</div></li> <li><div class=fn>void <a href="#truncate"><b>truncate</b></a> ( uint newLen )</div></li> <li><div class=fn>QString & <a href="#fill"><b>fill</b></a> ( QChar c, int len = -1 )</div></li> <li><div class=fn>QString copy () const <em>(obsolete)</em></div></li> <li><div class=fn>QString <a href="#arg-2"><b>arg</b></a> ( long a, int fieldwidth = 0, int base = 10 ) const</div></li> <li><div class=fn>QString <a href="#arg-3"><b>arg</b></a> ( ulong a, int fieldwidth = 0, int base = 10 ) const</div></li> <li><div class=fn>QString <a href="#arg-4"><b>arg</b></a> ( int a, int fieldwidth = 0, int base = 10 ) const</div></li> <li><div class=fn>QString <a href="#arg-5"><b>arg</b></a> ( uint a, int fieldwidth = 0, int base = 10 ) const</div></li> <li><div class=fn>QString <a href="#arg-6"><b>arg</b></a> ( short a, int fieldwidth = 0, int base = 10 ) const</div></li> <li><div class=fn>QString <a href="#arg-7"><b>arg</b></a> ( ushort a, int fieldwidth = 0, int base = 10 ) const</div></li> <li><div class=fn>QString <a href="#arg-8"><b>arg</b></a> ( char a, int fieldwidth = 0 ) const</div></li> <li><div class=fn>QString <a href="#arg-9"><b>arg</b></a> ( QChar a, int fieldwidth = 0 ) const</div></li> <li><div class=fn>QString <a href="#arg"><b>arg</b></a> ( const QString & a, int fieldwidth = 0 ) const</div></li> <li><div class=fn>QString <a href="#arg-a"><b>arg</b></a> ( double a, int fieldwidth = 0, char fmt = 'g', int prec = -1 ) const</div></li> <li><div class=fn>QString & <a href="#sprintf"><b>sprintf</b></a> ( const char * cformat, ... )</div></li> <li><div class=fn>int <a href="#find-2"><b>find</b></a> ( QChar c, int index = 0, bool cs = TRUE ) const</div></li> <li><div class=fn>int <a href="#find-3"><b>find</b></a> ( char c, int index = 0, bool cs = TRUE ) const</div></li> <li><div class=fn>int <a href="#find-4"><b>find</b></a> ( const QString & str, int index = 0, bool cs = TRUE ) const</div></li> <li><div class=fn>int <a href="#find"><b>find</b></a> ( const QRegExp & rx, int index = 0 ) const</div></li> <li><div class=fn>int <a href="#find-5"><b>find</b></a> ( const char * str, int index = 0 ) const</div></li> <li><div class=fn>int <a href="#findRev-2"><b>findRev</b></a> ( QChar c, int index = -1, bool cs = TRUE ) const</div></li> <li><div class=fn>int <a href="#findRev-3"><b>findRev</b></a> ( char c, int index = -1, bool cs = TRUE ) const</div></li> <li><div class=fn>int <a href="#findRev-4"><b>findRev</b></a> ( const QString & str, int index = -1, bool cs = TRUE ) const</div></li> <li><div class=fn>int <a href="#findRev-5"><b>findRev</b></a> ( const QRegExp & rx, int index = -1 ) const</div></li> <li><div class=fn>int <a href="#findRev"><b>findRev</b></a> ( const char * str, int index = -1 ) const</div></li> <li><div class=fn>int <a href="#contains"><b>contains</b></a> ( QChar c, bool cs = TRUE ) const</div></li> <li><div class=fn>int <a href="#contains-2"><b>contains</b></a> ( char c, bool cs = TRUE ) const</div></li> <li><div class=fn>int <a href="#contains-3"><b>contains</b></a> ( const char * str, bool cs = TRUE ) const</div></li> <li><div class=fn>int <a href="#contains-4"><b>contains</b></a> ( const QString & str, bool cs = TRUE ) const</div></li> <li><div class=fn>int <a href="#contains-5"><b>contains</b></a> ( const QRegExp & rx ) const</div></li> <li><div class=fn>enum <a href="#SectionFlags-enum"><b>SectionFlags</b></a> { SectionDefault = 0x00, SectionSkipEmpty = 0x01, SectionIncludeLeadingSep = 0x02, SectionIncludeTrailingSep = 0x04, SectionCaseInsensitiveSeps = 0x08 }</div></li> <li><div class=fn>QString <a href="#section"><b>section</b></a> ( QChar sep, int start, int end = 0xffffffff, int flags = SectionDefault ) const</div></li> <li><div class=fn>QString <a href="#section-2"><b>section</b></a> ( char sep, int start, int end = 0xffffffff, int flags = SectionDefault ) const</div></li> <li><div class=fn>QString <a href="#section-3"><b>section</b></a> ( const char * sep, int start, int end = 0xffffffff, int flags = SectionDefault ) const</div></li> <li><div class=fn>QString <a href="#section-4"><b>section</b></a> ( const QString & sep, int start, int end = 0xffffffff, int flags = SectionDefault ) const</div></li> <li><div class=fn>QString <a href="#section-5"><b>section</b></a> ( const QRegExp & reg, int start, int end = 0xffffffff, int flags = SectionDefault ) const</div></li> <li><div class=fn>QString <a href="#left"><b>left</b></a> ( uint len ) const</div></li> <li><div class=fn>QString <a href="#right"><b>right</b></a> ( uint len ) const</div></li> <li><div class=fn>QString <a href="#mid"><b>mid</b></a> ( uint index, uint len = 0xffffffff ) const</div></li> <li><div class=fn>QString <a href="#leftJustify"><b>leftJustify</b></a> ( uint width, QChar fill = ' ', bool truncate = FALSE ) const</div></li> <li><div class=fn>QString <a href="#rightJustify"><b>rightJustify</b></a> ( uint width, QChar fill = ' ', bool truncate = FALSE ) const</div></li> <li><div class=fn>QString <a href="#lower"><b>lower</b></a> () const</div></li> <li><div class=fn>QString <a href="#upper"><b>upper</b></a> () const</div></li> <li><div class=fn>QString <a href="#stripWhiteSpace"><b>stripWhiteSpace</b></a> () const</div></li> <li><div class=fn>QString <a href="#simplifyWhiteSpace"><b>simplifyWhiteSpace</b></a> () const</div></li> <li><div class=fn>QString & <a href="#insert"><b>insert</b></a> ( uint index, const QString & s )</div></li> <li><div class=fn>QString & <a href="#insert-2"><b>insert</b></a> ( uint index, const QChar * s, uint len )</div></li> <li><div class=fn>QString & <a href="#insert-3"><b>insert</b></a> ( uint index, QChar c )</div></li> <li><div class=fn>QString & <a href="#insert-4"><b>insert</b></a> ( uint index, char c )</div></li> <li><div class=fn>QString & <a href="#append-2"><b>append</b></a> ( char ch )</div></li> <li><div class=fn>QString & <a href="#append-3"><b>append</b></a> ( QChar ch )</div></li> <li><div class=fn>QString & <a href="#append"><b>append</b></a> ( const QString & str )</div></li> <li><div class=fn>QString & <a href="#prepend-2"><b>prepend</b></a> ( char ch )</div></li> <li><div class=fn>QString & <a href="#prepend-3"><b>prepend</b></a> ( QChar ch )</div></li> <li><div class=fn>QString & <a href="#prepend"><b>prepend</b></a> ( const QString & s )</div></li> <li><div class=fn>QString & <a href="#remove"><b>remove</b></a> ( uint index, uint len )</div></li> <li><div class=fn>QString & <a href="#replace"><b>replace</b></a> ( uint index, uint len, const QString & s )</div></li> <li><div class=fn>QString & <a href="#replace-2"><b>replace</b></a> ( uint index, uint len, const QChar * s, uint slen )</div></li> <li><div class=fn>QString & <a href="#replace-3"><b>replace</b></a> ( const QRegExp & rx, const QString & str )</div></li> <li><div class=fn>short <a href="#toShort"><b>toShort</b></a> ( bool * ok = 0, int base = 10 ) const</div></li> <li><div class=fn>ushort <a href="#toUShort"><b>toUShort</b></a> ( bool * ok = 0, int base = 10 ) const</div></li> <li><div class=fn>int <a href="#toInt"><b>toInt</b></a> ( bool * ok = 0, int base = 10 ) const</div></li> <li><div class=fn>uint <a href="#toUInt"><b>toUInt</b></a> ( bool * ok = 0, int base = 10 ) const</div></li> <li><div class=fn>long <a href="#toLong"><b>toLong</b></a> ( bool * ok = 0, int base = 10 ) const</div></li> <li><div class=fn>ulong <a href="#toULong"><b>toULong</b></a> ( bool * ok = 0, int base = 10 ) const</div></li> <li><div class=fn>float <a href="#toFloat"><b>toFloat</b></a> ( bool * ok = 0 ) const</div></li> <li><div class=fn>double <a href="#toDouble"><b>toDouble</b></a> ( bool * ok = 0 ) const</div></li> <li><div class=fn>QString & <a href="#setNum-2"><b>setNum</b></a> ( short n, int base = 10 )</div></li> <li><div class=fn>QString & <a href="#setNum-3"><b>setNum</b></a> ( ushort n, int base = 10 )</div></li> <li><div class=fn>QString & <a href="#setNum-4"><b>setNum</b></a> ( int n, int base = 10 )</div></li> <li><div class=fn>QString & <a href="#setNum-5"><b>setNum</b></a> ( uint n, int base = 10 )</div></li> <li><div class=fn>QString & <a href="#setNum"><b>setNum</b></a> ( long n, int base = 10 )</div></li> <li><div class=fn>QString & <a href="#setNum-6"><b>setNum</b></a> ( ulong n, int base = 10 )</div></li> <li><div class=fn>QString & <a href="#setNum-7"><b>setNum</b></a> ( float n, char f = 'g', int prec = 6 )</div></li> <li><div class=fn>QString & <a href="#setNum-8"><b>setNum</b></a> ( double n, char f = 'g', int prec = 6 )</div></li> <li><div class=fn>void setExpand ( uint index, QChar c ) <em>(obsolete)</em></div></li> <li><div class=fn>QString & <a href="#operator+-eq"><b>operator+=</b></a> ( const QString & str )</div></li> <li><div class=fn>QString & <a href="#operator+-eq-2"><b>operator+=</b></a> ( QChar c )</div></li> <li><div class=fn>QString & <a href="#operator+-eq-3"><b>operator+=</b></a> ( char c )</div></li> <li><div class=fn>QChar <a href="#at"><b>at</b></a> ( uint i ) const</div></li> <li><div class=fn>QChar <a href="#operator[]"><b>operator[]</b></a> ( int i ) const</div></li> <li><div class=fn>QCharRef <a href="#at-2"><b>at</b></a> ( uint i )</div></li> <li><div class=fn>QCharRef <a href="#operator[]-2"><b>operator[]</b></a> ( int i )</div></li> <li><div class=fn>QChar <a href="#constref"><b>constref</b></a> ( uint i ) const</div></li> <li><div class=fn>QChar & <a href="#ref"><b>ref</b></a> ( uint i )</div></li> <li><div class=fn>const QChar * <a href="#unicode"><b>unicode</b></a> () const</div></li> <li><div class=fn>const char * ascii () const <em>(obsolete)</em></div></li> <li><div class=fn>const char * <a href="#latin1"><b>latin1</b></a> () const</div></li> <li><div class=fn>QCString <a href="#utf8"><b>utf8</b></a> () const</div></li> <li><div class=fn>QCString <a href="#local8Bit"><b>local8Bit</b></a> () const</div></li> <li><div class=fn>bool <a href="#operator!"><b>operator!</b></a> () const</div></li> <li><div class=fn><a href="#operator-const-char-*"><b>operator const char *</b></a> () const</div></li> <li><div class=fn>QString & <a href="#setUnicode"><b>setUnicode</b></a> ( const QChar * unicode, uint len )</div></li> <li><div class=fn>QString & <a href="#setUnicodeCodes"><b>setUnicodeCodes</b></a> ( const ushort * unicode_as_ushorts, uint len )</div></li> <li><div class=fn>QString & <a href="#setLatin1"><b>setLatin1</b></a> ( const char * str, int len = -1 )</div></li> <li><div class=fn>int <a href="#compare-2"><b>compare</b></a> ( const QString & s ) const</div></li> <li><div class=fn>int <a href="#localeAwareCompare-2"><b>localeAwareCompare</b></a> ( const QString & s ) const</div></li> <li><div class=fn>void <a href="#compose"><b>compose</b></a> ()</div></li> <li><div class=fn>const char * data () const <em>(obsolete)</em></div></li> <li><div class=fn>bool <a href="#startsWith"><b>startsWith</b></a> ( const QString & s ) const</div></li> <li><div class=fn>bool <a href="#endsWith"><b>endsWith</b></a> ( const QString & s ) const</div></li> <li><div class=fn>void <a href="#setLength"><b>setLength</b></a> ( uint newLen )</div></li> </ul> <h2>Static Public Members</h2> <ul> <li><div class=fn>QString <a href="#number"><b>number</b></a> ( long n, int base = 10 )</div></li> <li><div class=fn>QString <a href="#number-2"><b>number</b></a> ( ulong n, int base = 10 )</div></li> <li><div class=fn>QString <a href="#number-3"><b>number</b></a> ( int n, int base = 10 )</div></li> <li><div class=fn>QString <a href="#number-4"><b>number</b></a> ( uint n, int base = 10 )</div></li> <li><div class=fn>QString <a href="#number-5"><b>number</b></a> ( double n, char f = 'g', int prec = 6 )</div></li> <li><div class=fn>QString <a href="#fromLatin1"><b>fromLatin1</b></a> ( const char * chars, int len = -1 )</div></li> <li><div class=fn>QString <a href="#fromUtf8"><b>fromUtf8</b></a> ( const char * utf8, int len = -1 )</div></li> <li><div class=fn>QString <a href="#fromLocal8Bit"><b>fromLocal8Bit</b></a> ( const char * local8Bit, int len = -1 )</div></li> <li><div class=fn>int <a href="#compare"><b>compare</b></a> ( const QString & s1, const QString & s2 )</div></li> <li><div class=fn>int <a href="#localeAwareCompare"><b>localeAwareCompare</b></a> ( const QString & s1, const QString & s2 )</div></li> </ul> <h2>Related Functions</h2> <ul> <li><div class=fn>bool <a href="#operator-eq-eq"><b>operator==</b></a> ( const QString & s1, const QString & s2 )</div></li> <li><div class=fn>bool <a href="#operator-eq-eq-2"><b>operator==</b></a> ( const QString & s1, const char * s2 )</div></li> <li><div class=fn>bool <a href="#operator-eq-eq-3"><b>operator==</b></a> ( const char * s1, const QString & s2 )</div></li> <li><div class=fn>bool <a href="#operator!-eq"><b>operator!=</b></a> ( const QString & s1, const QString & s2 )</div></li> <li><div class=fn>bool <a href="#operator!-eq-2"><b>operator!=</b></a> ( const QString & s1, const char * s2 )</div></li> <li><div class=fn>bool <a href="#operator!-eq-3"><b>operator!=</b></a> ( const char * s1, const QString & s2 )</div></li> <li><div class=fn>bool <a href="#operator-lt"><b>operator<</b></a> ( const QString & s1, const char * s2 )</div></li> <li><div class=fn>bool <a href="#operator-lt-2"><b>operator<</b></a> ( const char * s1, const QString & s2 )</div></li> <li><div class=fn>bool <a href="#operator-lt-eq"><b>operator<=</b></a> ( const QString & s1, const char * s2 )</div></li> <li><div class=fn>bool <a href="#operator-lt-eq-2"><b>operator<=</b></a> ( const char * s1, const QString & s2 )</div></li> <li><div class=fn>bool <a href="#operator-gt"><b>operator></b></a> ( const QString & s1, const char * s2 )</div></li> <li><div class=fn>bool <a href="#operator-gt-2"><b>operator></b></a> ( const char * s1, const QString & s2 )</div></li> <li><div class=fn>bool <a href="#operator-gt-eq"><b>operator>=</b></a> ( const QString & s1, const char * s2 )</div></li> <li><div class=fn>bool <a href="#operator-gt-eq-2"><b>operator>=</b></a> ( const char * s1, const QString & s2 )</div></li> <li><div class=fn>const QString <a href="#operator+"><b>operator+</b></a> ( const QString & s1, const QString & s2 )</div></li> <li><div class=fn>const QString <a href="#operator+-2"><b>operator+</b></a> ( const QString & s1, const char * s2 )</div></li> <li><div class=fn>const QString <a href="#operator+-3"><b>operator+</b></a> ( const char * s1, const QString & s2 )</div></li> <li><div class=fn>const QString <a href="#operator+-4"><b>operator+</b></a> ( const QString & s, char c )</div></li> <li><div class=fn>const QString <a href="#operator+-5"><b>operator+</b></a> ( char c, const QString & s )</div></li> <li><div class=fn>QDataStream & <a href="#operator-lt-lt"><b>operator<<</b></a> ( QDataStream & s, const QString & str )</div></li> <li><div class=fn>QDataStream & <a href="#operator-gt-gt"><b>operator>></b></a> ( QDataStream & s, QString & str )</div></li> </ul> <hr><a name="details"></a><h2>Detailed Description</h2> <p> The QString class provides an abstraction of Unicode text and the classic C null-terminated char array. <p> <p> QString uses <a href="shclass.html">implicit sharing</a>, which makes it very efficient and easy to use. <p> In all of the QString methods that take <tt>const char *</tt> parameters, the <tt>const char *</tt> is interpreted as a classic C-style 0-terminated ASCII string. It is legal for the <tt>const char *</tt> parameter to be 0. If the <tt>const char *</tt> is not 0-terminated, the results are undefined. Functions that copy classic C strings into a QString will not copy the terminating 0 character. The <a href="qchar.html">QChar</a> array of the QString (as returned by <a href="#unicode">unicode</a>()) is generally not terminated by a null. <p> <!-- index QString::null --><a name="QString-null"></a>A QString that has not been assigned to anything is <em>null</em>, i.e. both the length and data pointer is 0. A QString that references the empty string ("", a single '\0' char) is <em>empty</em>. Both null and empty QStrings are legal parameters to the methods. Assigning <tt>(const char *) 0</tt> to QString gives a null QString. For convenience, <a href="qstring.html#QString-null">QString::null</a> is a null QString. When sorting, empty strings come first, followed by non-empty strings, followed by null strings. We recommend using <tt>if ( !str.isNull() )</tt> to check for a non-null string rather than <tt>if ( !str )</tt>; see <a href="#operator!">operator!</a>() for an explanation. <p> Note that if you find that you are mixing usage of <a href="qcstring.html">QCString</a>, QString, and <a href="qbytearray.html">QByteArray</a>, this causes lots of unnecessary copying and might indicate that the true nature of the data you are dealing with is uncertain. If the data is 0-terminated 8-bit data, use <a href="qcstring.html">QCString</a>; if it is unterminated (i.e. contains 0s) 8-bit data, use <a href="qbytearray.html">QByteArray</a>; if it is text, use QString. <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 <a href="qstringlist.html#split">QStringList::split</a>(), 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">regex</a> using <a href="qstringlist.html#grep">QStringList::grep</a>(). <p> <b>Note for C programmers</b> <p> Due to C++'s type system and the fact that QString is <a href="shclass.html#implicitly-shared">implicitly shared</a>, QStrings may be treated like ints or other simple base types. For example: <p> <pre> QString boolToString( bool b ) { QString result; if ( b ) result = "True"; else result = "False"; return result; } </pre> <p> The variable, result, is an auto variable allocated on the stack. When return is called, 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 <a href="shclass.html#implicit-sharing">implicit sharing</a>, see below.) <p> Throughout Qt's source code you will encounter QString usages like this: <pre> QString func( const QString& input ) { QString output = input; // process output return output; } </pre> <p> The 'copying' of input to output is almost as fast as copying a pointer because behind the scenes copying is achieved by incrementing a reference count. QString operates on a copy-on-write basis, only copying if an instance is actually changed. <p> If you wish to create a <a href="shclass.html#deep-copy">deep copy</a> of a QString without loosing any Unicode information then you should use the QString constructor that takes a <a href="qchar.html">QChar</a>*. For example: <p> <pre> QString a("abcd"); QString b( a.<a href="#unicode">unicode</a>(), b.<a href="#length">length</a>() ); </pre> <p> Otherwise, using the QString constructor that takes a const char* will be sufficent. For example: <p> <pre> QString a("abcd"); QString b( a.<a href="#latin1">latin1</a>() ); </pre> <p> <p>See also <a href="qchar.html">QChar</a>, <a href="qcstring.html">QCString</a>, <a href="qbytearray.html">QByteArray</a>, <a href="qconststring.html">QConstString</a>, <a href="shared.html">Implicitly and Explicitly Shared Classes</a>, <a href="text.html">Text Related Classes</a> and <a href="tools.html">Non-GUI Classes</a>. <hr><h2>Member Type Documentation</h2> <h3 class=fn><a name="SectionFlags-enum"></a>QString::SectionFlags</h3> <ul> <li><tt>QString::SectionDefault</tt> - Empty fields are counted, leading and trailing separators are not included, and the separator is compared case sensitively. <li><tt>QString::SectionSkipEmpty</tt> - Treat empty fields as if they don't exist, i.e. they are not considered as far as <em>start</em> and <em>end</em> are oncerned. <li><tt>QString::SectionIncludeLeadingSep</tt> - Include the leading separator (if any) in the result string. <li><tt>QString::SectionIncludeTrailingSep</tt> - Include the trailing separator (if any) in the result string. <li><tt>QString::SectionCaseInsensitiveSeps</tt> - Compare the separator case-insensitively. </ul><p> Any of the last four values can be OR-ed together to form a flag. <p> <p>See also <a href="#section">section</a>(). <hr><h2>Member Function Documentation</h2> <h3 class=fn><a name="QString"></a>QString::QString () </h3> <p> Constructs a null string. This is a string that has not been assigned to anything, i.e. both the length and data pointer is 0. <p> <p>See also <a href="#isNull">isNull</a>(). <h3 class=fn><a name="QString-2"></a>QString::QString ( <a href="qchar.html">QChar</a> ch ) </h3> Constructs a string giving it a length of one character, assigning it the character <em>ch</em>. <h3 class=fn><a name="QString-3"></a>QString::QString ( const <a href="qstring.html">QString</a> & s ) </h3> Constructs an <a href="shclass.html#implicitly-shared">implicitly shared</a> copy of <em>s</em>. This is instantaneous, since <a href="shclass.html#reference-counting">reference counting</a> is used. <h3 class=fn><a name="QString-4"></a>QString::QString ( const <a href="qbytearray.html">QByteArray</a> & ba ) </h3> Constructs a string that is a <a href="shclass.html#deep-copy">deep copy</a> of <em>ba</em> interpreted as a classic C string. <h3 class=fn><a name="QString-5"></a>QString::QString ( const <a href="qchar.html">QChar</a> * unicode, uint length ) </h3> Constructs a string that is a <a href="shclass.html#deep-copy">deep copy</a> of the first <em>length</em> characters in the <a href="qchar.html">QChar</a> array. <p> If <em>unicode</em> and <em>length</em> are 0, then a null string is created. <p> If only <em>unicode</em> is 0, the string is empty but has <em>length</em> characters of space preallocated - QString expands automatically anyway, but this may speed up some cases a little. We recommend using the plain constructor and <a href="#setLength">setLength</a>() for this purpose since it will result in more readable code. <p> <p>See also <a href="#isNull">isNull</a>() and <a href="#setLength">setLength</a>(). <h3 class=fn><a name="QString-6"></a>QString::QString ( const char * str ) </h3> Constructs a string that is a <a href="shclass.html#deep-copy">deep copy</a> of <em>str</em>, interpreted as a classic C string. <p> If <em>str</em> is 0, then a null string is created. <p> This is a cast constructor, but it is perfectly safe: converting a Latin1 const char* to QString preserves all the information. You can disable this constructor by defining QT_NO_CAST_ASCII when you compile your applications. You can also make QString objects by using <a href="#setLatin1">setLatin1</a>(), <a href="#fromLatin1">fromLatin1</a>(), <a href="#fromLocal8Bit">fromLocal8Bit</a>(), and <a href="#fromUtf8">fromUtf8</a>(). Or whatever encoding is appropriate for the 8-bit data you have. <p> <p>See also <a href="#isNull">isNull</a>(). <h3 class=fn><a name="~QString"></a>QString::~QString () </h3> <p> Destroys the string and frees the "real" string if this is the last copy of that string. <h3 class=fn><a href="qstring.html">QString</a> & <a name="append"></a>QString::append ( const <a href="qstring.html">QString</a> & str ) </h3> Appends <em>str</em> to the string and returns a reference to the result. <p> <pre> string = "Test"; string.append( "ing" ); // string == "Testing" </pre> <p> Equivalent to <a href="#operator+-eq">operator+=</a>(). <p>Example: <a href="dirview-example.html#x1696">dirview/dirview.cpp</a>. <h3 class=fn><a href="qstring.html">QString</a> & <a name="append-2"></a>QString::append ( char ch ) </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Appends character <em>ch</em> to the string and returns a reference to the result. <p> Equivalent to <a href="#operator+-eq">operator+=</a>(). <h3 class=fn><a href="qstring.html">QString</a> & <a name="append-3"></a>QString::append ( <a href="qchar.html">QChar</a> ch ) </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Appends character <em>ch</em> to the string and returns a reference to the result. <p> Equivalent to <a href="#operator+-eq">operator+=</a>(). <h3 class=fn><a href="qstring.html">QString</a> <a name="arg"></a>QString::arg ( const <a href="qstring.html">QString</a> & a, int fieldwidth = 0 ) const </h3> <p> This function will return a string that replaces the lowest occurrence of <tt>%i</tt> (<tt>i</tt> being '1' or '2' or ... or '9') with <em>a</em>. <p> The <em>fieldwidth</em> value specifies the minimum amount of space that <em>a</em> is padded to. A positive value will produce right-aligned text, whereas a negative value will produce left-aligned text. <p> <pre> QString firstName( "Joe" ); QString lastName( "Bloggs" ); QString fullName; fullName = <a href="#QString">QString</a>( "First name is '%1', last name is '%2'" ) .arg( firstName ) .arg( lastName ); // fullName == First name is 'Joe', last name is 'Bloggs' </pre> <p> <b>Warning:</b> If you use <a href="#arg">arg</a>() to construct "real" sentences like the one shown in the examples above, then this may cause problems with translation (when you use the tr() function). <p> If there is no <tt>%i</tt> pattern, a warning message (<a href="qapplication.html#qWarning">qWarning</a>()) is outputted and the text is appended at the end of the string. This is error recovery done by the function and should not occur in correct code. <p> <p>See also <a href="qobject.html#tr">QObject::tr</a>(). <h3 class=fn><a href="qstring.html">QString</a> <a name="arg-2"></a>QString::arg ( long a, int fieldwidth = 0, int base = 10 ) const </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> The <em>fieldwidth</em> value specifies the minimum amount of space that <em>a</em> is padded to. A positive value will produce a right-aligned number, whereas a negative value will produce a left-aligned number. <p> <em>a</em> is expressed in base <em>base</em>, which is 10 by default and must be between 2 and 36. <p> <pre> QString str; str = <a href="#QString">QString</a>( "Decimal 63 is %1 in hexadecimal" ) .arg( 63, 0, 16 ); // str == "Decimal 63 is 3f in hexadecimal" </pre> <h3 class=fn><a href="qstring.html">QString</a> <a name="arg-3"></a>QString::arg ( ulong a, int fieldwidth = 0, int base = 10 ) const </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> <em>a</em> is expressed in base <em>base</em>, which is 10 by default and must be between 2 and 36. <h3 class=fn><a href="qstring.html">QString</a> <a name="arg-4"></a>QString::arg ( int a, int fieldwidth = 0, int base = 10 ) const </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> <em>a</em> is expressed in base <em>base</em>, which is 10 by default and must be between 2 and 36. <h3 class=fn><a href="qstring.html">QString</a> <a name="arg-5"></a>QString::arg ( uint a, int fieldwidth = 0, int base = 10 ) const </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> <em>a</em> is expressed in base <em>base</em>, which is 10 by default and must be between 2 and 36. <h3 class=fn><a href="qstring.html">QString</a> <a name="arg-6"></a>QString::arg ( short a, int fieldwidth = 0, int base = 10 ) const </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> <em>a</em> is expressed in base <em>base</em>, which is 10 by default and must be between 2 and 36. <h3 class=fn><a href="qstring.html">QString</a> <a name="arg-7"></a>QString::arg ( ushort a, int fieldwidth = 0, int base = 10 ) const </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> <em>a</em> is expressed in base <em>base</em>, which is 10 by default and must be between 2 and 36. <h3 class=fn><a href="qstring.html">QString</a> <a name="arg-8"></a>QString::arg ( char a, int fieldwidth = 0 ) const </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> <em>a</em> is assumed to be in the Latin1 character set. <h3 class=fn><a href="qstring.html">QString</a> <a name="arg-9"></a>QString::arg ( <a href="qchar.html">QChar</a> a, int fieldwidth = 0 ) const </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> <h3 class=fn><a href="qstring.html">QString</a> <a name="arg-a"></a>QString::arg ( double a, int fieldwidth = 0, char fmt = 'g', int prec = -1 ) const </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> <a name="arg-formats"></a> <p> Argument <em>a</em> is formatted according to the <em>fmt</em> format specified, which is <tt>g</tt> by default and can be any of the following: <p> <ul> <li> <tt>e</tt> - format as [-]9.9e[+|-]999 <li> <tt>E</tt> - format as [-]9.9E[+|-]999 <li> <tt>f</tt> - format as [-]9.9 <li> <tt>g</tt> - use <tt>e</tt> or <tt>f</tt> format, whichever is the most concise <li> <tt>G</tt> - use <tt>E</tt> or <tt>f</tt> format, whichever is the most concise </ul> <p> In all cases the number of digits after the decimal point is equal to the precision specified in <em>prec</em>. <p> <pre> double d = 12.34; QString ds = <a href="#QString">QString</a>( "'E' format, precision 3, gives %1" ) .arg( d, 0, 'E', 3 ); // ds == "1.234E+001" </pre> <h3 class=fn>const char * <a name="ascii"></a>QString::ascii () const </h3> <b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code. <p> This function simply calls <a href="#latin1">latin1</a>() and returns the result. <p>Example: <a href="networkprotocol-example.html#x955">network/networkprotocol/nntp.cpp</a>. <h3 class=fn><a href="qchar.html">QChar</a> <a name="at"></a>QString::at ( uint i ) const </h3> <p> Returns the character at index <em>i</em>, or 0 if <em>i</em> is beyond the length of the string. <p> <pre> const QString string( "abcdefgh" ); <a href="qchar.html">QChar</a> ch = string.<a href="#at">at</a>( 4 ); // ch == 'e' </pre> <p> If the QString is not const (i.e. const QString) or const& (i.e. const QString &), then the non-const overload of <a href="#at">at</a>() will be used instead. <h3 class=fn><a href="qcharref.html">QCharRef</a> <a name="at-2"></a>QString::at ( uint i ) </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> The function returns a reference to the character at index <em>i</em>. The resulting reference can then be assigned to, or used immediately, but it will become invalid once further modifications are made to the original string. <p> If <em>i</em> is beyond the length of the string then the string is expanded with QChar::null. <h3 class=fn>int <a name="compare"></a>QString::compare ( const <a href="qstring.html">QString</a> & s1, const <a href="qstring.html">QString</a> & s2 )<tt> [static]</tt> </h3> <p> Lexically compares <em>s1</em> with <em>s2</em> and returns an integer less than, equal to, or greater than zero if <em>s1</em> is less than, equal to, or greater than <em>s2</em>. <p> The 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-interface strings with <a href="#localeAwareCompare">QString::localeAwareCompare</a>(). <p> <pre> int a = QString::<a href="#compare">compare</a>( "def", "abc" ); // a > 0 int b = QString::<a href="#compare">compare</a>( "abc", "def" ); // b < 0 int c = QString::<a href="#compare">compare</a>(" abc", "abc" ); // c == 0 </pre> <h3 class=fn>int <a name="compare-2"></a>QString::compare ( const <a href="qstring.html">QString</a> & s ) const </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Lexically compares this string with <em>s</em> and returns an integer less than, equal to, or greater than zero if it is less than, equal to, or greater than <em>s</em>. <h3 class=fn>void <a name="compose"></a>QString::compose () </h3> Note that this function is not supported in Qt 3.0 and is merely for experimental and illustrative purposes. It is mainly of interest to those experimenting with Arabic and other composition-rich texts. <p> Applies possible ligatures to a QString. Useful when composition-rich text requires rendering with glyph-poor fonts, but it also makes compositions such as <a href="qchar.html">QChar</a>(0x0041) ('A') and QChar(0x0308) (Unicode accent diaresis), giving QChar(0x00c4) (German A Umlaut). <h3 class=fn><a href="qchar.html">QChar</a> <a name="constref"></a>QString::constref ( uint i ) const </h3> <p> Returns the <a href="qchar.html">QChar</a> at index <em>i</em> by value. <p> Equivalent to <a href="#at">at</a>(<em>i</em>). <p> <p>See also <a href="#ref">ref</a>(). <h3 class=fn>int <a name="contains"></a>QString::contains ( <a href="qchar.html">QChar</a> c, bool cs = TRUE ) const </h3> Returns the number of times the character <em>c</em> occurs in the string. <p> If <em>cs</em> is TRUE then the match is case sensitive. If <em>cs</em> is FALSE, then the match is case insensitive. <p> <pre> QString string( "Trolltech and Qt" ); int i = string.<a href="#contains">contains</a>( 't', FALSE ); // i == 3 </pre> <p>Examples: <a href="fileiconview-example.html#x1581">fileiconview/qfileiconview.cpp</a> and <a href="mdi-example.html#x1172">mdi/application.cpp</a>. <h3 class=fn>int <a name="contains-2"></a>QString::contains ( char c, bool cs = TRUE ) const </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> <h3 class=fn>int <a name="contains-3"></a>QString::contains ( const char * str, bool cs = TRUE ) const </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Returns the number of times the string <em>str</em> occurs in the string. <p> If <em>cs</em> is TRUE then the match is case sensitive. If <em>cs</em> is FALSE, then the match is case insensitive. <h3 class=fn>int <a name="contains-4"></a>QString::contains ( const <a href="qstring.html">QString</a> & str, bool cs = TRUE ) const </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Returns the number of times <em>str</em> occurs in the string. <p> The match is case sensitive if <em>cs</em> is TRUE or case insensitive if <em>cs</em> if FALSE. <p> This function counts overlapping strings, so in the example below, there are two instances of "ana" in "bananas". <p> <pre> QString str( "bananas" ); int i = str.<a href="#contains">contains</a>( "ana" ); // i == 2 </pre> <p> <p>See also <a href="#findRev">findRev</a>(). <h3 class=fn>int <a name="contains-5"></a>QString::contains ( const <a href="qregexp.html">QRegExp</a> & rx ) const </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Returns the number of times the regexp, <em>rx</em>, occurs in the string. <p> This function counts overlapping occurrences, so in the example below, there are four instances of "ana" or "ama". <p> <pre> QString str = "banana and panama"; <a href="qregexp.html">QRegExp</a> rxp = QRegExp( "a[nm]a", TRUE, FALSE ); int i = str.<a href="#contains">contains</a>( rxp ); // i == 4 </pre> <p> <p>See also <a href="#find">find</a>() and <a href="#findRev">findRev</a>(). <h3 class=fn><a href="qstring.html">QString</a> <a name="copy"></a>QString::copy () const </h3> <p> <b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code. <p> In Qt 2.0 and later, all calls to this function are needless. Just remove them. <h3 class=fn>const char * <a name="data"></a>QString::data () const </h3> <p> <b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code. <p> Returns a pointer to a 0-terminated classic C string. <p> In Qt 1.x, this returned a char* allowing direct manipulation of the string as a sequence of bytes. In Qt 2.x where QString is a Unicode string, char* conversion constructs a temporary string, and hence direct character operations are meaningless. <h3 class=fn>bool <a name="endsWith"></a>QString::endsWith ( const <a href="qstring.html">QString</a> & s ) const </h3> Returns TRUE if the string ends with <em>s</em>; otherwise it returns FALSE. <p> <p>See also <a href="#startsWith">startsWith</a>(). <h3 class=fn><a href="qstring.html">QString</a> & <a name="fill"></a>QString::fill ( <a href="qchar.html">QChar</a> c, int len = -1 ) </h3> Fills the string with <em>len</em> characters of value <em>c</em>, and returns a reference to the string. <p> If <em>len</em> is negative (the default), the current string length is used. <p> <pre> QString str; str.<a href="#fill">fill</a>( 'g', 5 ); // string == "gggggg" </pre> <h3 class=fn>int <a name="find"></a>QString::find ( const <a href="qregexp.html">QRegExp</a> & rx, int index = 0 ) const </h3> Finds the first occurrence of the constant <a href="qregexp.html#regular-expression">regular expression</a> <em>rx</em>, starting at position <em>index</em>. If <em>index</em> is -1, the search starts at the last character; if -2, at the next to last character and so on. (See <a href="#findRev">findRev</a>() for searching backwards.) <p> Returns the position of the first occurrence of <em>rx</em> or -1 if <em>rx</em> was not found. <p> <pre> QString string( "bananas" ); int i = string.<a href="#find">find</a>( QRegExp("an"), 0 ); // i == 1 </pre> <p> <p>See also <a href="#findRev">findRev</a>(), <a href="#replace">replace</a>() and <a href="#contains">contains</a>(). <p>Example: <a href="mail-example.html#x980">network/mail/smtp.cpp</a>. <h3 class=fn>int <a name="find-2"></a>QString::find ( <a href="qchar.html">QChar</a> c, int index = 0, bool cs = TRUE ) const </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Finds the first occurrence of the character <em>c</em>, starting at position <em>index</em>. If <em>index</em> is -1, the search starts at the last character; if -2, at the next to last character and so on. (See <a href="#findRev">findRev</a>() for searching backwards.) <p> If <em>cs</em> is TRUE, then the search is case sensitive. If <em>cs</em> is FALSE, then the search is case insensitive. <p> Returns the position of <em>c</em> or -1 if <em>c</em> could not be found. <h3 class=fn>int <a name="find-3"></a>QString::find ( char c, int index = 0, bool cs = TRUE ) const </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Find character <em>c</em> starting from position <em>index</em>. If <em>cs</em> is TRUE then the match is case sensitive. If <em>cs</em> is FALSE, then the match is case insensitive. <h3 class=fn>int <a name="find-4"></a>QString::find ( const <a href="qstring.html">QString</a> & str, int index = 0, bool cs = TRUE ) const </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Finds the first occurrence of the string <em>str</em>, starting at position <em>index</em>. If <em>index</em> is -1, the search starts at the last character, if it is -2, at the next to last character and so on. (See <a href="#findRev">findRev</a>() for searching backwards.) <p> The search is case sensitive if <em>cs</em> is TRUE or case insensitive if <em>cs</em> is FALSE. <p> Returns the position of <em>str</em> or -1 if <em>str</em> could not be found. <h3 class=fn>int <a name="find-5"></a>QString::find ( const char * str, int index = 0 ) const </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Equivalent to <a href="#find">find</a>(QString(<em>str</em>), <em>index</em>). <h3 class=fn>int <a name="findRev"></a>QString::findRev ( const char * str, int index = -1 ) const </h3> <p> Equivalent to <a href="#findRev">findRev</a>(QString(<em>str</em>), <em>index</em>). <h3 class=fn>int <a name="findRev-2"></a>QString::findRev ( <a href="qchar.html">QChar</a> c, int index = -1, bool cs = TRUE ) const </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Finds the first occurrence of the character <em>c</em>, starting at position <em>index</em> and searching backwards. If the index is -1, the search starts at the last character, if it is -2, at the next to last character and so on. <p> Returns the position of <em>c</em> or -1 if <em>c</em> could not be found. <p> If <em>cs</em> is TRUE then the search is case sensitive. If <em>cs</em> is FALSE then the search is case insensitive. <p> <pre> QString string( "bananas" ); int i = string.<a href="#findRev">findRev</a>( 'a' ); // i == 5 </pre> <h3 class=fn>int <a name="findRev-3"></a>QString::findRev ( char c, int index = -1, bool cs = TRUE ) const </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Find character <em>c</em> starting from position <em>index</em> and working backwards. If <em>cs</em> is TRUE then the match is case sensitive. If <em>cs</em> is FALSE, then the match is case insensitive. <h3 class=fn>int <a name="findRev-4"></a>QString::findRev ( const <a href="qstring.html">QString</a> & str, int index = -1, bool cs = TRUE ) const </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Finds the first occurrence of the string <em>str</em>, starting at position <em>index</em> and searching backwards. If the index is -1, the search starts at the last character, if it is -2, at the next to last character and so on. <p> Returns the position of <em>str</em> or -1 if <em>str</em> could not be found. <p> If <em>cs</em> is TRUE then the search is case sensitive. If <em>cs</em> is FALSE then the search is case insensitive. <p> <pre> QString string("bananas"); int i = string.<a href="#findRev">findRev</a>( "ana" ); // i == 3 </pre> <h3 class=fn>int <a name="findRev-5"></a>QString::findRev ( const <a href="qregexp.html">QRegExp</a> & rx, int index = -1 ) const </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Finds the first occurrence of the regexp <em>rx</em>, starting at position <em>index</em> and searching backwards. If the index is -1, the search starts at the last character, if it is -2, at the next to last character and so on. (See <a href="#findRev">findRev</a>() for searching backwards.) <p> Returns the position of <em>rx</em> or -1 if <em>rx</em> could not be found. <p> <pre> QString string( "bananas" ); int i = string.<a href="#findRev">findRev</a>( QRegExp("an") ); // i == 3 </pre> <p> <p>See also <a href="#find">find</a>(). <h3 class=fn><a href="qstring.html">QString</a> <a name="fromLatin1"></a>QString::fromLatin1 ( const char * chars, int len = -1 )<tt> [static]</tt> </h3> Returns the unicode string decoded from the first <em>len</em> characters of <em>chars</em>, ignoring the rest of <em>chars</em>. If <em>len</em> is -1 then the length of <em>chars</em> is used. If <em>len</em> is bigger than the length of <em>chars</em> then it will use the length of <em>chars</em>. <p> This is the same as the QString(const char*) constructor, but you can make that constructor invisible if you compile with the define QT_NO_CAST_ASCII, in which case you can explicitly create a QString from Latin-1 text using this function. <p> <pre> QString str = QString::<a href="#fromLatin1">fromLatin1</a>( "123456789", 5 ); // str == "12345" </pre> <p> <p>Examples: <a href="listbox-example.html#x1286">listbox/listbox.cpp</a> and <a href="mail-example.html#x981">network/mail/smtp.cpp</a>. <h3 class=fn><a href="qstring.html">QString</a> <a name="fromLocal8Bit"></a>QString::fromLocal8Bit ( const char * local8Bit, int len = -1 )<tt> [static]</tt> </h3> Returns the unicode string decoded from the first <em>len</em> characters of <em>local8Bit</em>, ignoring the rest of <em>local8Bit</em>. If <em>len</em> is -1 then the length of <em>local8Bit</em> is used. If <em>len</em> is bigger than the length of <em>local8Bit</em> then it will use the length of <em>local8Bit</em>. <p> <pre> QString str = QString::<a href="#fromLocal8Bit">fromLocal8Bit</a>( "123456789", 5 ); // str == "12345" </pre> <p> <em>local8Bit</em> is assumed to be encoded in a locale-specific format. <p> See <a href="qtextcodec.html">QTextCodec</a> for more diverse coding/decoding of Unicode strings. <h3 class=fn><a href="qstring.html">QString</a> <a name="fromUtf8"></a>QString::fromUtf8 ( const char * utf8, int len = -1 )<tt> [static]</tt> </h3> Returns the unicode string decoded from the first <em>len</em> characters of <em>utf8</em>, ignoring the rest of <em>utf8</em>. If <em>len</em> is -1 then the length of <em>utf8</em> is used. If <em>len</em> is bigger than the length of <em>utf8</em> then it will use the length of <em>utf8</em>. <p> <pre> QString str = QString::<a href="#fromUtf8">fromUtf8</a>( "123456789", 5 ); // str == "12345" </pre> <p> See <a href="qtextcodec.html">QTextCodec</a> for more diverse coding/decoding of Unicode strings. <p>Example: <a href="simple-qfont-demo-walkthrough.html#x2400">fonts/simple-qfont-demo/viewer.cpp</a>. <h3 class=fn><a href="qstring.html">QString</a> & <a name="insert"></a>QString::insert ( uint index, const <a href="qstring.html">QString</a> & s ) </h3> Inserts <em>s</em> into the string before position <em>index</em>. <p> If <em>index</em> is beyond the end of the string, the string is extended with spaces to length <em>index</em> and <em>s</em> is then appended and returns a reference to the string. <p> <pre> QString string( "I like fish" ); str = string.<a href="#insert">insert</a>( 2, "don't " ); // str == "I don't like fish" </pre> <p> <p>See also <a href="#remove">remove</a>() and <a href="#replace">replace</a>(). <p>Examples: <a href="themes-example.html#x354">themes/themes.cpp</a> and <a href="xform-example.html#x120">xform/xform.cpp</a>. <h3 class=fn><a href="qstring.html">QString</a> & <a name="insert-2"></a>QString::insert ( uint index, const <a href="qchar.html">QChar</a> * s, uint len ) </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Inserts the character in <em>s</em> into the string before the position <em>index</em> <em>len</em> number of times and returns a reference to the string. <p> <h3 class=fn><a href="qstring.html">QString</a> & <a name="insert-3"></a>QString::insert ( uint index, <a href="qchar.html">QChar</a> c ) </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Insert <em>c</em> into the string at (before) position <em>index</em> and returns a reference to the string. <p> If <em>index</em> is beyond the end of the string, the string is extended with spaces (ASCII 32) to length <em>index</em> and <em>c</em> is then appended. <p> <h3 class=fn><a href="qstring.html">QString</a> & <a name="insert-4"></a>QString::insert ( uint index, char c ) </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Insert character <em>c</em> at position <em>index</em>. <h3 class=fn>bool <a name="isEmpty"></a>QString::isEmpty () const </h3> <p> Returns TRUE if the string is empty, i.e., if <a href="#length">length</a>() == 0. Thus, null strings are empty strings. <p> <pre> QString a( "" ); a.<a href="#isEmpty">isEmpty</a>(); // TRUE a.<a href="#isNull">isNull</a>(); // FALSE QString b; b.<a href="#isEmpty">isEmpty</a>(); // TRUE b.<a href="#isNull">isNull</a>(); // TRUE </pre> <p> <p>See also <a href="#isNull">isNull</a>() and <a href="#length">length</a>(). <p>Examples: <a href="addressbook-example.html#x1962">addressbook/mainwindow.cpp</a>, <a href="simple-application-example.html#x1936">application/application.cpp</a>, <a href="hello-example.html#x1474">hello/main.cpp</a>, <a href="helpviewer-example.html#x1425">helpviewer/helpwindow.cpp</a>, <a href="networkprotocol-example.html#x956">network/networkprotocol/nntp.cpp</a>, <a href="qmag-example.html#x711">qmag/qmag.cpp</a> and <a href="qwerty-example.html#x652">qwerty/qwerty.cpp</a>. <h3 class=fn>bool <a name="isNull"></a>QString::isNull () const </h3> <p> Returns TRUE if the string is null. A null string is always empty. <p> <pre> QString a; // a.<a href="#unicode">unicode</a>() == 0, a.<a href="#length">length</a>() == 0 a.<a href="#isNull">isNull</a>(); // TRUE, because a.<a href="#unicode">unicode</a>() == 0 a.<a href="#isEmpty">isEmpty</a>(); // TRUE </pre> <p> <p>See also <a href="#isEmpty">isEmpty</a>() and <a href="#length">length</a>(). <p>Examples: <a href="i18n-example.html#x1379">i18n/main.cpp</a> and <a href="qdir-example.html#x799">qdir/qdir.cpp</a>. <h3 class=fn>const char * <a name="latin1"></a>QString::latin1 () const </h3> Returns a Latin-1 representation of the string. Note that the returned value is undefined if the string contains non-Latin-1 characters. If you want to convert strings into formats other than Unicode, see the <a href="qtextcodec.html">QTextCodec</a> classes. <p> This function is mainly useful for boot-strapping legacy code to use Unicode. <p> The result remains valid so long as one unmodified copy of the source string exists. <p> <p>See also <a href="#utf8">utf8</a>() and <a href="#local8Bit">local8Bit</a>(). <p>Examples: <a href="fileiconview-example.html#x1583">fileiconview/qfileiconview.cpp</a> and <a href="networkprotocol-example.html#x957">network/networkprotocol/nntp.cpp</a>. <h3 class=fn><a href="qstring.html">QString</a> <a name="left"></a>QString::left ( uint len ) const </h3> Returns a substring that contains the <em>len</em> leftmost characters of the string. <p> The whole string is returned if <em>len</em> exceeds the length of the string. <p> <pre> QString s = "Pineapple"; QString t = s.<a href="#left">left</a>( 4 ); // t == "Pine" </pre> <p> <p>See also <a href="#right">right</a>(), <a href="#mid">mid</a>() and <a href="#isEmpty">isEmpty</a>(). <p>Example: <a href="themes-example.html#x355">themes/themes.cpp</a>. <h3 class=fn><a href="qstring.html">QString</a> <a name="leftJustify"></a>QString::leftJustify ( uint width, <a href="qchar.html">QChar</a> fill = ' ', bool truncate = FALSE ) const </h3> Returns a string of length <em>width</em> that contains this string padded by the <em>fill</em> character. <p> If <em>truncate</em> is FALSE and the length of the string is more than <em>width</em>, then the returned string is a copy of the string. <p> If <em>truncate</em> is TRUE and the length of the string is more than <em>width</em>, then any characters in a copy of the string after length <em>width</em> are removed, and the copy is returned. <p> <pre> QString s( "apple" ); QString t = s.<a href="#leftJustify">leftJustify</a>( 8, '.' ); // t == "apple..." </pre> <p> <p>See also <a href="#rightJustify">rightJustify</a>(). <h3 class=fn>uint <a name="length"></a>QString::length () const </h3> <p> Returns the length of the string. <p> Null strings and empty strings have zero length. <p> <p>See also <a href="#isNull">isNull</a>() and <a href="#isEmpty">isEmpty</a>(). <p>Examples: <a href="fileiconview-example.html#x1584">fileiconview/qfileiconview.cpp</a>, <a href="networkprotocol-example.html#x958">network/networkprotocol/nntp.cpp</a>, <a href="rot-example.html#x581">rot13/rot13.cpp</a> and <a href="themes-example.html#x356">themes/themes.cpp</a>. <h3 class=fn><a href="qcstring.html">QCString</a> <a name="local8Bit"></a>QString::local8Bit () const </h3> Returns the string encoded in a locale-specific format. On X11, this is the <a href="qtextcodec.html#codecForLocale">QTextCodec::codecForLocale</a>(). On Windows, it is a system-defined encoding. On Mac OS X, this always uses utf8 as the encoding. <p> See <a href="qtextcodec.html">QTextCodec</a> for more diverse coding/decoding of Unicode strings. <p> <p>See also <a href="#fromLocal8Bit">QString::fromLocal8Bit</a>(), <a href="#latin1">latin1</a>() and <a href="#utf8">utf8</a>(). <h3 class=fn>int <a name="localeAwareCompare"></a>QString::localeAwareCompare ( const <a href="qstring.html">QString</a> & s1, const <a href="qstring.html">QString</a> & s2 )<tt> [static]</tt> </h3> <p> Compares <em>s1</em> with <em>s2</em> and returns an integer less than, equal to, or greater than zero if <em>s1</em> is less than, equal to, or greater than <em>s2</em>. <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>See also <a href="#compare">QString::compare</a>() and <a href="qtextcodec.html#locale">QTextCodec::locale</a>(). <h3 class=fn>int <a name="localeAwareCompare-2"></a>QString::localeAwareCompare ( const <a href="qstring.html">QString</a> & s ) const </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Compares this string with <em>s</em>. <h3 class=fn><a href="qstring.html">QString</a> <a name="lower"></a>QString::lower () const </h3> Returns a string that is the string converted to lowercase. <p> <pre> QString string( "TROlltECH" ); str = string.<a href="#lower">lower</a>(); // str == "trolltech" </pre> <p> <p>See also <a href="#upper">upper</a>(). <p>Example: <a href="scribble-example.html#x556">scribble/scribble.cpp</a>. <h3 class=fn><a href="qstring.html">QString</a> <a name="mid"></a>QString::mid ( uint index, uint len = 0xffffffff ) const </h3> Returns a string that contains the <em>len</em> characters of this string, starting at position <em>index</em>. <p> Returns a null string if the string is empty or <em>index</em> is out of range. Returns the whole string from <em>index</em> if <em>index+len</em> exceeds the length of the string. <p> <pre> QString s( "Five pineapples" ); QString t = s.<a href="#mid">mid</a>( 5, 4 ); // t == "pine" </pre> <p> <p>See also <a href="#left">left</a>() and <a href="#right">right</a>(). <p>Examples: <a href="mail-example.html#x982">network/mail/smtp.cpp</a>, <a href="qmag-example.html#x712">qmag/qmag.cpp</a> and <a href="themes-example.html#x357">themes/themes.cpp</a>. <h3 class=fn><a href="qstring.html">QString</a> <a name="number"></a>QString::number ( long n, int base = 10 )<tt> [static]</tt> </h3> A convenience function that returns a string equivalent of the number <em>n</em> to base <em>base</em>, which is 10 by default and must be between 2 and 36. <p> <pre> long a = 63; QString str = QString::<a href="#number">number</a>( a, 16 ); // str == "3f" QString str = QString::<a href="#number">number</a>( a, 16 ).upper(); // str == "3F" </pre> <p> <p>See also <a href="#setNum">setNum</a>(). <p>Examples: <a href="qaction-application-example.html#x2039">action/application.cpp</a>, <a href="simple-application-example.html#x1937">application/application.cpp</a>, <a href="simple-qfont-demo-walkthrough.html#x2401">fonts/simple-qfont-demo/viewer.cpp</a>, <a href="helpviewer-example.html#x1426">helpviewer/helpwindow.cpp</a>, <a href="mdi-example.html#x1174">mdi/application.cpp</a> and <a href="sql.html#x2307">sql/overview/extract/main.cpp</a>. <h3 class=fn><a href="qstring.html">QString</a> <a name="number-2"></a>QString::number ( ulong n, int base = 10 )<tt> [static]</tt> </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> <p>See also <a href="#setNum">setNum</a>(). <h3 class=fn><a href="qstring.html">QString</a> <a name="number-3"></a>QString::number ( int n, int base = 10 )<tt> [static]</tt> </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> <p>See also <a href="#setNum">setNum</a>(). <h3 class=fn><a href="qstring.html">QString</a> <a name="number-4"></a>QString::number ( uint n, int base = 10 )<tt> [static]</tt> </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> A convenience factory function that returns a string representation of the number <em>n</em> to the base <em>base</em>, which is 10 by default and must be between 2 and 36. <p> <p>See also <a href="#setNum">setNum</a>(). <h3 class=fn><a href="qstring.html">QString</a> <a name="number-5"></a>QString::number ( double n, char f = 'g', int prec = 6 )<tt> [static]</tt> </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Argument <em>n</em> is formatted according to the <em>f</em> format specified, which is <tt>g</tt> by default, and can be any of the following: <p> <ul> <li> <tt>e</tt> - format as [-]9.9e[+|-]999 <li> <tt>E</tt> - format as [-]9.9E[+|-]999 <li> <tt>f</tt> - format as [-]9.9 <li> <tt>g</tt> - use <tt>e</tt> or <tt>f</tt> format, whichever is the most concise <li> <tt>G</tt> - use <tt>E</tt> or <tt>f</tt> format, whichever is the most concise </ul> <p> In all cases the number of digits after the decimal point is equal to the precision specified in <em>prec</em>. <p> <pre> double d = 12.34; QString ds = <a href="#QString">QString</a>( "'E' format, precision 3, gives %1" ) .arg( d, 0, 'E', 3 ); // ds == "1.234E+001" </pre> <p> <p>See also <a href="#setNum">setNum</a>(). <h3 class=fn><a name="operator-const-char-*"></a>QString::operator const char * () const </h3> <p> Returns <a href="#latin1">latin1</a>(). Be sure to see the warnings documented there. Note that for new code which you wish to be strictly Unicode-clean, you can define the macro QT_NO_ASCII_CAST when compiling your code to hide this function so that automatic casts are not done. This has the added advantage that you catch the programming error described under <a href="#operator!">operator!</a>(). <h3 class=fn>bool <a name="operator!"></a>QString::operator! () const </h3> Returns TRUE if it is a null string; otherwise FALSE. <p> <pre> QString name = getName(); if ( !name ) name = "Rodney"; </pre> <p> Note that if you say <p> <pre> QString name = getName(); if ( name ) doSomethingWith(name); </pre> <p> It will call "operator const char*()", which is inefficent; you may wish to define the macro QT_NO_ASCII_CAST when writing code which you wish to remain Unicode-clean. <p> When you want the above semantics, use: <p> <pre> QString name = getName(); if ( !name.<a href="#isNull">isNull</a>() ) doSomethingWith(name); </pre> <h3 class=fn><a href="qstring.html">QString</a> & <a name="operator+-eq"></a>QString::operator+= ( const <a href="qstring.html">QString</a> & str ) </h3> Appends <em>str</em> to the string and returns a reference to the string. <h3 class=fn><a href="qstring.html">QString</a> & <a name="operator+-eq-2"></a>QString::operator+= ( <a href="qchar.html">QChar</a> c ) </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Appends <em>c</em> to the string and returns a reference to the string. <h3 class=fn><a href="qstring.html">QString</a> & <a name="operator+-eq-3"></a>QString::operator+= ( char c ) </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Appends <em>c</em> to the string and returns a reference to the string. <h3 class=fn><a href="qstring.html">QString</a> & <a name="operator-eq"></a>QString::operator= ( <a href="qchar.html">QChar</a> c ) </h3> Sets the string to contain just the single character <em>c</em>. <h3 class=fn><a href="qstring.html">QString</a> & <a name="operator-eq-2"></a>QString::operator= ( const <a href="qstring.html">QString</a> & s ) </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Assigns a <a href="shclass.html#shallow-copy">shallow copy</a> of <em>s</em> to this string and returns a reference to this string. This is very fast because the string isn't actually copied. <h3 class=fn><a href="qstring.html">QString</a> & <a name="operator-eq-3"></a>QString::operator= ( const char * str ) </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Assigns a <a href="shclass.html#deep-copy">deep copy</a> of <em>str</em>, interpreted as a classic C string to this string and returns a reference to this string. <p> If <em>str</em> is 0, then a null string is created. <p> <p>See also <a href="#isNull">isNull</a>(). <h3 class=fn><a href="qstring.html">QString</a> & <a name="operator-eq-4"></a>QString::operator= ( const <a href="qcstring.html">QCString</a> & cs ) </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Assigns a <a href="shclass.html#deep-copy">deep copy</a> of <em>cs</em>, interpreted as a classic C string, to this string and returns a reference to this string. <h3 class=fn><a href="qstring.html">QString</a> & <a name="operator-eq-5"></a>QString::operator= ( char c ) </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Sets the string to contain just the single character <em>c</em>. <h3 class=fn><a href="qchar.html">QChar</a> <a name="operator[]"></a>QString::operator[] ( int i ) const </h3> <p> Returns the character at index <em>i</em>, or QChar::null if <em>i</em> is beyond the length of the string. <p> If the QString is not const (i.e., const QString) or const& (i.e., const QString&), then the non-const overload of operator[] will be used instead. <h3 class=fn><a href="qcharref.html">QCharRef</a> <a name="operator[]-2"></a>QString::operator[] ( int i ) </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> The function returns a reference to the character at index <em>i</em>. The resulting reference can then be assigned to, or used immediately, but it will become invalid once further modifications are made to the original string. <p> If <em>i</em> is beyond the length of the string then the string is expanded with QChar::nulls, so that the <a href="qcharref.html">QCharRef</a> references a valid (null) character in the string. <p> The QCharRef internal class can be used much like a constant <a href="qchar.html">QChar</a>, but if you assign to it, you change the original string (which will detach itself because of QString's copy-on-write semantics). You will get compilation errors if you try to use the result as anything but a QChar. <h3 class=fn><a href="qstring.html">QString</a> & <a name="prepend"></a>QString::prepend ( const <a href="qstring.html">QString</a> & s ) </h3> <p> Inserts <em>s</em> at the beginning of the string and returns a reference to the string. <p> Equivalent to <a href="#insert">insert</a>(0, <em>s</em>). <p> <pre> QString string = "42"; string.<a href="#prepend">prepend</a>( "The answer is " ); // string == "The answer is 42" </pre> <p> <p>See also <a href="#insert">insert</a>(). <h3 class=fn><a href="qstring.html">QString</a> & <a name="prepend-2"></a>QString::prepend ( char ch ) </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Inserts <em>ch</em> at the beginning of the string and returns a reference to the string. <p> Equivalent to <a href="#insert">insert</a>(0, <em>ch</em>). <p> <p>See also <a href="#insert">insert</a>(). <h3 class=fn><a href="qstring.html">QString</a> & <a name="prepend-3"></a>QString::prepend ( <a href="qchar.html">QChar</a> ch ) </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Inserts <em>ch</em> at the beginning of the string and returns a reference to the string. <p> Equivalent to <a href="#insert">insert</a>(0, <em>ch</em>). <p> <p>See also <a href="#insert">insert</a>(). <h3 class=fn><a href="qchar.html">QChar</a> & <a name="ref"></a>QString::ref ( uint i ) </h3> <p> Returns the <a href="qchar.html">QChar</a> at index <em>i</em> by reference, expanding the string with QChar::null if necessary. The resulting reference can be assigned to, or otherwise used immediately, but becomes invalid once furher modifications are made to the string. <p> <pre> QString string("ABCDEF"); <a href="qchar.html">QChar</a> ch = string.<a href="#ref">ref</a>( 3 ); // ch == 'D' </pre> <p> <p>See also <a href="#constref">constref</a>(). <h3 class=fn><a href="qstring.html">QString</a> & <a name="remove"></a>QString::remove ( uint index, uint len ) </h3> Removes <em>len</em> characters starting at position <em>index</em> from the string and returns a reference to the string. <p> If <em>index</em> is beyond the length of the string, nothing happens. If <em>index</em> is within the string, but <em>index</em> plus <em>len</em> is beyond the end of the string, the string is truncated at position <em>index</em>. <p> <pre> QString string( "Montreal" ); string.<a href="#remove">remove</a>( 1, 4 ); // string == "Meal" </pre> <p> <p>See also <a href="#insert">insert</a>() and <a href="#replace">replace</a>(). <h3 class=fn><a href="qstring.html">QString</a> & <a name="replace"></a>QString::replace ( uint index, uint len, const <a href="qstring.html">QString</a> & s ) </h3> Replaces <em>len</em> characters starting at position <em>index</em> from the string with <em>s</em>, and returns a reference to the string. <p> If <em>index</em> is beyond the length of the string, nothing is deleted and <em>s</em> is appended at the end of the string. If <em>index</em> is valid, but <em>index</em> plus <em>len</em> is beyond the end of the string, the string is truncated at position <em>index</em>, then <em>s</em> is appended at the end. <p> <pre> QString string( "Say yes!" ); string = string.<a href="#replace">replace</a>( 4, 3, "NO" ); // string == "Say NO!" </pre> <p> <p>See also <a href="#insert">insert</a>() and <a href="#remove">remove</a>(). <p>Examples: <a href="listviews-example.html#x1231">listviews/listviews.cpp</a>, <a href="networkprotocol-example.html#x959">network/networkprotocol/nntp.cpp</a> and <a href="qmag-example.html#x713">qmag/qmag.cpp</a>. <h3 class=fn><a href="qstring.html">QString</a> & <a name="replace-2"></a>QString::replace ( uint index, uint len, const <a href="qchar.html">QChar</a> * s, uint slen ) </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Replaces <em>len</em> characters starting at position <em>index</em> by <em>slen</em> characters of <a href="qchar.html">QChar</a> data from <em>s</em>, and returns a reference to the string. <p> <p>See also <a href="#insert">insert</a>() and <a href="#remove">remove</a>(). <h3 class=fn><a href="qstring.html">QString</a> & <a name="replace-3"></a>QString::replace ( const <a href="qregexp.html">QRegExp</a> & rx, const <a href="qstring.html">QString</a> & str ) </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Replaces every occurrence of the regexp <em>rx</em> in the string with <em>str</em>. Returns a reference to the string. <p> <pre> QString string = "banana"; string = string.<a href="#replace">replace</a>( QRegExp("an"), "" ); // string == "ba" </pre> <p> <p>See also <a href="#find">find</a>() and <a href="#findRev">findRev</a>(). <h3 class=fn><a href="qstring.html">QString</a> <a name="right"></a>QString::right ( uint len ) const </h3> Returns a string that contains the <em>len</em> rightmost characters of the string. <p> If <em>len</em> is greater than the length of the string then the whole string is returned. <p> <pre> QString string( "Pineapple" ); QString t = string.<a href="#right">right</a>( 5 ); // t == "apple" </pre> <p> <p>See also <a href="#left">left</a>(), <a href="#mid">mid</a>() and <a href="#isEmpty">isEmpty</a>(). <p>Example: <a href="fileiconview-example.html#x1585">fileiconview/qfileiconview.cpp</a>. <h3 class=fn><a href="qstring.html">QString</a> <a name="rightJustify"></a>QString::rightJustify ( uint width, <a href="qchar.html">QChar</a> fill = ' ', bool truncate = FALSE ) const </h3> Returns a string of length <em>width</em> that contains the <em>fill</em> character followed by the string. <p> If <em>truncate</em> is FALSE and the length of the string is more than <em>width</em>, then the returned string is a copy of the string. <p> If <em>truncate</em> is TRUE and the length of the string is more than <em>width</em>, then the resulting string is truncated at position <em>width</em>. <p> <pre> QString string( "apple" ); QString t = string.<a href="#rightJustify">rightJustify</a>( 8, '.' ); // t == "...apple" </pre> <p> <p>See also <a href="#leftJustify">leftJustify</a>(). <h3 class=fn><a href="qstring.html">QString</a> <a name="section"></a>QString::section ( <a href="qchar.html">QChar</a> sep, int start, int end = 0xffffffff, int flags = SectionDefault ) const </h3> <p> <p> This function returns a section of the string. <p> This string is treated as a sequence of fields separated by the character, <em>sep</em>. The returned string consists of the fields from position <em>start</em> to position <em>end</em> inclusive. If <em>end</em> is not specified, all fields from position <em>start</em> to the end of the string are included. <p> The <em>flags</em> argument can be used to affect some aspects of the function's behaviour, e.g. whether to be case sensitive, whether to skip empty fields and how to deal with leading and trailing separators; see <a href="#SectionFlags-enum">SectionFlags</a>. <p> <pre> QString csv( "forename,middlename,surname,phone" ); QString s = csv.<a href="#section">section</a>( ',', 2, 2 ); // s == "surname" QString path( "/usr/local/bin/myapp" ); // First field is empty QString s = path.<a href="#section">section</a>( '/', 3, 4 ); // s == "bin/myapp" QString s = path.<a href="#section">section</a>( '/', 3, 3, SectionSkipEmpty ); // s == "myapp" </pre> <p> If <em>start</em> or <em>end</em> 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> QString csv( "forename,middlename,surname,phone" ); QString s = csv.<a href="#section">section</a>( ',', -3, -2 ); // s == "middlename,surname" QString path( "/usr/local/bin/myapp" ); // First field is empty QString s = path.<a href="#section">section</a>( '/', -1 ); // s == "myapp" </pre> <p> <p>See also <a href="qstringlist.html#split">QStringList::split</a>(). <h3 class=fn><a href="qstring.html">QString</a> <a name="section-2"></a>QString::section ( char sep, int start, int end = 0xffffffff, int flags = SectionDefault ) const </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> <h3 class=fn><a href="qstring.html">QString</a> <a name="section-3"></a>QString::section ( const char * sep, int start, int end = 0xffffffff, int flags = SectionDefault ) const </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> <h3 class=fn><a href="qstring.html">QString</a> <a name="section-4"></a>QString::section ( const <a href="qstring.html">QString</a> & sep, int start, int end = 0xffffffff, int flags = SectionDefault ) const </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> This function returns a section of the string. <p> This string is treated as a sequence of fields separated by the string, <em>sep</em>. The returned string consists of the fields from position <em>start</em> to position <em>end</em> inclusive. If <em>end</em> is not specified, all fields from position <em>start</em> to the end of the string are included. <p> The <em>flags</em> argument can be used to affect some aspects of the function's behaviour, e.g. whether to be case sensitive, whether to skip empty fields and how to deal with leading and trailing separators; see <a href="#SectionFlags-enum">SectionFlags</a>. <p> <pre> QString data( "forename**middlename**surname**phone" ); QString s = data.<a href="#section">section</a>( "**", 2, 2 ); // s == "surname" </pre> <p> If <em>start</em> or <em>end</em> 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> QString data( "forename**middlename**surname**phone" ); QString s = data.<a href="#section">section</a>( "**", -3, -2 ); // s == "middlename**surname" </pre> <p> <p>See also <a href="qstringlist.html#split">QStringList::split</a>(). <h3 class=fn><a href="qstring.html">QString</a> <a name="section-5"></a>QString::section ( const <a href="qregexp.html">QRegExp</a> & reg, int start, int end = 0xffffffff, int flags = SectionDefault ) const </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> This function returns a section of the string. <p> This string is treated as a sequence of fields separated by the <a href="qregexp.html#regular-expression">regular expression</a>, <em>reg</em>. The returned string consists of the fields from position <em>start</em> to position <em>end</em> inclusive. If <em>end</em> is not specified, all fields from position <em>start</em> to the end of the string are included. <p> The <em>flags</em> argument can be used to affect some aspects of the function's behaviour, e.g. whether to be case sensitive, whether to skip empty fields and how to deal with leading and trailing separators; see <a href="#SectionFlags-enum">SectionFlags</a>. <p> <pre> QString line( "forename\tmiddlename surname \t \t phone" ); <a href="qregexp.html">QRegExp</a> sep( "\s+" ); QString s = line.<a href="#section">section</a>( sep, 2, 2 ); // s == "surname" </pre> <p> If <em>start</em> or <em>end</em> 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> QString line( "forename\tmiddlename surname \t \t phone" ); <a href="qregexp.html">QRegExp</a> sep( "\\s+" ); QString s = line.<a href="#section">section</a>( sep, -3, -2 ); // s == "middlename surname" </pre> <p> <b>Warning:</b> Section on <a href="qregexp.html">QRegExp</a> is much more expensive than the overloaded string and character versions. <p> <p>See also <a href="qstringlist.html#split">QStringList::split</a>() and <a href="#simplifyWhiteSpace">simplifyWhiteSpace</a>(). <h3 class=fn>void <a name="setExpand"></a>QString::setExpand ( uint index, <a href="qchar.html">QChar</a> c ) </h3> <b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code. <p> Sets the character at position <em>index</em> to <em>c</em> and expands the string if necessary, filling with spaces. <p> This method is redundant in Qt 3.x, because operator[] will expand the string as necessary. <h3 class=fn><a href="qstring.html">QString</a> & <a name="setLatin1"></a>QString::setLatin1 ( const char * str, int len = -1 ) </h3> Sets this string to <em>str</em>, interpreted as a classic Latin1 C string. If <em>len</em> is -1 (the default), then it is set to strlen(str). <p> If <em>str</em> is 0 a null string is created. If <em>str</em> is "", an empty string is created. <p> <p>See also <a href="#isNull">isNull</a>() and <a href="#isEmpty">isEmpty</a>(). <h3 class=fn>void <a name="setLength"></a>QString::setLength ( uint newLen ) </h3> Ensures that at least <em>newLen</em> characters are allocated to the string, and sets the length of the string to <em>newLen</em>. Any new space allocated contains arbitrary data. <p> If <em>newLen</em> is 0, then the string becomes empty, unless the string is null, in which case it remains null. <p> This function always detaches the string from other references to the same data. <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 big enough: <pre> QString result; int resultLength = 0; result.<a href="#setLength">setLength</a>( newLen ) // allocate some space while ( ... ) { result[resultLength++] = ... // fill (part of) the space with data } result.truncate[resultLength]; // and get rid of the undefined junk </pre> <p> If <em>newLen</em> is an underestimate, the worst that will happen is that the loop will slow down. <p> <p>See also <a href="#truncate">truncate</a>(), <a href="#isNull">isNull</a>(), <a href="#isEmpty">isEmpty</a>() and <a href="#length">length</a>(). <h3 class=fn><a href="qstring.html">QString</a> & <a name="setNum"></a>QString::setNum ( long n, int base = 10 ) </h3> Sets the string to the printed value of <em>n</em> in base <em>base</em> and returns a reference to the string. <p> The base is 10 by default and must be between 2 and 36. <p> <pre> QString string; string = string.<a href="#setNum">setNum</a>( 1234 ); // string == "1234" </pre> <h3 class=fn><a href="qstring.html">QString</a> & <a name="setNum-2"></a>QString::setNum ( short n, int base = 10 ) </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Sets the string to the printed value of <em>n</em> in base <em>base</em> and returns a reference to the string. <p> The base is 10 by default and must be between 2 and 36. <h3 class=fn><a href="qstring.html">QString</a> & <a name="setNum-3"></a>QString::setNum ( ushort n, int base = 10 ) </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Sets the string to the printed value of <em>n</em> in base <em>base</em> and returns a reference to the string. <p> The base is 10 by default and must be between 2 and 36. <h3 class=fn><a href="qstring.html">QString</a> & <a name="setNum-4"></a>QString::setNum ( int n, int base = 10 ) </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Sets the string to the printed value of <em>n</em> in base <em>base</em> and returns a reference to the string. <p> The base is 10 by default and must be between 2 and 36. <h3 class=fn><a href="qstring.html">QString</a> & <a name="setNum-5"></a>QString::setNum ( uint n, int base = 10 ) </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Sets the string to the printed value of <em>n</em> in base <em>base</em> and returns a reference to the string. <p> The base is 10 by default and must be between 2 and 36. <h3 class=fn><a href="qstring.html">QString</a> & <a name="setNum-6"></a>QString::setNum ( ulong n, int base = 10 ) </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Sets the string to the printed value of <em>n</em> in base <em>base</em> and returns a reference to the string. <p> The base is 10 by default and must be between 2 and 36. <h3 class=fn><a href="qstring.html">QString</a> & <a name="setNum-7"></a>QString::setNum ( float n, char f = 'g', int prec = 6 ) </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Sets the string to the printed value of <em>n</em>, formatted in format <em>f</em> with precision <em>prec</em>, and returns a reference to the string. <p> The format <em>f</em> can be 'f', 'F', 'e', 'E', 'g' or 'G'. See <a href="#arg-formats">arg</a>() for an explanation of the formats. <h3 class=fn><a href="qstring.html">QString</a> & <a name="setNum-8"></a>QString::setNum ( double n, char f = 'g', int prec = 6 ) </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Sets the string to the printed value of <em>n</em>, formatted in format <em>f</em> with precision <em>prec</em>, and returns a reference to the string. <p> The format <em>f</em> can be 'f', 'F', 'e', 'E', 'g' or 'G'. See <a href="#arg-formats">arg</a>() for an explanation of the formats. <h3 class=fn><a href="qstring.html">QString</a> & <a name="setUnicode"></a>QString::setUnicode ( const <a href="qchar.html">QChar</a> * unicode, uint len ) </h3> Resizes the string to <em>len</em> characters and copies <em>unicode</em> into the string. If <em>unicode</em> is null, nothing is copied, but the string is still resized to <em>len</em>. If <em>len</em> is zero, then the string becomes a <a href="#isNull">null</a> string. <p> <p>See also <a href="#setLatin1">setLatin1</a>() and <a href="#isNull">isNull</a>(). <h3 class=fn><a href="qstring.html">QString</a> & <a name="setUnicodeCodes"></a>QString::setUnicodeCodes ( const ushort * unicode_as_ushorts, uint len ) </h3> Resizes the string to <em>len</em> characters and copies <em>unicode_as_ushorts</em> into the string (on some X11 client platforms this will involve a byte-swapping pass). <p> If <em>unicode_as_ushorts</em> is null, nothing is copied, but the string is still resized to <em>len</em>. If <em>len</em> is zero, the string becomes a <a href="#isNull">null</a> string. <p> <p>See also <a href="#setLatin1">setLatin1</a>() and <a href="#isNull">isNull</a>(). <h3 class=fn><a href="qstring.html">QString</a> <a name="simplifyWhiteSpace"></a>QString::simplifyWhiteSpace () const </h3> Returns a string that has whitespace removed from the start and the end of the string, and any sequence of internal whitespace is replaced with a single space. <p> Whitespace means any character for which <a href="qchar.html#isSpace">QChar::isSpace</a>() returns TRUE. This includes UNICODE characters with decimal values 9 (TAB), 10 (LF), 11 (VT), 12 (FF), 13 (CR), and 32 (Space). <p> <pre> QString string = " lots\t of\nwhite space "; QString t = string.<a href="#simplifyWhiteSpace">simplifyWhiteSpace</a>(); // t == "lots of white space" </pre> <p> <p>See also <a href="#stripWhiteSpace">stripWhiteSpace</a>(). <h3 class=fn><a href="qstring.html">QString</a> & <a name="sprintf"></a>QString::sprintf ( const char * cformat, ... ) </h3> Safely builds a formatted string from the format string <em>cformat</em> and an arbitrary list of arguments. The format string supports all the escape sequences of printf() in the standard C library. <p> The %s escape sequence expects a <a href="#utf8">utf8</a>() encoded string. The format string <em>cformat</em> is expected to be in latin1. If you need a unicode format string, use <a href="#arg">arg</a>() instead. For typesafe string building, with full Unicode support, you can use <a href="qtextostream.html">QTextOStream</a> like this: <p> <pre> QString str; QString s = ...; int x = ...; QTextOStream( &str ) << s << " : " << x; </pre> <p> For <a href="qobject.html#tr">translations,</a> especially if the strings contains more than one escape sequence, you should consider using the arg() function instead. This allows the order of the replacements to be controlled by the translator, and has Unicode support. <p> <p>See also <a href="#arg">arg</a>(). <p>Examples: <a href="dclock-example.html#x1765">dclock/dclock.cpp</a>, <a href="forever-example.html#x1485">forever/forever.cpp</a>, <a href="layout-example.html#x1338">layout/layout.cpp</a>, <a href="qmag-example.html#x714">qmag/qmag.cpp</a>, <a href="scrollview-example.html#x508">scrollview/scrollview.cpp</a>, <a href="tooltip-example.html#x162">tooltip/tooltip.cpp</a> and <a href="xform-example.html#x121">xform/xform.cpp</a>. <h3 class=fn>bool <a name="startsWith"></a>QString::startsWith ( const <a href="qstring.html">QString</a> & s ) const </h3> Returns TRUE if the string starts with <em>s</em>; otherwise it returns FALSE. <p> <pre> QString string("Bananas"); bool a = string.<a href="#startsWith">startsWith</a>("Ban"); // a == TRUE </pre> <p> <p>See also <a href="#endsWith">endsWith</a>(). <h3 class=fn><a href="qstring.html">QString</a> <a name="stripWhiteSpace"></a>QString::stripWhiteSpace () const </h3> Returns a string that has whitespace removed from the start and the end. <p> Whitespace means any character for which <a href="qchar.html#isSpace">QChar::isSpace</a>() returns TRUE. This includes UNICODE characters with decimal values 9 (TAB), 10 (LF), 11 (VT), 12 (FF), 13 (CR) and 32 (Space), and may also include other Unicode characters. <p> <pre> QString string = " white space "; QString s = string.<a href="#stripWhiteSpace">stripWhiteSpace</a>(); // s == "white space" </pre> <p> <p>See also <a href="#simplifyWhiteSpace">simplifyWhiteSpace</a>(). <h3 class=fn>double <a name="toDouble"></a>QString::toDouble ( bool * ok = 0 ) const </h3> Returns the string converted to a <tt>double</tt> value. <p> If a conversion error occurs, <em>*ok</em> is set to FALSE (unless <em>ok</em> is null, the default) and 0 is returned. Otherwise, <em>*ok</em> is set to true. <p> <pre> QString string( "1234.56" ); double a = string.<a href="#toDouble">toDouble</a>(); // a == 1234.56 </pre> <p> <p>See also <a href="#number">number</a>(). <h3 class=fn>float <a name="toFloat"></a>QString::toFloat ( bool * ok = 0 ) const </h3> Returns the string converted to a <tt>float</tt> value. <p> If a conversion error occurs, <em>*ok</em> is set to FALSE (unless <em>ok</em> is null, the default) and 0 is returned. Otherwise, <em>*ok</em> is set to true. <p> <p>See also <a href="#number">number</a>(). <h3 class=fn>int <a name="toInt"></a>QString::toInt ( bool * ok = 0, int base = 10 ) const </h3> Returns the string converted to an <tt>int</tt> value to the base <em>base</em>, which is 10 by default and must be between 2 and 36. <p> If <em>*ok</em> is nonnull, and is TRUE then there have been no errors in the conversion. If <em>*ok</em> is nonnull, and is FALSE, then the string is not a number at all or it has invalid characters at the end. <p> <pre> QString str( "FF" ); bool ok; int hex = str.<a href="#toInt">toInt</a>( &ok, 16 ); // hex == 255, ok == TRUE int dec = str.<a href="#toInt">toInt</a>( &ok, 10 ); // dec == 0, ok == FALSE </pre> <p> <p>See also <a href="#number">number</a>(). <h3 class=fn>long <a name="toLong"></a>QString::toLong ( bool * ok = 0, int base = 10 ) const </h3> Returns the string converted to a <tt>long</tt> value to the base <em>base</em>, which is 10 by default and must be between 2 and 36. <p> If a conversion error occurs, <em>*ok</em> is set to FALSE (unless <em>ok</em> is null, the default) and 0 is returned. Otherwise, <em>*ok</em> is set to true. <p> <p>See also <a href="#number">number</a>(). <h3 class=fn>short <a name="toShort"></a>QString::toShort ( bool * ok = 0, int base = 10 ) const </h3> Returns the string converted to a <tt>short</tt> value to the base <em>base</em>, which is 10 by default and must be between 2 and 36. <p> If a conversion error occurs, <em>*ok</em> is set to FALSE (unless <em>ok</em> is null, the default) and 0 is returned. Otherwise, <em>*ok</em> is set to true. <h3 class=fn>uint <a name="toUInt"></a>QString::toUInt ( bool * ok = 0, int base = 10 ) const </h3> Returns the string converted to an <tt>unsigned int</tt> value to the base <em>base</em>, which is 10 by default and must be between 2 and 36. <p> If a conversion error occurs, <em>*ok</em> is set to FALSE (unless <em>ok</em> is null, the default) and 0 is returned. Otherwise, <em>*ok</em> is set to true. <p> <p>See also <a href="#number">number</a>(). <h3 class=fn>ulong <a name="toULong"></a>QString::toULong ( bool * ok = 0, int base = 10 ) const </h3> Returns the string converted to an <tt>unsigned long</tt> value to the base <em>base</em>, which is 10 by default and must be between 2 and 36. <p> If a conversion error occurs, <em>*ok</em> is set to FALSE (unless <em>ok</em> is null, the default) and 0 is returned. Otherwise, <em>*ok</em> is set to true. <p> <p>See also <a href="#number">number</a>(). <h3 class=fn>ushort <a name="toUShort"></a>QString::toUShort ( bool * ok = 0, int base = 10 ) const </h3> Returns the string converted to an <tt>unsigned short</tt> value to the base <em>base</em>, which is 10 by default and must be between 2 and 36. <p> If a conversion error occurs, <em>*ok</em> is set to FALSE (unless <em>ok</em> is null, the default) and 0 is returned. Otherwise, <em>*ok</em> is set to true. <h3 class=fn>void <a name="truncate"></a>QString::truncate ( uint newLen ) </h3> If <em>newLen</em> is less than the length of the string, then the string is truncated at position <em>newLen</em>. Otherwise nothing will happen. <p> <pre> QString s = "truncate me"; s.<a href="#truncate">truncate</a>( 5 ); // s == "trunc" </pre> <p> <p>See also <a href="#setLength">setLength</a>(). <p>Example: <a href="mail-example.html#x983">network/mail/smtp.cpp</a>. <h3 class=fn>const <a href="qchar.html">QChar</a> * <a name="unicode"></a>QString::unicode () const </h3> <p> Returns the Unicode representation of the string. The result remains valid until the string is modified. <h3 class=fn><a href="qstring.html">QString</a> <a name="upper"></a>QString::upper () const </h3> Returns a string that is the string converted to uppercase. <p> <pre> QString string( "TeXt" ); str = string.<a href="#upper">upper</a>(); // t == "TEXT" </pre> <p> <p>See also <a href="#lower">lower</a>(). <p>Examples: <a href="scribble-example.html#x557">scribble/scribble.cpp</a> and <a href="sql.html#x2354">sql/overview/custom1/main.cpp</a>. <h3 class=fn><a href="qcstring.html">QCString</a> <a name="utf8"></a>QString::utf8 () const </h3> Returns the string encoded in UTF8 format. <p> See <a href="qtextcodec.html">QTextCodec</a> for more diverse coding/decoding of Unicode strings. <p> <p>See also <a href="#fromUtf8">QString::fromUtf8</a>(), <a href="#local8Bit">local8Bit</a>() and <a href="#latin1">latin1</a>(). <hr><h2>Related Functions</h2> <h3 class=fn>bool <a name="operator!-eq"></a>operator!= ( const <a href="qstring.html">QString</a> & s1, const <a href="qstring.html">QString</a> & s2 ) </h3> Returns TRUE if <em>s1</em> is not equal to <em>s2</em> or FALSE if they are equal. Note that a null string is not equal to an empty string which is nonnull. <p> Equivalent to <a href="#compare">compare</a>(<em>s1</em>, <em>s2</em>) != 0. <h3 class=fn>bool <a name="operator!-eq-2"></a>operator!= ( const <a href="qstring.html">QString</a> & s1, const char * s2 ) </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Returns TRUE if <em>s1</em> is not equal to <em>s2</em> or FALSE if they are equal. Note that a null string is not equal to an empty string which is nonnull. <p> Equivalent to <a href="#compare">compare</a>(<em>s1</em>, <em>s2</em>) != 0. <h3 class=fn>bool <a name="operator!-eq-3"></a>operator!= ( const char * s1, const <a href="qstring.html">QString</a> & s2 ) </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Returns TRUE if <em>s1</em> is not equal to <em>s2</em> or FALSE if they are equal. Note that a null string is not equal to an empty string which is nonnull. <p> Equivalent to <a href="#compare">compare</a>(<em>s1</em>, <em>s2</em>) != 0. <h3 class=fn>const <a href="qstring.html">QString</a> <a name="operator+"></a>operator+ ( const <a href="qstring.html">QString</a> & s1, const <a href="qstring.html">QString</a> & s2 ) </h3> Returns a string which is the result of concatenating the string <em>s1</em> and the string <em>s2</em>. <p> Equivalent to <em>s1</em>.<a href="#append">append</a>(<em>s2</em>). <h3 class=fn>const <a href="qstring.html">QString</a> <a name="operator+-2"></a>operator+ ( const <a href="qstring.html">QString</a> & s1, const char * s2 ) </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Returns a string which is the result of concatenating the string <em>s1</em> and character <em>s2</em>. <p> Equivalent to <em>s1</em>.<a href="#append">append</a>(<em>s2</em>). <h3 class=fn>const <a href="qstring.html">QString</a> <a name="operator+-3"></a>operator+ ( const char * s1, const <a href="qstring.html">QString</a> & s2 ) </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Returns a string which is the result of concatenating the character <em>s1</em> and string <em>s2</em>. <p> <h3 class=fn>const <a href="qstring.html">QString</a> <a name="operator+-4"></a>operator+ ( const <a href="qstring.html">QString</a> & s, char c ) </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Returns a string which is the result of concatenating the string <em>s</em> and character <em>c</em>. <p> Equivalent to <em>s</em>.<a href="#append">append</a>(<em>c</em>). <h3 class=fn>const <a href="qstring.html">QString</a> <a name="operator+-5"></a>operator+ ( char c, const <a href="qstring.html">QString</a> & s ) </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Returns a string which is the result of concatenating the character <em>c</em> and string <em>s</em>. <p> Equivalent to <em>s</em>.<a href="#prepend">prepend</a>(<em>c</em>). <h3 class=fn>bool <a name="operator-lt"></a>operator< ( const <a href="qstring.html">QString</a> & s1, const char * s2 ) </h3> Returns TRUE if <em>s1</em> is lexically less than <em>s2</em> or FALSE if it is not. The comparison is case sensitive. Note that a null string is not equal to an empty string which is nonnull. <p> Equivalent to <a href="#compare">compare</a>(<em>s1</em>, <em>s2</em>) < 0. <h3 class=fn>bool <a name="operator-lt-2"></a>operator< ( const char * s1, const <a href="qstring.html">QString</a> & s2 ) </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Returns TRUE if <em>s1</em> is lexically less than <em>s2</em> or FALSE if it is not. The comparison is case sensitive. Note that a null string is not equal to an empty string which is nonnull. <p> Equivalent to <a href="#compare">compare</a>(<em>s1</em>, <em>s2</em>) < 0. <p> <h3 class=fn><a href="qdatastream.html">QDataStream</a> & <a name="operator-lt-lt"></a>operator<< ( <a href="qdatastream.html">QDataStream</a> & s, const <a href="qstring.html">QString</a> & str ) </h3> Writes the string <em>str</em> to the stream <em>s</em>. <p> See also <a href="datastreamformat.html">Format of the QDataStream operators</a> <h3 class=fn>bool <a name="operator-lt-eq"></a>operator<= ( const <a href="qstring.html">QString</a> & s1, const char * s2 ) </h3> Returns TRUE if <em>s1</em> is lexically less than or equal to <em>s2</em> or FALSE if it is not. The comparison is case sensitive. Note that a null string is not equal to an empty string which is nonnull. <p> Equivalent to <a href="#compare">compare</a>(<em>s1</em>,<em>s2</em>) <= 0. <p> <h3 class=fn>bool <a name="operator-lt-eq-2"></a>operator<= ( const char * s1, const <a href="qstring.html">QString</a> & s2 ) </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Returns TRUE if <em>s1</em> is lexically less than or equal to <em>s2</em> or FALSE if it is not. The comparison is case sensitive. Note that a null string is not equal to an empty string which is nonnull. <p> Equivalent to <a href="#compare">compare</a>(<em>s1</em>, <em>s2</em>) <= 0. <h3 class=fn>bool <a name="operator-eq-eq"></a>operator== ( const <a href="qstring.html">QString</a> & s1, const <a href="qstring.html">QString</a> & s2 ) </h3> Returns TRUE if <em>s1</em> is equal to <em>s2</em> or FALSE if they are different. Note that a null string is not equal to a nonnull empty string. <p> Equivalent to <a href="#compare">compare</a>(<em>s1</em>, <em>s2</em>) != 0. <h3 class=fn>bool <a name="operator-eq-eq-2"></a>operator== ( const <a href="qstring.html">QString</a> & s1, const char * s2 ) </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Returns TRUE if <em>s1</em> is equal to <em>s2</em> or FALSE if they are different. Note that a null string is not equal to an empty string which is nonnull. <p> Equivalent to <a href="#compare">compare</a>(<em>s1</em>, <em>s2</em>) == 0. <h3 class=fn>bool <a name="operator-eq-eq-3"></a>operator== ( const char * s1, const <a href="qstring.html">QString</a> & s2 ) </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Returns TRUE if <em>s1</em> is equal to <em>s2</em> or FALSE if they are different. Note that a null string is not equal to an empty string which is nonnull. <p> Equivalent to <a href="#compare">compare</a>(<em>s1</em>, <em>s2</em>) == 0. <h3 class=fn>bool <a name="operator-gt"></a>operator> ( const <a href="qstring.html">QString</a> & s1, const char * s2 ) </h3> Returns TRUE if <em>s1</em> is lexically greater than <em>s2</em> or FALSE if it is not. The comparison is case sensitive. Note that a null string is not equal to an empty string which is nonnull. <p> Equivalent to <a href="#compare">compare</a>(<em>s1</em>, <em>s2</em>) > 0. <h3 class=fn>bool <a name="operator-gt-2"></a>operator> ( const char * s1, const <a href="qstring.html">QString</a> & s2 ) </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Returns TRUE if <em>s1</em> is lexically greater than <em>s2</em> or FALSE if it is not. The comparison is case sensitive. Note that a null string is not equal to an empty string which is nonnull. <p> Equivalent to <a href="#compare">compare</a>(<em>s1</em>, <em>s2</em>) > 0. <h3 class=fn>bool <a name="operator-gt-eq"></a>operator>= ( const <a href="qstring.html">QString</a> & s1, const char * s2 ) </h3> Returns TRUE if <em>s1</em> is lexically greater than or equal to <em>s2</em> or FALSE if it is not. The comparison is case sensitive. Note that a null string is not equal to an empty string which is nonnull. <p> Equivalent to <a href="#compare">compare</a>(<em>s1</em>, <em>s2</em>) >= 0. <h3 class=fn>bool <a name="operator-gt-eq-2"></a>operator>= ( const char * s1, const <a href="qstring.html">QString</a> & s2 ) </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Returns TRUE if <em>s1</em> is lexically greater than or equal to <em>s2</em> or FALSE if it is not. The comparison is case sensitive. Note that a null string is not equal to an empty string which is nonnull. <p> Equivalent to <a href="#compare">compare</a>(<em>s1</em>, <em>s2</em>) >= 0. <h3 class=fn><a href="qdatastream.html">QDataStream</a> & <a name="operator-gt-gt"></a>operator>> ( <a href="qdatastream.html">QDataStream</a> & s, <a href="qstring.html">QString</a> & str ) </h3> Reads a string from the stream <em>s</em> into string <em>str</em>. <p> See also <a href="datastreamformat.html">Format of the QDataStream operators</a> <!-- eof --> <hr><p> This file is part of the <a href="index.html">Qt toolkit</a>. Copyright © 1995-2001 <a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center> <table width=100% cellspacing=0 border=0><tr> <td>Copyright © 2001 <a href="http://www.trolltech.com">Trolltech</a><td><a href="http://www.trolltech.com/trademarks.html">Trademarks</a> <td align=right><div align=right>Qt version 3.0.2</div> </table></div></address></body> </html>