[190] | 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
---|
| 2 | <!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/tools/qstring.cpp:1228 -->
|
---|
| 3 | <html>
|
---|
| 4 | <head>
|
---|
| 5 | <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
---|
| 6 | <title>QString Class</title>
|
---|
| 7 | <style type="text/css"><!--
|
---|
| 8 | fn { margin-left: 1cm; text-indent: -1cm; }
|
---|
| 9 | a:link { color: #004faf; text-decoration: none }
|
---|
| 10 | a:visited { color: #672967; text-decoration: none }
|
---|
| 11 | body { background: #ffffff; color: black; }
|
---|
| 12 | --></style>
|
---|
| 13 | </head>
|
---|
| 14 | <body>
|
---|
| 15 |
|
---|
| 16 | <table border="0" cellpadding="0" cellspacing="0" width="100%">
|
---|
| 17 | <tr bgcolor="#E5E5E5">
|
---|
| 18 | <td valign=center>
|
---|
| 19 | <a href="index.html">
|
---|
| 20 | <font color="#004faf">Home</font></a>
|
---|
| 21 | | <a href="classes.html">
|
---|
| 22 | <font color="#004faf">All Classes</font></a>
|
---|
| 23 | | <a href="mainclasses.html">
|
---|
| 24 | <font color="#004faf">Main Classes</font></a>
|
---|
| 25 | | <a href="annotated.html">
|
---|
| 26 | <font color="#004faf">Annotated</font></a>
|
---|
| 27 | | <a href="groups.html">
|
---|
| 28 | <font color="#004faf">Grouped Classes</font></a>
|
---|
| 29 | | <a href="functions.html">
|
---|
| 30 | <font color="#004faf">Functions</font></a>
|
---|
| 31 | </td>
|
---|
| 32 | <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>
|
---|
| 33 |
|
---|
| 34 | <p>The QString class provides an abstraction of Unicode text
|
---|
| 35 | and the classic C '\0'-terminated char array.
|
---|
| 36 | <a href="#details">More...</a>
|
---|
| 37 | <p>All the functions in this class are <a href="threads.html#reentrant">reentrant</a> when Qt is built with thread support.</p>
|
---|
| 38 | <p><tt>#include <<a href="qstring-h.html">qstring.h</a>></tt>
|
---|
| 39 | <p><a href="qstring-members.html">List of all member functions.</a>
|
---|
| 40 | <h2>Public Members</h2>
|
---|
| 41 | <ul>
|
---|
| 42 | <li class=fn><a href="#QString"><b>QString</b></a> ()</li>
|
---|
| 43 | <li class=fn><a href="#QString-2"><b>QString</b></a> ( QChar ch )</li>
|
---|
| 44 | <li class=fn><a href="#QString-3"><b>QString</b></a> ( const QString & s )</li>
|
---|
| 45 | <li class=fn><a href="#QString-4"><b>QString</b></a> ( const QByteArray & ba )</li>
|
---|
| 46 | <li class=fn><a href="#QString-5"><b>QString</b></a> ( const QChar * unicode, uint length )</li>
|
---|
| 47 | <li class=fn><a href="#QString-6"><b>QString</b></a> ( const char * str )</li>
|
---|
| 48 | <li class=fn><a href="#QString-7"><b>QString</b></a> ( const std::string & str )</li>
|
---|
| 49 | <li class=fn><a href="#~QString"><b>~QString</b></a> ()</li>
|
---|
| 50 | <li class=fn>QString & <a href="#operator-eq-2"><b>operator=</b></a> ( const QString & s )</li>
|
---|
| 51 | <li class=fn>QString & <a href="#operator-eq-3"><b>operator=</b></a> ( const char * str )</li>
|
---|
| 52 | <li class=fn>QString & <a href="#operator-eq-4"><b>operator=</b></a> ( const std::string & s )</li>
|
---|
| 53 | <li class=fn>QString & <a href="#operator-eq-5"><b>operator=</b></a> ( const QCString & cstr )</li>
|
---|
| 54 | <li class=fn>QString & <a href="#operator-eq"><b>operator=</b></a> ( QChar c )</li>
|
---|
| 55 | <li class=fn>QString & <a href="#operator-eq-6"><b>operator=</b></a> ( char c )</li>
|
---|
| 56 | <li class=fn>bool <a href="#isNull"><b>isNull</b></a> () const</li>
|
---|
| 57 | <li class=fn>bool <a href="#isEmpty"><b>isEmpty</b></a> () const</li>
|
---|
| 58 | <li class=fn>uint <a href="#length"><b>length</b></a> () const</li>
|
---|
| 59 | <li class=fn>void <a href="#truncate"><b>truncate</b></a> ( uint newLen )</li>
|
---|
| 60 | <li class=fn>QString & <a href="#fill"><b>fill</b></a> ( QChar c, int len = -1 )</li>
|
---|
| 61 | <li class=fn>QString copy () const <em>(obsolete)</em></li>
|
---|
| 62 | <li class=fn>QString <a href="#arg-2"><b>arg</b></a> ( long a, int fieldWidth = 0, int base = 10 ) const</li>
|
---|
| 63 | <li class=fn>QString <a href="#arg-3"><b>arg</b></a> ( ulong a, int fieldWidth = 0, int base = 10 ) const</li>
|
---|
| 64 | <li class=fn>QString <a href="#arg-4"><b>arg</b></a> ( Q_LLONG a, int fieldWidth = 0, int base = 10 ) const</li>
|
---|
| 65 | <li class=fn>QString <a href="#arg-5"><b>arg</b></a> ( Q_ULLONG a, int fieldWidth = 0, int base = 10 ) const</li>
|
---|
| 66 | <li class=fn>QString <a href="#arg-6"><b>arg</b></a> ( int a, int fieldWidth = 0, int base = 10 ) const</li>
|
---|
| 67 | <li class=fn>QString <a href="#arg-7"><b>arg</b></a> ( uint a, int fieldWidth = 0, int base = 10 ) const</li>
|
---|
| 68 | <li class=fn>QString <a href="#arg-8"><b>arg</b></a> ( short a, int fieldWidth = 0, int base = 10 ) const</li>
|
---|
| 69 | <li class=fn>QString <a href="#arg-9"><b>arg</b></a> ( ushort a, int fieldWidth = 0, int base = 10 ) const</li>
|
---|
| 70 | <li class=fn>QString <a href="#arg-a"><b>arg</b></a> ( double a, int fieldWidth = 0, char fmt = 'g', int prec = -1 ) const</li>
|
---|
| 71 | <li class=fn>QString <a href="#arg-b"><b>arg</b></a> ( char a, int fieldWidth = 0 ) const</li>
|
---|
| 72 | <li class=fn>QString <a href="#arg-c"><b>arg</b></a> ( QChar a, int fieldWidth = 0 ) const</li>
|
---|
| 73 | <li class=fn>QString <a href="#arg"><b>arg</b></a> ( const QString & a, int fieldWidth = 0 ) const</li>
|
---|
| 74 | <li class=fn>QString <a href="#arg-d"><b>arg</b></a> ( const QString & a1, const QString & a2 ) const</li>
|
---|
| 75 | <li class=fn>QString <a href="#arg-e"><b>arg</b></a> ( const QString & a1, const QString & a2, const QString & a3 ) const</li>
|
---|
| 76 | <li class=fn>QString <a href="#arg-f"><b>arg</b></a> ( const QString & a1, const QString & a2, const QString & a3, const QString & a4 ) const</li>
|
---|
| 77 | <li class=fn>QString & <a href="#sprintf"><b>sprintf</b></a> ( const char * cformat, ... )</li>
|
---|
| 78 | <li class=fn>int <a href="#find-2"><b>find</b></a> ( QChar c, int index = 0, bool cs = TRUE ) const</li>
|
---|
| 79 | <li class=fn>int <a href="#find-3"><b>find</b></a> ( char c, int index = 0, bool cs = TRUE ) const</li>
|
---|
| 80 | <li class=fn>int <a href="#find-4"><b>find</b></a> ( const QString & str, int index = 0, bool cs = TRUE ) const</li>
|
---|
| 81 | <li class=fn>int <a href="#find"><b>find</b></a> ( const QRegExp & rx, int index = 0 ) const</li>
|
---|
| 82 | <li class=fn>int <a href="#find-5"><b>find</b></a> ( const char * str, int index = 0 ) const</li>
|
---|
| 83 | <li class=fn>int <a href="#findRev-2"><b>findRev</b></a> ( QChar c, int index = -1, bool cs = TRUE ) const</li>
|
---|
| 84 | <li class=fn>int <a href="#findRev-3"><b>findRev</b></a> ( char c, int index = -1, bool cs = TRUE ) const</li>
|
---|
| 85 | <li class=fn>int <a href="#findRev-4"><b>findRev</b></a> ( const QString & str, int index = -1, bool cs = TRUE ) const</li>
|
---|
| 86 | <li class=fn>int <a href="#findRev-5"><b>findRev</b></a> ( const QRegExp & rx, int index = -1 ) const</li>
|
---|
| 87 | <li class=fn>int <a href="#findRev"><b>findRev</b></a> ( const char * str, int index = -1 ) const</li>
|
---|
| 88 | <li class=fn>int <a href="#contains"><b>contains</b></a> ( QChar c, bool cs = TRUE ) const</li>
|
---|
| 89 | <li class=fn>int <a href="#contains-2"><b>contains</b></a> ( char c, bool cs = TRUE ) const</li>
|
---|
| 90 | <li class=fn>int <a href="#contains-3"><b>contains</b></a> ( const char * str, bool cs = TRUE ) const</li>
|
---|
| 91 | <li class=fn>int <a href="#contains-4"><b>contains</b></a> ( const QString & str, bool cs = TRUE ) const</li>
|
---|
| 92 | <li class=fn>int <a href="#contains-5"><b>contains</b></a> ( const QRegExp & rx ) const</li>
|
---|
| 93 | <li class=fn>enum <a href="#SectionFlags-enum"><b>SectionFlags</b></a> { SectionDefault = 0x00, SectionSkipEmpty = 0x01, SectionIncludeLeadingSep = 0x02, SectionIncludeTrailingSep = 0x04, SectionCaseInsensitiveSeps = 0x08 }</li>
|
---|
| 94 | <li class=fn>QString <a href="#section"><b>section</b></a> ( QChar sep, int start, int end = 0xffffffff, int flags = SectionDefault ) const</li>
|
---|
| 95 | <li class=fn>QString <a href="#section-2"><b>section</b></a> ( char sep, int start, int end = 0xffffffff, int flags = SectionDefault ) const</li>
|
---|
| 96 | <li class=fn>QString <a href="#section-3"><b>section</b></a> ( const char * sep, int start, int end = 0xffffffff, int flags = SectionDefault ) const</li>
|
---|
| 97 | <li class=fn>QString <a href="#section-4"><b>section</b></a> ( const QString & sep, int start, int end = 0xffffffff, int flags = SectionDefault ) const</li>
|
---|
| 98 | <li class=fn>QString <a href="#section-5"><b>section</b></a> ( const QRegExp & reg, int start, int end = 0xffffffff, int flags = SectionDefault ) const</li>
|
---|
| 99 | <li class=fn>QString <a href="#left"><b>left</b></a> ( uint len ) const</li>
|
---|
| 100 | <li class=fn>QString <a href="#right"><b>right</b></a> ( uint len ) const</li>
|
---|
| 101 | <li class=fn>QString <a href="#mid"><b>mid</b></a> ( uint index, uint len = 0xffffffff ) const</li>
|
---|
| 102 | <li class=fn>QString <a href="#leftJustify"><b>leftJustify</b></a> ( uint width, QChar fill = ' ', bool truncate = FALSE ) const</li>
|
---|
| 103 | <li class=fn>QString <a href="#rightJustify"><b>rightJustify</b></a> ( uint width, QChar fill = ' ', bool truncate = FALSE ) const</li>
|
---|
| 104 | <li class=fn>QString <a href="#lower"><b>lower</b></a> () const</li>
|
---|
| 105 | <li class=fn>QString <a href="#upper"><b>upper</b></a> () const</li>
|
---|
| 106 | <li class=fn>QString <a href="#stripWhiteSpace"><b>stripWhiteSpace</b></a> () const</li>
|
---|
| 107 | <li class=fn>QString <a href="#simplifyWhiteSpace"><b>simplifyWhiteSpace</b></a> () const</li>
|
---|
| 108 | <li class=fn>QString & <a href="#insert"><b>insert</b></a> ( uint index, const QString & s )</li>
|
---|
| 109 | <li class=fn>QString & <a href="#insert-2"><b>insert</b></a> ( uint index, const QByteArray & s )</li>
|
---|
| 110 | <li class=fn>QString & <a href="#insert-3"><b>insert</b></a> ( uint index, const char * s )</li>
|
---|
| 111 | <li class=fn>QString & <a href="#insert-4"><b>insert</b></a> ( uint index, const QChar * s, uint len )</li>
|
---|
| 112 | <li class=fn>QString & <a href="#insert-5"><b>insert</b></a> ( uint index, QChar c )</li>
|
---|
| 113 | <li class=fn>QString & <a href="#insert-6"><b>insert</b></a> ( uint index, char c )</li>
|
---|
| 114 | <li class=fn>QString & <a href="#append-2"><b>append</b></a> ( char ch )</li>
|
---|
| 115 | <li class=fn>QString & <a href="#append-3"><b>append</b></a> ( QChar ch )</li>
|
---|
| 116 | <li class=fn>QString & <a href="#append"><b>append</b></a> ( const QString & str )</li>
|
---|
| 117 | <li class=fn>QString & <a href="#append-4"><b>append</b></a> ( const QByteArray & str )</li>
|
---|
| 118 | <li class=fn>QString & <a href="#append-5"><b>append</b></a> ( const char * str )</li>
|
---|
| 119 | <li class=fn>QString & <a href="#append-6"><b>append</b></a> ( const std::string & str )</li>
|
---|
| 120 | <li class=fn>QString & <a href="#prepend-2"><b>prepend</b></a> ( char ch )</li>
|
---|
| 121 | <li class=fn>QString & <a href="#prepend-3"><b>prepend</b></a> ( QChar ch )</li>
|
---|
| 122 | <li class=fn>QString & <a href="#prepend"><b>prepend</b></a> ( const QString & s )</li>
|
---|
| 123 | <li class=fn>QString & <a href="#prepend-4"><b>prepend</b></a> ( const QByteArray & s )</li>
|
---|
| 124 | <li class=fn>QString & <a href="#prepend-5"><b>prepend</b></a> ( const char * s )</li>
|
---|
| 125 | <li class=fn>QString & <a href="#prepend-6"><b>prepend</b></a> ( const std::string & s )</li>
|
---|
| 126 | <li class=fn>QString & <a href="#remove"><b>remove</b></a> ( uint index, uint len )</li>
|
---|
| 127 | <li class=fn>QString & <a href="#remove-2"><b>remove</b></a> ( const QString & str, bool cs = TRUE )</li>
|
---|
| 128 | <li class=fn>QString & <a href="#remove-3"><b>remove</b></a> ( QChar c )</li>
|
---|
| 129 | <li class=fn>QString & <a href="#remove-4"><b>remove</b></a> ( char c )</li>
|
---|
| 130 | <li class=fn>QString & <a href="#remove-5"><b>remove</b></a> ( const char * str )</li>
|
---|
| 131 | <li class=fn>QString & <a href="#remove-6"><b>remove</b></a> ( const QRegExp & rx )</li>
|
---|
| 132 | <li class=fn>QString & <a href="#replace"><b>replace</b></a> ( uint index, uint len, const QString & s )</li>
|
---|
| 133 | <li class=fn>QString & <a href="#replace-2"><b>replace</b></a> ( uint index, uint len, const QChar * s, uint slen )</li>
|
---|
| 134 | <li class=fn>QString & <a href="#replace-3"><b>replace</b></a> ( uint index, uint len, QChar c )</li>
|
---|
| 135 | <li class=fn>QString & <a href="#replace-4"><b>replace</b></a> ( uint index, uint len, char c )</li>
|
---|
| 136 | <li class=fn>QString & <a href="#replace-5"><b>replace</b></a> ( QChar c, const QString & after, bool cs = TRUE )</li>
|
---|
| 137 | <li class=fn>QString & <a href="#replace-6"><b>replace</b></a> ( char c, const QString & after, bool cs = TRUE )</li>
|
---|
| 138 | <li class=fn>QString & <a href="#replace-7"><b>replace</b></a> ( const QString & before, const QString & after, bool cs = TRUE )</li>
|
---|
| 139 | <li class=fn>QString & <a href="#replace-8"><b>replace</b></a> ( const QRegExp & rx, const QString & after )</li>
|
---|
| 140 | <li class=fn>QString & <a href="#replace-9"><b>replace</b></a> ( QChar c1, QChar c2 )</li>
|
---|
| 141 | <li class=fn>short <a href="#toShort"><b>toShort</b></a> ( bool * ok = 0, int base = 10 ) const</li>
|
---|
| 142 | <li class=fn>ushort <a href="#toUShort"><b>toUShort</b></a> ( bool * ok = 0, int base = 10 ) const</li>
|
---|
| 143 | <li class=fn>int <a href="#toInt"><b>toInt</b></a> ( bool * ok = 0, int base = 10 ) const</li>
|
---|
| 144 | <li class=fn>uint <a href="#toUInt"><b>toUInt</b></a> ( bool * ok = 0, int base = 10 ) const</li>
|
---|
| 145 | <li class=fn>long <a href="#toLong"><b>toLong</b></a> ( bool * ok = 0, int base = 10 ) const</li>
|
---|
| 146 | <li class=fn>ulong <a href="#toULong"><b>toULong</b></a> ( bool * ok = 0, int base = 10 ) const</li>
|
---|
| 147 | <li class=fn>Q_LLONG <a href="#toLongLong"><b>toLongLong</b></a> ( bool * ok = 0, int base = 10 ) const</li>
|
---|
| 148 | <li class=fn>Q_ULLONG <a href="#toULongLong"><b>toULongLong</b></a> ( bool * ok = 0, int base = 10 ) const</li>
|
---|
| 149 | <li class=fn>float <a href="#toFloat"><b>toFloat</b></a> ( bool * ok = 0 ) const</li>
|
---|
| 150 | <li class=fn>double <a href="#toDouble"><b>toDouble</b></a> ( bool * ok = 0 ) const</li>
|
---|
| 151 | <li class=fn>QString & <a href="#setNum-2"><b>setNum</b></a> ( short n, int base = 10 )</li>
|
---|
| 152 | <li class=fn>QString & <a href="#setNum-3"><b>setNum</b></a> ( ushort n, int base = 10 )</li>
|
---|
| 153 | <li class=fn>QString & <a href="#setNum-4"><b>setNum</b></a> ( int n, int base = 10 )</li>
|
---|
| 154 | <li class=fn>QString & <a href="#setNum-5"><b>setNum</b></a> ( uint n, int base = 10 )</li>
|
---|
| 155 | <li class=fn>QString & <a href="#setNum-6"><b>setNum</b></a> ( long n, int base = 10 )</li>
|
---|
| 156 | <li class=fn>QString & <a href="#setNum-7"><b>setNum</b></a> ( ulong n, int base = 10 )</li>
|
---|
| 157 | <li class=fn>QString & <a href="#setNum"><b>setNum</b></a> ( Q_LLONG n, int base = 10 )</li>
|
---|
| 158 | <li class=fn>QString & <a href="#setNum-8"><b>setNum</b></a> ( Q_ULLONG n, int base = 10 )</li>
|
---|
| 159 | <li class=fn>QString & <a href="#setNum-9"><b>setNum</b></a> ( float n, char f = 'g', int prec = 6 )</li>
|
---|
| 160 | <li class=fn>QString & <a href="#setNum-a"><b>setNum</b></a> ( double n, char f = 'g', int prec = 6 )</li>
|
---|
| 161 | <li class=fn>void setExpand ( uint index, QChar c ) <em>(obsolete)</em></li>
|
---|
| 162 | <li class=fn>QString & <a href="#operator+-eq"><b>operator+=</b></a> ( const QString & str )</li>
|
---|
| 163 | <li class=fn>QString & <a href="#operator+-eq-2"><b>operator+=</b></a> ( const QByteArray & str )</li>
|
---|
| 164 | <li class=fn>QString & <a href="#operator+-eq-3"><b>operator+=</b></a> ( const char * str )</li>
|
---|
| 165 | <li class=fn>QString & <a href="#operator+-eq-4"><b>operator+=</b></a> ( const std::string & str )</li>
|
---|
| 166 | <li class=fn>QString & <a href="#operator+-eq-5"><b>operator+=</b></a> ( QChar c )</li>
|
---|
| 167 | <li class=fn>QString & <a href="#operator+-eq-6"><b>operator+=</b></a> ( char c )</li>
|
---|
| 168 | <li class=fn>QChar <a href="#at"><b>at</b></a> ( uint i ) const</li>
|
---|
| 169 | <li class=fn>QChar <a href="#operator[]"><b>operator[]</b></a> ( int i ) const</li>
|
---|
| 170 | <li class=fn>QCharRef <a href="#at-2"><b>at</b></a> ( uint i )</li>
|
---|
| 171 | <li class=fn>QCharRef <a href="#operator[]-2"><b>operator[]</b></a> ( int i )</li>
|
---|
| 172 | <li class=fn>QChar <a href="#constref"><b>constref</b></a> ( uint i ) const</li>
|
---|
| 173 | <li class=fn>QChar & <a href="#ref"><b>ref</b></a> ( uint i )</li>
|
---|
| 174 | <li class=fn>const QChar * <a href="#unicode"><b>unicode</b></a> () const</li>
|
---|
| 175 | <li class=fn>const char * <a href="#ascii"><b>ascii</b></a> () const</li>
|
---|
| 176 | <li class=fn>const char * <a href="#latin1"><b>latin1</b></a> () const</li>
|
---|
| 177 | <li class=fn>QCString <a href="#utf8"><b>utf8</b></a> () const</li>
|
---|
| 178 | <li class=fn>QCString <a href="#local8Bit"><b>local8Bit</b></a> () const</li>
|
---|
| 179 | <li class=fn>bool <a href="#operator!"><b>operator!</b></a> () const</li>
|
---|
| 180 | <li class=fn><a href="#operator-const-char-*"><b>operator const char *</b></a> () const</li>
|
---|
| 181 | <li class=fn><a href="#operator-std::string"><b>operator std::string</b></a> () const</li>
|
---|
| 182 | <li class=fn>const unsigned short * <a href="#ucs2"><b>ucs2</b></a> () const</li>
|
---|
| 183 | <li class=fn>QString & <a href="#setUnicode"><b>setUnicode</b></a> ( const QChar * unicode, uint len )</li>
|
---|
| 184 | <li class=fn>QString & <a href="#setUnicodeCodes"><b>setUnicodeCodes</b></a> ( const ushort * unicode_as_ushorts, uint len )</li>
|
---|
| 185 | <li class=fn>QString & <a href="#setAscii"><b>setAscii</b></a> ( const char * str, int len = -1 )</li>
|
---|
| 186 | <li class=fn>QString & <a href="#setLatin1"><b>setLatin1</b></a> ( const char * str, int len = -1 )</li>
|
---|
| 187 | <li class=fn>int <a href="#compare-2"><b>compare</b></a> ( const QString & s ) const</li>
|
---|
| 188 | <li class=fn>int <a href="#localeAwareCompare-2"><b>localeAwareCompare</b></a> ( const QString & s ) const</li>
|
---|
| 189 | <li class=fn>void <a href="#compose"><b>compose</b></a> ()</li>
|
---|
| 190 | <li class=fn>const char * data () const <em>(obsolete)</em></li>
|
---|
| 191 | <li class=fn>bool <a href="#startsWith"><b>startsWith</b></a> ( const QString & s, bool cs = TRUE ) const</li>
|
---|
| 192 | <li class=fn>bool <a href="#endsWith"><b>endsWith</b></a> ( const QString & s, bool cs = TRUE ) const</li>
|
---|
| 193 | <li class=fn>void <a href="#setLength"><b>setLength</b></a> ( uint newLen )</li>
|
---|
| 194 | <li class=fn>uint <a href="#capacity"><b>capacity</b></a> () const</li>
|
---|
| 195 | <li class=fn>void <a href="#reserve"><b>reserve</b></a> ( uint minCapacity )</li>
|
---|
| 196 | <li class=fn>void <a href="#squeeze"><b>squeeze</b></a> ()</li>
|
---|
| 197 | </ul>
|
---|
| 198 | <h2>Static Public Members</h2>
|
---|
| 199 | <ul>
|
---|
| 200 | <li class=fn>QString <a href="#number"><b>number</b></a> ( long n, int base = 10 )</li>
|
---|
| 201 | <li class=fn>QString <a href="#number-2"><b>number</b></a> ( ulong n, int base = 10 )</li>
|
---|
| 202 | <li class=fn>QString <a href="#number-3"><b>number</b></a> ( Q_LLONG n, int base = 10 )</li>
|
---|
| 203 | <li class=fn>QString <a href="#number-4"><b>number</b></a> ( Q_ULLONG n, int base = 10 )</li>
|
---|
| 204 | <li class=fn>QString <a href="#number-5"><b>number</b></a> ( int n, int base = 10 )</li>
|
---|
| 205 | <li class=fn>QString <a href="#number-6"><b>number</b></a> ( uint n, int base = 10 )</li>
|
---|
| 206 | <li class=fn>QString <a href="#number-7"><b>number</b></a> ( double n, char f = 'g', int prec = 6 )</li>
|
---|
| 207 | <li class=fn>QString <a href="#fromAscii"><b>fromAscii</b></a> ( const char * ascii, int len = -1 )</li>
|
---|
| 208 | <li class=fn>QString <a href="#fromLatin1"><b>fromLatin1</b></a> ( const char * chars, int len = -1 )</li>
|
---|
| 209 | <li class=fn>QString <a href="#fromUtf8"><b>fromUtf8</b></a> ( const char * utf8, int len = -1 )</li>
|
---|
| 210 | <li class=fn>QString <a href="#fromLocal8Bit"><b>fromLocal8Bit</b></a> ( const char * local8Bit, int len = -1 )</li>
|
---|
| 211 | <li class=fn>QString <a href="#fromUcs2"><b>fromUcs2</b></a> ( const unsigned short * str )</li>
|
---|
| 212 | <li class=fn>int <a href="#compare"><b>compare</b></a> ( const QString & s1, const QString & s2 )</li>
|
---|
| 213 | <li class=fn>int <a href="#localeAwareCompare"><b>localeAwareCompare</b></a> ( const QString & s1, const QString & s2 )</li>
|
---|
| 214 | </ul>
|
---|
| 215 | <h2>Related Functions</h2>
|
---|
| 216 | <ul>
|
---|
| 217 | <li class=fn>bool <a href="#operator-eq-eq"><b>operator==</b></a> ( const QString & s1, const QString & s2 )</li>
|
---|
| 218 | <li class=fn>bool <a href="#operator-eq-eq-2"><b>operator==</b></a> ( const QString & s1, const char * s2 )</li>
|
---|
| 219 | <li class=fn>bool <a href="#operator-eq-eq-3"><b>operator==</b></a> ( const char * s1, const QString & s2 )</li>
|
---|
| 220 | <li class=fn>bool <a href="#operator!-eq"><b>operator!=</b></a> ( const QString & s1, const QString & s2 )</li>
|
---|
| 221 | <li class=fn>bool <a href="#operator!-eq-2"><b>operator!=</b></a> ( const QString & s1, const char * s2 )</li>
|
---|
| 222 | <li class=fn>bool <a href="#operator!-eq-3"><b>operator!=</b></a> ( const char * s1, const QString & s2 )</li>
|
---|
| 223 | <li class=fn>bool <a href="#operator-lt"><b>operator<</b></a> ( const QString & s1, const char * s2 )</li>
|
---|
| 224 | <li class=fn>bool <a href="#operator-lt-2"><b>operator<</b></a> ( const char * s1, const QString & s2 )</li>
|
---|
| 225 | <li class=fn>bool <a href="#operator-lt-eq"><b>operator<=</b></a> ( const QString & s1, const char * s2 )</li>
|
---|
| 226 | <li class=fn>bool <a href="#operator-lt-eq-2"><b>operator<=</b></a> ( const char * s1, const QString & s2 )</li>
|
---|
| 227 | <li class=fn>bool <a href="#operator-gt"><b>operator></b></a> ( const QString & s1, const char * s2 )</li>
|
---|
| 228 | <li class=fn>bool <a href="#operator-gt-2"><b>operator></b></a> ( const char * s1, const QString & s2 )</li>
|
---|
| 229 | <li class=fn>bool <a href="#operator-gt-eq"><b>operator>=</b></a> ( const QString & s1, const char * s2 )</li>
|
---|
| 230 | <li class=fn>bool <a href="#operator-gt-eq-2"><b>operator>=</b></a> ( const char * s1, const QString & s2 )</li>
|
---|
| 231 | <li class=fn>const QString <a href="#operator+"><b>operator+</b></a> ( const QString & s1, const QString & s2 )</li>
|
---|
| 232 | <li class=fn>const QString <a href="#operator+-2"><b>operator+</b></a> ( const QString & s1, const char * s2 )</li>
|
---|
| 233 | <li class=fn>const QString <a href="#operator+-3"><b>operator+</b></a> ( const char * s1, const QString & s2 )</li>
|
---|
| 234 | <li class=fn>const QString <a href="#operator+-4"><b>operator+</b></a> ( const QString & s, char c )</li>
|
---|
| 235 | <li class=fn>const QString <a href="#operator+-5"><b>operator+</b></a> ( char c, const QString & s )</li>
|
---|
| 236 | <li class=fn>QDataStream & <a href="#operator-lt-lt"><b>operator<<</b></a> ( QDataStream & s, const QString & str )</li>
|
---|
| 237 | <li class=fn>QDataStream & <a href="#operator-gt-gt"><b>operator>></b></a> ( QDataStream & s, QString & str )</li>
|
---|
| 238 | </ul>
|
---|
| 239 | <hr><a name="details"></a><h2>Detailed Description</h2>
|
---|
| 240 |
|
---|
| 241 |
|
---|
| 242 |
|
---|
| 243 | <p> The QString class provides an abstraction of Unicode text
|
---|
| 244 | and the classic C '\0'-terminated char array.
|
---|
| 245 | <p>
|
---|
| 246 |
|
---|
| 247 |
|
---|
| 248 |
|
---|
| 249 | <p> QString uses <a href="shclass.html">implicit sharing</a>, which
|
---|
| 250 | makes it very efficient and easy to use.
|
---|
| 251 | <p> In all of the QString methods that take <tt>const char *</tt>
|
---|
| 252 | parameters, the <tt>const char *</tt> is interpreted as a classic
|
---|
| 253 | 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
|
---|
| 254 | '\0'-terminated, the results are undefined. Functions that copy
|
---|
| 255 | classic C strings into a QString will not copy the terminating
|
---|
| 256 | '\0' character. The <a href="qchar.html">QChar</a> array of the QString (as returned by
|
---|
| 257 | <a href="#unicode">unicode</a>()) is generally not terminated by a '\0'. If you need to
|
---|
| 258 | pass a QString to a function that requires a C '\0'-terminated
|
---|
| 259 | string use <a href="#latin1">latin1</a>().
|
---|
| 260 | <p> <!-- index QString::null --><a name="QString-null"></a>A QString that has not been assigned to anything is <em>null</em>, i.e.
|
---|
| 261 | both the length and data pointer is 0. A QString that references
|
---|
| 262 | the empty string ("", a single '\0' char) is <em>empty</em>. Both null
|
---|
| 263 | and empty QStrings are legal parameters to the methods. Assigning
|
---|
| 264 | <tt>(const char *) 0</tt> to QString gives a null QString. For
|
---|
| 265 | convenience, <a href="qstring.html#QString-null">QString::null</a> is a null QString. When sorting,
|
---|
| 266 | empty strings come first, followed by non-empty strings, followed
|
---|
| 267 | by null strings. We recommend using <tt>if ( !str.isNull() )</tt> to
|
---|
| 268 | check for a non-null string rather than <tt>if ( !str )</tt>; see <a href="#operator!">operator!</a>() for an explanation.
|
---|
| 269 | <p> Note that if you find that you are mixing usage of <a href="qcstring.html">QCString</a>,
|
---|
| 270 | QString, and <a href="qbytearray.html">QByteArray</a>, this causes lots of unnecessary
|
---|
| 271 | copying and might indicate that the true nature of the data you
|
---|
| 272 | are dealing with is uncertain. If the data is '\0'-terminated 8-bit
|
---|
| 273 | data, use <a href="qcstring.html">QCString</a>; if it is unterminated (i.e. contains '\0's)
|
---|
| 274 | 8-bit data, use <a href="qbytearray.html">QByteArray</a>; if it is text, use QString.
|
---|
| 275 | <p> Lists of strings are handled by the <a href="qstringlist.html">QStringList</a> class. You can
|
---|
| 276 | split a string into a list of strings using <a href="qstringlist.html#split">QStringList::split</a>(),
|
---|
| 277 | and join a list of strings into a single string with an optional
|
---|
| 278 | separator using <a href="qstringlist.html#join">QStringList::join</a>(). You can obtain a list of
|
---|
| 279 | strings from a string list that contain a particular substring or
|
---|
| 280 | that match a particular <a href="qregexp.html">regex</a> using
|
---|
| 281 | <a href="qstringlist.html#grep">QStringList::grep</a>().
|
---|
| 282 | <p> <b>Note for C programmers</b>
|
---|
| 283 | <p> Due to C++'s type system and the fact that QString is <a href="shclass.html#implicitly-shared">implicitly shared</a>, QStrings can be treated like ints or other simple base
|
---|
| 284 | types. For example:
|
---|
| 285 | <p> <pre>
|
---|
| 286 | QString boolToString( bool b )
|
---|
| 287 | {
|
---|
| 288 | QString result;
|
---|
| 289 | if ( b )
|
---|
| 290 | result = "True";
|
---|
| 291 | else
|
---|
| 292 | result = "False";
|
---|
| 293 | return result;
|
---|
| 294 | }
|
---|
| 295 | </pre>
|
---|
| 296 |
|
---|
| 297 | <p> The variable, result, is an auto variable allocated on the stack.
|
---|
| 298 | When return is called, because we're returning by value, The copy
|
---|
| 299 | constructor is called and a copy of the string is returned. (No
|
---|
| 300 | actual copying takes place thanks to the <a href="shclass.html#implicit-sharing">implicit sharing</a>, see
|
---|
| 301 | below.)
|
---|
| 302 | <p> Throughout Qt's source code you will encounter QString usages like
|
---|
| 303 | this:
|
---|
| 304 | <pre>
|
---|
| 305 | QString func( const QString& input )
|
---|
| 306 | {
|
---|
| 307 | QString output = input;
|
---|
| 308 | // process output
|
---|
| 309 | return output;
|
---|
| 310 | }
|
---|
| 311 | </pre>
|
---|
| 312 |
|
---|
| 313 | <p> The 'copying' of input to output is almost as fast as copying a
|
---|
| 314 | pointer because behind the scenes copying is achieved by
|
---|
| 315 | incrementing a reference count. QString (like all Qt's implicitly
|
---|
| 316 | shared classes) operates on a copy-on-write basis, only copying if
|
---|
| 317 | an instance is actually changed.
|
---|
| 318 | <p> If you wish to create a <a href="shclass.html#deep-copy">deep copy</a> of a QString without losing any
|
---|
| 319 | Unicode information then you should use <a href="qdeepcopy.html">QDeepCopy</a>.
|
---|
| 320 | <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>.
|
---|
| 321 |
|
---|
| 322 | <hr><h2>Member Type Documentation</h2>
|
---|
| 323 | <h3 class=fn><a name="SectionFlags-enum"></a>QString::SectionFlags</h3>
|
---|
| 324 |
|
---|
| 325 | <ul>
|
---|
| 326 | <li><tt>QString::SectionDefault</tt> - Empty fields are counted, leading and
|
---|
| 327 | trailing separators are not included, and the separator is
|
---|
| 328 | compared case sensitively.
|
---|
| 329 | <li><tt>QString::SectionSkipEmpty</tt> - Treat empty fields as if they don't exist,
|
---|
| 330 | i.e. they are not considered as far as <em>start</em> and <em>end</em> are
|
---|
| 331 | concerned.
|
---|
| 332 | <li><tt>QString::SectionIncludeLeadingSep</tt> - Include the leading separator (if
|
---|
| 333 | any) in the result string.
|
---|
| 334 | <li><tt>QString::SectionIncludeTrailingSep</tt> - Include the trailing separator
|
---|
| 335 | (if any) in the result string.
|
---|
| 336 | <li><tt>QString::SectionCaseInsensitiveSeps</tt> - Compare the separator
|
---|
| 337 | case-insensitively.
|
---|
| 338 | </ul><p> Any of the last four values can be OR-ed together to form a flag.
|
---|
| 339 | <p> <p>See also <a href="#section">section</a>().
|
---|
| 340 |
|
---|
| 341 | <hr><h2>Member Function Documentation</h2>
|
---|
| 342 | <h3 class=fn><a name="QString"></a>QString::QString ()
|
---|
| 343 | </h3>
|
---|
| 344 |
|
---|
| 345 | <p> Constructs a null string, i.e. both the length and data pointer
|
---|
| 346 | are 0.
|
---|
| 347 | <p> <p>See also <a href="#isNull">isNull</a>().
|
---|
| 348 |
|
---|
| 349 | <h3 class=fn><a name="QString-2"></a>QString::QString ( <a href="qchar.html">QChar</a> ch )
|
---|
| 350 | </h3>
|
---|
| 351 | Constructs a string of length one, containing the character <em>ch</em>.
|
---|
| 352 |
|
---|
| 353 | <h3 class=fn><a name="QString-3"></a>QString::QString ( const <a href="qstring.html">QString</a> & s )
|
---|
| 354 | </h3>
|
---|
| 355 | Constructs an <a href="shclass.html#implicitly-shared">implicitly shared</a> copy of <em>s</em>. This is very fast
|
---|
| 356 | since it only involves incrementing a reference count.
|
---|
| 357 |
|
---|
| 358 | <h3 class=fn><a name="QString-4"></a>QString::QString ( const <a href="qbytearray.html">QByteArray</a> & ba )
|
---|
| 359 | </h3>
|
---|
| 360 | Constructs a string that is a <a href="shclass.html#deep-copy">deep copy</a> of <em>ba</em> interpreted as a
|
---|
| 361 | classic C string.
|
---|
| 362 |
|
---|
| 363 | <h3 class=fn><a name="QString-5"></a>QString::QString ( const <a href="qchar.html">QChar</a> * unicode, uint length )
|
---|
| 364 | </h3>
|
---|
| 365 | Constructs a string that is a <a href="shclass.html#deep-copy">deep copy</a> of the first <em>length</em>
|
---|
| 366 | characters in the <a href="qchar.html">QChar</a> array.
|
---|
| 367 | <p> If <em>unicode</em> and <em>length</em> are 0, then a null string is created.
|
---|
| 368 | <p> If only <em>unicode</em> is 0, the string is empty but has <em>length</em>
|
---|
| 369 | characters of space preallocated: QString expands automatically
|
---|
| 370 | anyway, but this may speed up some cases a little. We recommend
|
---|
| 371 | using the plain constructor and <a href="#setLength">setLength</a>() for this purpose since
|
---|
| 372 | it will result in more readable code.
|
---|
| 373 | <p> <p>See also <a href="#isNull">isNull</a>() and <a href="#setLength">setLength</a>().
|
---|
| 374 |
|
---|
| 375 | <h3 class=fn><a name="QString-6"></a>QString::QString ( const char * str )
|
---|
| 376 | </h3>
|
---|
| 377 | Constructs a string that is a <a href="shclass.html#deep-copy">deep copy</a> of <em>str</em>, interpreted as
|
---|
| 378 | a classic C string. The encoding is assumed to be Latin-1, unless
|
---|
| 379 | you change it using <a href="qtextcodec.html#setCodecForCStrings">QTextCodec::setCodecForCStrings</a>().
|
---|
| 380 | <p> If <em>str</em> is 0, then a null string is created.
|
---|
| 381 | <p> This is a cast constructor, but it is perfectly safe: converting a
|
---|
| 382 | Latin-1 <tt>const char *</tt> to QString preserves all the information. You
|
---|
| 383 | can disable this constructor by defining <tt>QT_NO_CAST_ASCII</tt> when
|
---|
| 384 | you compile your applications. You can also make QString objects
|
---|
| 385 | by using <a href="#setLatin1">setLatin1</a>(), <a href="#fromLatin1">fromLatin1</a>(), <a href="#fromLocal8Bit">fromLocal8Bit</a>(), and
|
---|
| 386 | <a href="#fromUtf8">fromUtf8</a>(). Or whatever encoding is appropriate for the 8-bit data
|
---|
| 387 | you have.
|
---|
| 388 | <p> <p>See also <a href="#isNull">isNull</a>() and <a href="#fromAscii">fromAscii</a>().
|
---|
| 389 |
|
---|
| 390 | <h3 class=fn><a name="QString-7"></a>QString::QString ( const std::string & str )
|
---|
| 391 | </h3>
|
---|
| 392 | Constructs a string that is a <a href="shclass.html#deep-copy">deep copy</a> of <em>str</em>.
|
---|
| 393 | <p> This is the same as <a href="#fromAscii">fromAscii</a>(<em>str</em>).
|
---|
| 394 |
|
---|
| 395 | <h3 class=fn><a name="~QString"></a>QString::~QString ()
|
---|
| 396 | </h3>
|
---|
| 397 |
|
---|
| 398 | <p> Destroys the string and frees the string's data if this is the
|
---|
| 399 | last reference to the string.
|
---|
| 400 |
|
---|
| 401 | <h3 class=fn><a href="qstring.html">QString</a> & <a name="append"></a>QString::append ( const <a href="qstring.html">QString</a> & str )
|
---|
| 402 | </h3>
|
---|
| 403 |
|
---|
| 404 | <p> Appends <em>str</em> to the string and returns a reference to the
|
---|
| 405 | result.
|
---|
| 406 | <p> <pre>
|
---|
| 407 | string = "Test";
|
---|
| 408 | string.append( "ing" ); // string == "Testing"
|
---|
| 409 | </pre>
|
---|
| 410 |
|
---|
| 411 | <p> Equivalent to <a href="#operator+-eq">operator+=</a>().
|
---|
| 412 |
|
---|
| 413 | <p>Example: <a href="dirview-example.html#x1701">dirview/dirview.cpp</a>.
|
---|
| 414 | <h3 class=fn><a href="qstring.html">QString</a> & <a name="append-2"></a>QString::append ( char ch )
|
---|
| 415 | </h3>
|
---|
| 416 |
|
---|
| 417 | <p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 418 | <p> Appends character <em>ch</em> to the string and returns a reference to
|
---|
| 419 | the result.
|
---|
| 420 | <p> Equivalent to <a href="#operator+-eq">operator+=</a>().
|
---|
| 421 |
|
---|
| 422 | <h3 class=fn><a href="qstring.html">QString</a> & <a name="append-3"></a>QString::append ( <a href="qchar.html">QChar</a> ch )
|
---|
| 423 | </h3>
|
---|
| 424 |
|
---|
| 425 | <p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 426 | <p> Appends character <em>ch</em> to the string and returns a reference to
|
---|
| 427 | the result.
|
---|
| 428 | <p> Equivalent to <a href="#operator+-eq">operator+=</a>().
|
---|
| 429 |
|
---|
| 430 | <h3 class=fn><a href="qstring.html">QString</a> & <a name="append-4"></a>QString::append ( const <a href="qbytearray.html">QByteArray</a> & str )
|
---|
| 431 | </h3>
|
---|
| 432 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 433 | <p> Appends <em>str</em> to the string and returns a reference to the result.
|
---|
| 434 | <p> Equivalent to <a href="#operator+-eq">operator+=</a>().
|
---|
| 435 |
|
---|
| 436 | <h3 class=fn><a href="qstring.html">QString</a> & <a name="append-5"></a>QString::append ( const char * str )
|
---|
| 437 | </h3>
|
---|
| 438 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 439 | <p> Appends <em>str</em> to the string and returns a reference to the result.
|
---|
| 440 | <p> Equivalent to <a href="#operator+-eq">operator+=</a>().
|
---|
| 441 |
|
---|
| 442 | <h3 class=fn><a href="qstring.html">QString</a> & <a name="append-6"></a>QString::append ( const std::string & str )
|
---|
| 443 | </h3>
|
---|
| 444 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 445 | <p> Appends <em>str</em> to the string and returns a reference to the result.
|
---|
| 446 | <p> Equivalent to <a href="#operator+-eq">operator+=</a>().
|
---|
| 447 |
|
---|
| 448 | <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
|
---|
| 449 | </h3>
|
---|
| 450 | This function will return a string that replaces the lowest
|
---|
| 451 | numbered occurrence of <tt>%1</tt>, <tt>%2</tt>, ..., <tt>%9</tt> with <em>a</em>.
|
---|
| 452 | <p> The <em>fieldWidth</em> value specifies the minimum amount of space that
|
---|
| 453 | <em>a</em> is padded to. A positive value will produce right-aligned
|
---|
| 454 | text, whereas a negative value will produce left-aligned text.
|
---|
| 455 | <p> The following example shows how we could create a 'status' string
|
---|
| 456 | when processing a list of files:
|
---|
| 457 | <pre>
|
---|
| 458 | QString status = <a href="#QString">QString</a>( "Processing file %1 of %2: %3" )
|
---|
| 459 | .arg( i ) // current file's number
|
---|
| 460 | .arg( total ) // number of files to process
|
---|
| 461 | .arg( fileName ); // current file's name
|
---|
| 462 | </pre>
|
---|
| 463 |
|
---|
| 464 | <p> It is generally fine to use filenames and numbers as we have done
|
---|
| 465 | in the example above. But note that using <a href="#arg">arg</a>() to construct
|
---|
| 466 | natural language sentences does not usually translate well into
|
---|
| 467 | other languages because sentence structure and word order often
|
---|
| 468 | differ between languages.
|
---|
| 469 | <p> If there is no place marker (<tt>%1</tt>, <tt>%2</tt>, etc.), a warning
|
---|
| 470 | message (<a href="qapplication.html#qWarning">qWarning</a>()) is output and the result is undefined.
|
---|
| 471 | <p> <b>Warning:</b> If any placeholder occurs more than once, the result is undefined.
|
---|
| 472 | <p>
|
---|
| 473 | <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
|
---|
| 474 | </h3>
|
---|
| 475 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 476 | <p> The <em>fieldWidth</em> value specifies the minimum amount of space that
|
---|
| 477 | <em>a</em> is padded to. A positive value will produce a right-aligned
|
---|
| 478 | number, whereas a negative value will produce a left-aligned
|
---|
| 479 | number.
|
---|
| 480 | <p> <em>a</em> is expressed in base <em>base</em>, which is 10 by default and must
|
---|
| 481 | be between 2 and 36.
|
---|
| 482 | <p> The '%' can be followed by an 'L', in which case the sequence is
|
---|
| 483 | replaced with a localized representation of <em>a</em>. The conversion
|
---|
| 484 | uses the default locale. The default locale is determined from the
|
---|
| 485 | system's locale settings at application startup. It can be changed
|
---|
| 486 | using <a href="qlocale.html#setDefault">QLocale::setDefault</a>(). The 'L' flag is ignored if <em>base</em> is
|
---|
| 487 | not 10.
|
---|
| 488 | <p> <pre>
|
---|
| 489 | QString str;
|
---|
| 490 | str = <a href="#QString">QString</a>( "Decimal 63 is %1 in hexadecimal" )
|
---|
| 491 | .arg( 63, 0, 16 );
|
---|
| 492 | // str == "Decimal 63 is 3f in hexadecimal"
|
---|
| 493 |
|
---|
| 494 | QLocale::<a href="qlocale.html#setDefault">setDefault</a>(QLocale::English, QLocale::UnitedStates);
|
---|
| 495 | str = <a href="#QString">QString</a>( "%1 %L2 %L3" )
|
---|
| 496 | .arg( 12345 )
|
---|
| 497 | .arg( 12345 )
|
---|
| 498 | .arg( 12345, 0, 16 );
|
---|
| 499 | // str == "12345 12,345 3039"
|
---|
| 500 | </pre>
|
---|
| 501 |
|
---|
| 502 |
|
---|
| 503 | <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
|
---|
| 504 | </h3>
|
---|
| 505 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 506 | <p> <em>a</em> is expressed in base <em>base</em>, which is 10 by default and must
|
---|
| 507 | be between 2 and 36. If <em>base</em> is 10, the '%L' syntax can be used
|
---|
| 508 | to produce localized strings.
|
---|
| 509 |
|
---|
| 510 | <h3 class=fn><a href="qstring.html">QString</a> <a name="arg-4"></a>QString::arg ( Q_LLONG a, int fieldWidth = 0, int base = 10 ) const
|
---|
| 511 | </h3>
|
---|
| 512 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 513 | <p> <em>a</em> is expressed in base <em>base</em>, which is 10 by default and must
|
---|
| 514 | be between 2 and 36. If <em>base</em> is 10, the '%L' syntax can be used
|
---|
| 515 | to produce localized strings.
|
---|
| 516 |
|
---|
| 517 | <h3 class=fn><a href="qstring.html">QString</a> <a name="arg-5"></a>QString::arg ( Q_ULLONG a, int fieldWidth = 0, int base = 10 ) const
|
---|
| 518 | </h3>
|
---|
| 519 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 520 | <p> <em>a</em> is expressed in base <em>base</em>, which is 10 by default and must
|
---|
| 521 | be between 2 and 36. If <em>base</em> is 10, the '%L' syntax can be used
|
---|
| 522 | to produce localized strings.
|
---|
| 523 |
|
---|
| 524 | <h3 class=fn><a href="qstring.html">QString</a> <a name="arg-6"></a>QString::arg ( int a, int fieldWidth = 0, int base = 10 ) const
|
---|
| 525 | </h3>
|
---|
| 526 |
|
---|
| 527 | <p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 528 | <p> <em>a</em> is expressed in base <em>base</em>, which is 10 by default and must
|
---|
| 529 | be between 2 and 36. If <em>base</em> is 10, the '%L' syntax can be used
|
---|
| 530 | to produce localized strings.
|
---|
| 531 |
|
---|
| 532 | <h3 class=fn><a href="qstring.html">QString</a> <a name="arg-7"></a>QString::arg ( uint a, int fieldWidth = 0, int base = 10 ) const
|
---|
| 533 | </h3>
|
---|
| 534 |
|
---|
| 535 | <p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 536 | <p> <em>a</em> is expressed in base <em>base</em>, which is 10 by default and must
|
---|
| 537 | be between 2 and 36. If <em>base</em> is 10, the '%L' syntax can be used
|
---|
| 538 | to produce localized strings.
|
---|
| 539 |
|
---|
| 540 | <h3 class=fn><a href="qstring.html">QString</a> <a name="arg-8"></a>QString::arg ( short a, int fieldWidth = 0, int base = 10 ) const
|
---|
| 541 | </h3>
|
---|
| 542 |
|
---|
| 543 | <p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 544 | <p> <em>a</em> is expressed in base <em>base</em>, which is 10 by default and must
|
---|
| 545 | be between 2 and 36. If <em>base</em> is 10, the '%L' syntax can be used
|
---|
| 546 | to produce localized strings.
|
---|
| 547 |
|
---|
| 548 | <h3 class=fn><a href="qstring.html">QString</a> <a name="arg-9"></a>QString::arg ( ushort a, int fieldWidth = 0, int base = 10 ) const
|
---|
| 549 | </h3>
|
---|
| 550 |
|
---|
| 551 | <p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 552 | <p> <em>a</em> is expressed in base <em>base</em>, which is 10 by default and must
|
---|
| 553 | be between 2 and 36. If <em>base</em> is 10, the '%L' syntax can be used
|
---|
| 554 | to produce localized strings.
|
---|
| 555 |
|
---|
| 556 | <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
|
---|
| 557 | </h3>
|
---|
| 558 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 559 | <p> <a name="arg-formats"></a>
|
---|
| 560 | <p> Argument <em>a</em> is formatted according to the <em>fmt</em> format specified,
|
---|
| 561 | which is 'g' by default and can be any of the following:
|
---|
| 562 | <p> <center><table cellpadding="4" cellspacing="2" border="0">
|
---|
| 563 | <tr bgcolor="#a2c511"> <th valign="top">Format <th valign="top">Meaning
|
---|
| 564 | <tr bgcolor="#f0f0f0"> <td valign="top"><tt>e</tt> <td valign="top">format as [-]9.9e[+|-]999
|
---|
| 565 | <tr bgcolor="#d0d0d0"> <td valign="top"><tt>E</tt> <td valign="top">format as [-]9.9E[+|-]999
|
---|
| 566 | <tr bgcolor="#f0f0f0"> <td valign="top"><tt>f</tt> <td valign="top">format as [-]9.9
|
---|
| 567 | <tr bgcolor="#d0d0d0"> <td valign="top"><tt>g</tt> <td valign="top">use <tt>e</tt> or <tt>f</tt> format, whichever is the most concise
|
---|
| 568 | <tr bgcolor="#f0f0f0"> <td valign="top"><tt>G</tt> <td valign="top">use <tt>E</tt> or <tt>f</tt> format, whichever is the most concise
|
---|
| 569 | </table></center>
|
---|
| 570 | <p> With 'e', 'E', and 'f', <em>prec</em> is the number of digits after the
|
---|
| 571 | decimal point. With 'g' and 'G', <em>prec</em> is the maximum number of
|
---|
| 572 | significant digits (trailing zeroes are omitted).
|
---|
| 573 | <p> <pre>
|
---|
| 574 | double d = 12.34;
|
---|
| 575 | QString ds = <a href="#QString">QString</a>( "'E' format, precision 3, gives %1" )
|
---|
| 576 | .arg( d, 0, 'E', 3 );
|
---|
| 577 | // ds == "'E' format, precision 3, gives 1.234E+01"
|
---|
| 578 | </pre>
|
---|
| 579 |
|
---|
| 580 | <p> The '%L' syntax can be used to produce localized strings.
|
---|
| 581 |
|
---|
| 582 | <h3 class=fn><a href="qstring.html">QString</a> <a name="arg-b"></a>QString::arg ( char a, int fieldWidth = 0 ) const
|
---|
| 583 | </h3>
|
---|
| 584 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 585 | <p> <em>a</em> is assumed to be in the Latin-1 character set.
|
---|
| 586 |
|
---|
| 587 | <h3 class=fn><a href="qstring.html">QString</a> <a name="arg-c"></a>QString::arg ( <a href="qchar.html">QChar</a> a, int fieldWidth = 0 ) const
|
---|
| 588 | </h3>
|
---|
| 589 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 590 | <p>
|
---|
| 591 | <h3 class=fn><a href="qstring.html">QString</a> <a name="arg-d"></a>QString::arg ( const <a href="qstring.html">QString</a> & a1, const <a href="qstring.html">QString</a> & a2 ) const
|
---|
| 592 | </h3>
|
---|
| 593 |
|
---|
| 594 | <p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 595 | <p> This is the same as str.<a href="#arg">arg</a>(<em>a1</em>).arg(<em>a2</em>), except that
|
---|
| 596 | the strings are replaced in one pass. This can make a difference
|
---|
| 597 | if <em>a1</em> contains e.g. <tt>%1</tt>:
|
---|
| 598 | <p> <pre>
|
---|
| 599 | QString str( "%1 %2" );
|
---|
| 600 | str.<a href="#arg">arg</a>( "Hello", "world" ); // returns "Hello world"
|
---|
| 601 | str.<a href="#arg">arg</a>( "Hello" ).arg( "world" ); // returns "Hello world"
|
---|
| 602 |
|
---|
| 603 | str.<a href="#arg">arg</a>( "(%1)", "Hello" ); // returns "(%1) Hello"
|
---|
| 604 | str.<a href="#arg">arg</a>( "(%1)" ).arg( "Hello" ); // returns "(Hello) %2"
|
---|
| 605 | </pre>
|
---|
| 606 |
|
---|
| 607 |
|
---|
| 608 | <h3 class=fn><a href="qstring.html">QString</a> <a name="arg-e"></a>QString::arg ( const <a href="qstring.html">QString</a> & a1, const <a href="qstring.html">QString</a> & a2, const <a href="qstring.html">QString</a> & a3 ) const
|
---|
| 609 | </h3>
|
---|
| 610 |
|
---|
| 611 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 612 | <p> This is the same as calling str.<a href="#arg">arg</a>(<em>a1</em>).arg(<em>a2</em>).arg(<em>a3</em>),
|
---|
| 613 | except that the strings are replaced in one pass.
|
---|
| 614 |
|
---|
| 615 | <h3 class=fn><a href="qstring.html">QString</a> <a name="arg-f"></a>QString::arg ( const <a href="qstring.html">QString</a> & a1, const <a href="qstring.html">QString</a> & a2, const <a href="qstring.html">QString</a> & a3, const <a href="qstring.html">QString</a> & a4 ) const
|
---|
| 616 | </h3>
|
---|
| 617 |
|
---|
| 618 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 619 | <p> This is the same as calling
|
---|
| 620 | str.<a href="#arg">arg</a>(<em>a1</em>).arg(<em>a2</em>).arg(<em>a3</em>).arg(<em>a4</em>),
|
---|
| 621 | except that the strings are replaced in one pass.
|
---|
| 622 |
|
---|
| 623 | <h3 class=fn>const char * <a name="ascii"></a>QString::ascii () const
|
---|
| 624 | </h3>
|
---|
| 625 | Returns an 8-bit ASCII representation of the string.
|
---|
| 626 | <p> If a codec has been set using <a href="qtextcodec.html#codecForCStrings">QTextCodec::codecForCStrings</a>(),
|
---|
| 627 | it is used to convert Unicode to 8-bit char. Otherwise, this function
|
---|
| 628 | does the same as <a href="#latin1">latin1</a>().
|
---|
| 629 | <p> <p>See also <a href="#fromAscii">fromAscii</a>(), <a href="#latin1">latin1</a>(), <a href="#utf8">utf8</a>(), and <a href="#local8Bit">local8Bit</a>().
|
---|
| 630 |
|
---|
| 631 | <p>Example: <a href="networkprotocol-example.html#x690">network/networkprotocol/nntp.cpp</a>.
|
---|
| 632 | <h3 class=fn><a href="qchar.html">QChar</a> <a name="at"></a>QString::at ( uint i ) const
|
---|
| 633 | </h3>
|
---|
| 634 |
|
---|
| 635 | <p> Returns the character at index <em>i</em>, or 0 if <em>i</em> is beyond the
|
---|
| 636 | length of the string.
|
---|
| 637 | <p> <pre>
|
---|
| 638 | const QString string( "abcdefgh" );
|
---|
| 639 | <a href="qchar.html">QChar</a> ch = string.<a href="#at">at</a>( 4 );
|
---|
| 640 | // ch == 'e'
|
---|
| 641 | </pre>
|
---|
| 642 |
|
---|
| 643 | <p> If the QString is not const (i.e. const QString) or const& (i.e.
|
---|
| 644 | const QString &), then the non-const overload of <a href="#at">at</a>() will be used
|
---|
| 645 | instead.
|
---|
| 646 |
|
---|
| 647 | <h3 class=fn><a href="qcharref.html">QCharRef</a> <a name="at-2"></a>QString::at ( uint i )
|
---|
| 648 | </h3>
|
---|
| 649 |
|
---|
| 650 | <p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 651 | <p> The function returns a reference to the character at index <em>i</em>.
|
---|
| 652 | The resulting reference can then be assigned to, or used
|
---|
| 653 | immediately, but it will become invalid once further modifications
|
---|
| 654 | are made to the original string.
|
---|
| 655 | <p> If <em>i</em> is beyond the length of the string then the string is
|
---|
| 656 | expanded with QChar::null.
|
---|
| 657 |
|
---|
| 658 | <h3 class=fn>uint <a name="capacity"></a>QString::capacity () const
|
---|
| 659 | </h3>
|
---|
| 660 |
|
---|
| 661 | <p> Returns the number of characters this string can hold
|
---|
| 662 | in the allocated memory.
|
---|
| 663 | <p> <p>See also <a href="#reserve">reserve</a>() and <a href="#squeeze">squeeze</a>().
|
---|
| 664 |
|
---|
| 665 | <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>
|
---|
| 666 | </h3>
|
---|
| 667 |
|
---|
| 668 | <p> Lexically compares <em>s1</em> with <em>s2</em> and returns an integer less
|
---|
| 669 | than, equal to, or greater than zero if <em>s1</em> is less than, equal
|
---|
| 670 | to, or greater than <em>s2</em>.
|
---|
| 671 | <p> The comparison is based exclusively on the numeric Unicode values
|
---|
| 672 | of the characters and is very fast, but is not what a human would
|
---|
| 673 | expect. Consider sorting user-interface strings with
|
---|
| 674 | <a href="#localeAwareCompare">QString::localeAwareCompare</a>().
|
---|
| 675 | <p> <pre>
|
---|
| 676 | int a = QString::<a href="#compare">compare</a>( "def", "abc" ); // a > 0
|
---|
| 677 | int b = QString::<a href="#compare">compare</a>( "abc", "def" ); // b < 0
|
---|
| 678 | int c = QString::<a href="#compare">compare</a>( "abc", "abc" ); // c == 0
|
---|
| 679 | </pre>
|
---|
| 680 |
|
---|
| 681 |
|
---|
| 682 | <h3 class=fn>int <a name="compare-2"></a>QString::compare ( const <a href="qstring.html">QString</a> & s ) const
|
---|
| 683 | </h3>
|
---|
| 684 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 685 | <p> Lexically compares this string with <em>s</em> and returns an integer
|
---|
| 686 | less than, equal to, or greater than zero if it is less than, equal
|
---|
| 687 | to, or greater than <em>s</em>.
|
---|
| 688 |
|
---|
| 689 | <h3 class=fn>void <a name="compose"></a>QString::compose ()
|
---|
| 690 | </h3>
|
---|
| 691 | <b>Warning:</b> This function is not supported in Qt 3.x. It is provided
|
---|
| 692 | for experimental and illustrative purposes only. It is mainly of
|
---|
| 693 | interest to those experimenting with Arabic and other
|
---|
| 694 | composition-rich texts.
|
---|
| 695 | <p> Applies possible ligatures to a QString. Useful when
|
---|
| 696 | composition-rich text requires rendering with glyph-poor fonts,
|
---|
| 697 | but it also makes compositions such as <a href="qchar.html">QChar</a>(0x0041) ('A') and
|
---|
| 698 | QChar(0x0308) (Unicode accent diaresis), giving QChar(0x00c4)
|
---|
| 699 | (German A Umlaut).
|
---|
| 700 |
|
---|
| 701 | <h3 class=fn><a href="qchar.html">QChar</a> <a name="constref"></a>QString::constref ( uint i ) const
|
---|
| 702 | </h3>
|
---|
| 703 |
|
---|
| 704 | <p> Returns the <a href="qchar.html">QChar</a> at index <em>i</em> by value.
|
---|
| 705 | <p> Equivalent to <a href="#at">at</a>(<em>i</em>).
|
---|
| 706 | <p> <p>See also <a href="#ref">ref</a>().
|
---|
| 707 |
|
---|
| 708 | <h3 class=fn>int <a name="contains"></a>QString::contains ( <a href="qchar.html">QChar</a> c, bool cs = TRUE ) const
|
---|
| 709 | </h3>
|
---|
| 710 | Returns the number of times the character <em>c</em> occurs in the
|
---|
| 711 | string.
|
---|
| 712 | <p> If <em>cs</em> is TRUE (the default), the search is case sensitive;
|
---|
| 713 | otherwise the search is case insensitive.
|
---|
| 714 | <p> <pre>
|
---|
| 715 | QString string( "Trolltech and Qt" );
|
---|
| 716 | int n = string.<a href="#contains">contains</a>( 't', FALSE );
|
---|
| 717 | // n == 3
|
---|
| 718 | </pre>
|
---|
| 719 |
|
---|
| 720 |
|
---|
| 721 | <p>Examples: <a href="fileiconview-example.html#x867">fileiconview/qfileiconview.cpp</a> and <a href="mdi-example.html#x2064">mdi/application.cpp</a>.
|
---|
| 722 | <h3 class=fn>int <a name="contains-2"></a>QString::contains ( char c, bool cs = TRUE ) const
|
---|
| 723 | </h3>
|
---|
| 724 |
|
---|
| 725 | <p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 726 | <p>
|
---|
| 727 | <h3 class=fn>int <a name="contains-3"></a>QString::contains ( const char * str, bool cs = TRUE ) const
|
---|
| 728 | </h3>
|
---|
| 729 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 730 | <p> Returns the number of times the string <em>str</em> occurs in the string.
|
---|
| 731 | <p> If <em>cs</em> is TRUE (the default), the search is case sensitive;
|
---|
| 732 | otherwise the search is case insensitive.
|
---|
| 733 |
|
---|
| 734 | <h3 class=fn>int <a name="contains-4"></a>QString::contains ( const <a href="qstring.html">QString</a> & str, bool cs = TRUE ) const
|
---|
| 735 | </h3>
|
---|
| 736 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 737 | <p> Returns the number of times <em>str</em> occurs in the string.
|
---|
| 738 | <p> If <em>cs</em> is TRUE (the default), the search is case sensitive;
|
---|
| 739 | otherwise the search is case insensitive.
|
---|
| 740 | <p> This function counts overlapping strings, so in the example below,
|
---|
| 741 | there are two instances of "ana" in "bananas".
|
---|
| 742 | <p> <pre>
|
---|
| 743 | QString str( "bananas" );
|
---|
| 744 | int i = str.<a href="#contains">contains</a>( "ana" ); // i == 2
|
---|
| 745 | </pre>
|
---|
| 746 |
|
---|
| 747 | <p> <p>See also <a href="#findRev">findRev</a>().
|
---|
| 748 |
|
---|
| 749 | <h3 class=fn>int <a name="contains-5"></a>QString::contains ( const <a href="qregexp.html">QRegExp</a> & rx ) const
|
---|
| 750 | </h3>
|
---|
| 751 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 752 | <p> Returns the number of times the regexp, <em>rx</em>, matches in the
|
---|
| 753 | string.
|
---|
| 754 | <p> This function counts overlapping matches, so in the example below,
|
---|
| 755 | there are four instances of "ana" or "ama".
|
---|
| 756 | <p> <pre>
|
---|
| 757 | QString str = "banana and panama";
|
---|
| 758 | <a href="qregexp.html">QRegExp</a> rxp = QRegExp( "a[nm]a", TRUE, FALSE );
|
---|
| 759 | int i = str.<a href="#contains">contains</a>( rxp ); // i == 4
|
---|
| 760 | </pre>
|
---|
| 761 |
|
---|
| 762 | <p> <p>See also <a href="#find">find</a>() and <a href="#findRev">findRev</a>().
|
---|
| 763 |
|
---|
| 764 | <h3 class=fn><a href="qstring.html">QString</a> <a name="copy"></a>QString::copy () const
|
---|
| 765 | </h3>
|
---|
| 766 |
|
---|
| 767 | <p> <b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
|
---|
| 768 | <p> In Qt 2.0 and later, all calls to this function are needless. Just
|
---|
| 769 | remove them.
|
---|
| 770 |
|
---|
| 771 | <h3 class=fn>const char * <a name="data"></a>QString::data () const
|
---|
| 772 | </h3>
|
---|
| 773 |
|
---|
| 774 | <p> <b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
|
---|
| 775 | <p> Returns a pointer to a '\0'-terminated classic C string.
|
---|
| 776 | <p> In Qt 1.x, this returned a char* allowing direct manipulation of the
|
---|
| 777 | string as a sequence of bytes. In Qt 2.x where QString is a Unicode
|
---|
| 778 | string, char* conversion constructs a temporary string, and hence
|
---|
| 779 | direct character operations are meaningless.
|
---|
| 780 |
|
---|
| 781 | <h3 class=fn>bool <a name="endsWith"></a>QString::endsWith ( const <a href="qstring.html">QString</a> & s, bool cs = TRUE ) const
|
---|
| 782 | </h3>
|
---|
| 783 | Returns TRUE if the string ends with <em>s</em>; otherwise returns
|
---|
| 784 | FALSE.
|
---|
| 785 | <p> If <em>cs</em> is TRUE (the default), the search is case sensitive;
|
---|
| 786 | otherwise the search is case insensitive.
|
---|
| 787 | <p> <pre>
|
---|
| 788 | QString str( "Bananas" );
|
---|
| 789 | str.<a href="#endsWith">endsWith</a>( "anas" ); // returns TRUE
|
---|
| 790 | str.<a href="#endsWith">endsWith</a>( "pple" ); // returns FALSE
|
---|
| 791 | </pre>
|
---|
| 792 |
|
---|
| 793 | <p> <p>See also <a href="#startsWith">startsWith</a>().
|
---|
| 794 |
|
---|
| 795 | <p>Example: <a href="tutorial2-04.html#x2561">chart/main.cpp</a>.
|
---|
| 796 | <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 )
|
---|
| 797 | </h3>
|
---|
| 798 | Fills the string with <em>len</em> characters of value <em>c</em>, and returns
|
---|
| 799 | a reference to the string.
|
---|
| 800 | <p> If <em>len</em> is negative (the default), the current string length is
|
---|
| 801 | used.
|
---|
| 802 | <p> <pre>
|
---|
| 803 | QString str;
|
---|
| 804 | str.<a href="#fill">fill</a>( 'g', 5 ); // string == "ggggg"
|
---|
| 805 | </pre>
|
---|
| 806 |
|
---|
| 807 |
|
---|
| 808 | <h3 class=fn>int <a name="find"></a>QString::find ( const <a href="qregexp.html">QRegExp</a> & rx, int index = 0 ) const
|
---|
| 809 | </h3>
|
---|
| 810 | Finds the first match of the <a href="qregexp.html#regular-expression">regular expression</a> <em>rx</em>, starting
|
---|
| 811 | from position <em>index</em>. If <em>index</em> is -1, the search starts at
|
---|
| 812 | the last character; if -2, at the next to last character and so
|
---|
| 813 | on. (See <a href="#findRev">findRev</a>() for searching backwards.)
|
---|
| 814 | <p> Returns the position of the first match of <em>rx</em> or -1 if no match
|
---|
| 815 | was found.
|
---|
| 816 | <p> <pre>
|
---|
| 817 | QString string( "bananas" );
|
---|
| 818 | int i = string.<a href="#find">find</a>( QRegExp("an"), 0 ); // i == 1
|
---|
| 819 | </pre>
|
---|
| 820 |
|
---|
| 821 | <p> <p>See also <a href="#findRev">findRev</a>(), <a href="#replace">replace</a>(), and <a href="#contains">contains</a>().
|
---|
| 822 |
|
---|
| 823 | <p>Example: <a href="mail-example.html#x715">network/mail/smtp.cpp</a>.
|
---|
| 824 | <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
|
---|
| 825 | </h3>
|
---|
| 826 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 827 | <p> Finds the first occurrence of the character <em>c</em>, starting at
|
---|
| 828 | position <em>index</em>. If <em>index</em> is -1, the search starts at the
|
---|
| 829 | last character; if -2, at the next to last character and so on.
|
---|
| 830 | (See <a href="#findRev">findRev</a>() for searching backwards.)
|
---|
| 831 | <p> If <em>cs</em> is TRUE (the default), the search is case sensitive;
|
---|
| 832 | otherwise the search is case insensitive.
|
---|
| 833 | <p> Returns the position of <em>c</em> or -1 if <em>c</em> could not be found.
|
---|
| 834 |
|
---|
| 835 | <h3 class=fn>int <a name="find-3"></a>QString::find ( char c, int index = 0, bool cs = TRUE ) const
|
---|
| 836 | </h3>
|
---|
| 837 |
|
---|
| 838 | <p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 839 | <p> Find character <em>c</em> starting from position <em>index</em>.
|
---|
| 840 | <p> If <em>cs</em> is TRUE (the default), the search is case sensitive;
|
---|
| 841 | otherwise the search is case insensitive.
|
---|
| 842 |
|
---|
| 843 | <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
|
---|
| 844 | </h3>
|
---|
| 845 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 846 | <p> Finds the first occurrence of the string <em>str</em>, starting at
|
---|
| 847 | position <em>index</em>. If <em>index</em> is -1, the search starts at the
|
---|
| 848 | last character, if it is -2, at the next to last character and so
|
---|
| 849 | on. (See <a href="#findRev">findRev</a>() for searching backwards.)
|
---|
| 850 | <p> If <em>cs</em> is TRUE (the default), the search is case sensitive;
|
---|
| 851 | otherwise the search is case insensitive.
|
---|
| 852 | <p> Returns the position of <em>str</em> or -1 if <em>str</em> could not be found.
|
---|
| 853 |
|
---|
| 854 | <h3 class=fn>int <a name="find-5"></a>QString::find ( const char * str, int index = 0 ) const
|
---|
| 855 | </h3>
|
---|
| 856 |
|
---|
| 857 | <p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 858 | <p> Equivalent to <a href="#find">find</a>(QString(<em>str</em>), <em>index</em>).
|
---|
| 859 |
|
---|
| 860 | <h3 class=fn>int <a name="findRev"></a>QString::findRev ( const char * str, int index = -1 ) const
|
---|
| 861 | </h3>
|
---|
| 862 |
|
---|
| 863 | <p> Equivalent to <a href="#findRev">findRev</a>(QString(<em>str</em>), <em>index</em>).
|
---|
| 864 |
|
---|
| 865 | <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
|
---|
| 866 | </h3>
|
---|
| 867 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 868 | <p> Finds the first occurrence of the character <em>c</em>, starting at
|
---|
| 869 | position <em>index</em> and searching backwards. If the index is -1, the
|
---|
| 870 | search starts at the last character, if it is -2, at the next to
|
---|
| 871 | last character and so on.
|
---|
| 872 | <p> Returns the position of <em>c</em> or -1 if <em>c</em> could not be found.
|
---|
| 873 | <p> If <em>cs</em> is TRUE (the default), the search is case sensitive;
|
---|
| 874 | otherwise the search is case insensitive.
|
---|
| 875 | <p> <pre>
|
---|
| 876 | QString string( "bananas" );
|
---|
| 877 | int i = string.<a href="#findRev">findRev</a>( 'a' ); // i == 5
|
---|
| 878 | </pre>
|
---|
| 879 |
|
---|
| 880 |
|
---|
| 881 | <h3 class=fn>int <a name="findRev-3"></a>QString::findRev ( char c, int index = -1, bool cs = TRUE ) const
|
---|
| 882 | </h3>
|
---|
| 883 |
|
---|
| 884 | <p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 885 | <p> Find character <em>c</em> starting from position <em>index</em> and working
|
---|
| 886 | backwards.
|
---|
| 887 | <p> If <em>cs</em> is TRUE (the default), the search is case sensitive;
|
---|
| 888 | otherwise the search is case insensitive.
|
---|
| 889 |
|
---|
| 890 | <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
|
---|
| 891 | </h3>
|
---|
| 892 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 893 | <p> Finds the first occurrence of the string <em>str</em>, starting at
|
---|
| 894 | position <em>index</em> and searching backwards. If the index is -1, the
|
---|
| 895 | search starts at the last character, if it is -2, at the next to
|
---|
| 896 | last character and so on.
|
---|
| 897 | <p> Returns the position of <em>str</em> or -1 if <em>str</em> could not be found.
|
---|
| 898 | <p> If <em>cs</em> is TRUE (the default), the search is case sensitive;
|
---|
| 899 | otherwise the search is case insensitive.
|
---|
| 900 | <p> <pre>
|
---|
| 901 | QString string("bananas");
|
---|
| 902 | int i = string.<a href="#findRev">findRev</a>( "ana" ); // i == 3
|
---|
| 903 | </pre>
|
---|
| 904 |
|
---|
| 905 |
|
---|
| 906 | <h3 class=fn>int <a name="findRev-5"></a>QString::findRev ( const <a href="qregexp.html">QRegExp</a> & rx, int index = -1 ) const
|
---|
| 907 | </h3>
|
---|
| 908 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 909 | <p> Finds the first match of the regexp <em>rx</em>, starting at position <em>index</em> and searching backwards. If the index is -1, the search
|
---|
| 910 | starts at the last character, if it is -2, at the next to last
|
---|
| 911 | character and so on. (See <a href="#findRev">findRev</a>() for searching backwards.)
|
---|
| 912 | <p> Returns the position of the match or -1 if no match was found.
|
---|
| 913 | <p> <pre>
|
---|
| 914 | QString string( "bananas" );
|
---|
| 915 | int i = string.<a href="#findRev">findRev</a>( QRegExp("an") ); // i == 3
|
---|
| 916 | </pre>
|
---|
| 917 |
|
---|
| 918 | <p> <p>See also <a href="#find">find</a>().
|
---|
| 919 |
|
---|
| 920 | <h3 class=fn><a href="qstring.html">QString</a> <a name="fromAscii"></a>QString::fromAscii ( const char * ascii, int len = -1 )<tt> [static]</tt>
|
---|
| 921 | </h3>
|
---|
| 922 | Returns the Unicode string decoded from the first <em>len</em>
|
---|
| 923 | bytes of <em>ascii</em>, ignoring the rest of <em>ascii</em>. If <em>len</em>
|
---|
| 924 | is -1 then the length of <em>ascii</em> is used. If <em>len</em> is bigger
|
---|
| 925 | than the length of <em>ascii</em> then it will use the length of <em>ascii</em>.
|
---|
| 926 | <p> If a codec has been set using <a href="qtextcodec.html#codecForCStrings">QTextCodec::codecForCStrings</a>(),
|
---|
| 927 | it is used to convert the string from 8-bit characters to Unicode.
|
---|
| 928 | Otherwise, this function does the same as <a href="#fromLatin1">fromLatin1</a>().
|
---|
| 929 | <p> This is the same as the QString(const char*) constructor, but you
|
---|
| 930 | can make that constructor invisible if you compile with the define
|
---|
| 931 | <tt>QT_NO_CAST_ASCII</tt>, in which case you can explicitly create a
|
---|
| 932 | QString from 8-bit ASCII text using this function.
|
---|
| 933 | <p> <pre>
|
---|
| 934 | QString str = QString::<a href="#fromAscii">fromAscii</a>( "123456789", 5 );
|
---|
| 935 | // str == "12345"
|
---|
| 936 | </pre>
|
---|
| 937 |
|
---|
| 938 |
|
---|
| 939 | <h3 class=fn><a href="qstring.html">QString</a> <a name="fromLatin1"></a>QString::fromLatin1 ( const char * chars, int len = -1 )<tt> [static]</tt>
|
---|
| 940 | </h3>
|
---|
| 941 | Returns the Unicode string decoded from the first <em>len</em>
|
---|
| 942 | bytes of <em>chars</em>, ignoring the rest of <em>chars</em>. If <em>len</em>
|
---|
| 943 | is -1 then the length of <em>chars</em> is used. If <em>len</em> is bigger
|
---|
| 944 | than the length of <em>chars</em> then it will use the length of <em>chars</em>.
|
---|
| 945 | <p> <p>See also <a href="#fromAscii">fromAscii</a>().
|
---|
| 946 |
|
---|
| 947 | <p>Examples: <a href="listbox-example.html#x1446">listbox/listbox.cpp</a> and <a href="mail-example.html#x716">network/mail/smtp.cpp</a>.
|
---|
| 948 | <h3 class=fn><a href="qstring.html">QString</a> <a name="fromLocal8Bit"></a>QString::fromLocal8Bit ( const char * local8Bit, int len = -1 )<tt> [static]</tt>
|
---|
| 949 | </h3>
|
---|
| 950 | Returns the Unicode string decoded from the first <em>len</em>
|
---|
| 951 | bytes of <em>local8Bit</em>, ignoring the rest of <em>local8Bit</em>. If
|
---|
| 952 | <em>len</em> is -1 then the length of <em>local8Bit</em> is used. If <em>len</em> is
|
---|
| 953 | bigger than the length of <em>local8Bit</em> then it will use the length
|
---|
| 954 | of <em>local8Bit</em>.
|
---|
| 955 | <p> <pre>
|
---|
| 956 | QString str = QString::<a href="#fromLocal8Bit">fromLocal8Bit</a>( "123456789", 5 );
|
---|
| 957 | // str == "12345"
|
---|
| 958 | </pre>
|
---|
| 959 |
|
---|
| 960 | <p> <em>local8Bit</em> is assumed to be encoded in a locale-specific format.
|
---|
| 961 | <p> See <a href="qtextcodec.html">QTextCodec</a> for more diverse coding/decoding of Unicode strings.
|
---|
| 962 |
|
---|
| 963 | <h3 class=fn><a href="qstring.html">QString</a> <a name="fromUcs2"></a>QString::fromUcs2 ( const unsigned short * str )<tt> [static]</tt>
|
---|
| 964 | </h3>
|
---|
| 965 | Constructs a string that is a <a href="shclass.html#deep-copy">deep copy</a> of <em>str</em>, interpreted as a
|
---|
| 966 | UCS2 encoded, zero terminated, Unicode string.
|
---|
| 967 | <p> If <em>str</em> is 0, then a null string is created.
|
---|
| 968 | <p> <p>See also <a href="#isNull">isNull</a>().
|
---|
| 969 |
|
---|
| 970 | <h3 class=fn><a href="qstring.html">QString</a> <a name="fromUtf8"></a>QString::fromUtf8 ( const char * utf8, int len = -1 )<tt> [static]</tt>
|
---|
| 971 | </h3>
|
---|
| 972 | Returns the Unicode string decoded from the first <em>len</em>
|
---|
| 973 | bytes of <em>utf8</em>, ignoring the rest of <em>utf8</em>. If <em>len</em> is
|
---|
| 974 | -1 then the length of <em>utf8</em> is used. If <em>len</em> is bigger than
|
---|
| 975 | the length of <em>utf8</em> then it will use the length of <em>utf8</em>.
|
---|
| 976 | <p> <pre>
|
---|
| 977 | QString str = QString::<a href="#fromUtf8">fromUtf8</a>( "123456789", 5 );
|
---|
| 978 | // str == "12345"
|
---|
| 979 | </pre>
|
---|
| 980 |
|
---|
| 981 | <p> See <a href="qtextcodec.html">QTextCodec</a> for more diverse coding/decoding of Unicode strings.
|
---|
| 982 |
|
---|
| 983 | <p>Example: <a href="simple-font-demo-example.html#x2850">fonts/simple-qfont-demo/viewer.cpp</a>.
|
---|
| 984 | <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 )
|
---|
| 985 | </h3>
|
---|
| 986 | Inserts <em>s</em> into the string at position <em>index</em>.
|
---|
| 987 | <p> If <em>index</em> is beyond the end of the string, the string is
|
---|
| 988 | extended with spaces to length <em>index</em> and <em>s</em> is then appended
|
---|
| 989 | and returns a reference to the string.
|
---|
| 990 | <p> <pre>
|
---|
| 991 | QString string( "I like fish" );
|
---|
| 992 | str = string.<a href="#insert">insert</a>( 2, "don't " );
|
---|
| 993 | // str == "I don't like fish"
|
---|
| 994 | </pre>
|
---|
| 995 |
|
---|
| 996 | <p> <p>See also <a href="#remove">remove</a>() and <a href="#replace">replace</a>().
|
---|
| 997 |
|
---|
| 998 | <p>Examples: <a href="themes-example.html#x337">themes/themes.cpp</a> and <a href="xform-example.html#x1264">xform/xform.cpp</a>.
|
---|
| 999 | <h3 class=fn><a href="qstring.html">QString</a> & <a name="insert-2"></a>QString::insert ( uint index, const <a href="qbytearray.html">QByteArray</a> & s )
|
---|
| 1000 | </h3>
|
---|
| 1001 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 1002 | <p> Inserts <em>s</em> into the string at position <em>index</em> and returns
|
---|
| 1003 | a reference to the string.
|
---|
| 1004 |
|
---|
| 1005 | <h3 class=fn><a href="qstring.html">QString</a> & <a name="insert-3"></a>QString::insert ( uint index, const char * s )
|
---|
| 1006 | </h3>
|
---|
| 1007 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 1008 | <p> Inserts <em>s</em> into the string at position <em>index</em> and returns
|
---|
| 1009 | a reference to the string.
|
---|
| 1010 |
|
---|
| 1011 | <h3 class=fn><a href="qstring.html">QString</a> & <a name="insert-4"></a>QString::insert ( uint index, const <a href="qchar.html">QChar</a> * s, uint len )
|
---|
| 1012 | </h3>
|
---|
| 1013 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 1014 | <p> Inserts the first <em>len</em> characters in <em>s</em> into the string at
|
---|
| 1015 | position <em>index</em> and returns a reference to the string.
|
---|
| 1016 |
|
---|
| 1017 | <h3 class=fn><a href="qstring.html">QString</a> & <a name="insert-5"></a>QString::insert ( uint index, <a href="qchar.html">QChar</a> c )
|
---|
| 1018 | </h3>
|
---|
| 1019 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 1020 | <p> Insert <em>c</em> into the string at position <em>index</em> and returns a
|
---|
| 1021 | reference to the string.
|
---|
| 1022 | <p> If <em>index</em> is beyond the end of the string, the string is
|
---|
| 1023 | extended with spaces (ASCII 32) to length <em>index</em> and <em>c</em> is
|
---|
| 1024 | then appended.
|
---|
| 1025 |
|
---|
| 1026 | <h3 class=fn><a href="qstring.html">QString</a> & <a name="insert-6"></a>QString::insert ( uint index, char c )
|
---|
| 1027 | </h3>
|
---|
| 1028 |
|
---|
| 1029 | <p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 1030 | <p> Insert character <em>c</em> at position <em>index</em>.
|
---|
| 1031 |
|
---|
| 1032 | <h3 class=fn>bool <a name="isEmpty"></a>QString::isEmpty () const
|
---|
| 1033 | </h3>
|
---|
| 1034 |
|
---|
| 1035 | <p> Returns TRUE if the string is empty, i.e. if <a href="#length">length</a>() == 0;
|
---|
| 1036 | otherwise returns FALSE. Null strings are also empty.
|
---|
| 1037 | <p> <pre>
|
---|
| 1038 | QString a( "" );
|
---|
| 1039 | a.<a href="#isEmpty">isEmpty</a>(); // TRUE
|
---|
| 1040 | a.<a href="#isNull">isNull</a>(); // FALSE
|
---|
| 1041 |
|
---|
| 1042 | QString b;
|
---|
| 1043 | b.<a href="#isEmpty">isEmpty</a>(); // TRUE
|
---|
| 1044 | b.<a href="#isNull">isNull</a>(); // TRUE
|
---|
| 1045 | </pre>
|
---|
| 1046 |
|
---|
| 1047 | <p> <p>See also <a href="#isNull">isNull</a>() and <a href="#length">length</a>().
|
---|
| 1048 |
|
---|
| 1049 | <p>Examples: <a href="addressbook-example.html#x571">addressbook/mainwindow.cpp</a>, <a href="canvas-chart-example.html#x2892">chart/chartform.cpp</a>, <a href="tutorial2-06.html#x2576">chart/chartform_canvas.cpp</a>, <a href="networkprotocol-example.html#x691">network/networkprotocol/nntp.cpp</a>, <a href="qmag-example.html#x1792">qmag/qmag.cpp</a>, and <a href="qwerty-example.html#x390">qwerty/qwerty.cpp</a>.
|
---|
| 1050 | <h3 class=fn>bool <a name="isNull"></a>QString::isNull () const
|
---|
| 1051 | </h3>
|
---|
| 1052 |
|
---|
| 1053 | <p> Returns TRUE if the string is null; otherwise returns FALSE. A
|
---|
| 1054 | null string is always empty.
|
---|
| 1055 | <p> <pre>
|
---|
| 1056 | QString a; // a.<a href="#unicode">unicode</a>() == 0, a.<a href="#length">length</a>() == 0
|
---|
| 1057 | a.<a href="#isNull">isNull</a>(); // TRUE, because a.<a href="#unicode">unicode</a>() == 0
|
---|
| 1058 | a.<a href="#isEmpty">isEmpty</a>(); // TRUE, because a.<a href="#length">length</a>() == 0
|
---|
| 1059 | </pre>
|
---|
| 1060 |
|
---|
| 1061 | <p> <p>See also <a href="#isEmpty">isEmpty</a>() and <a href="#length">length</a>().
|
---|
| 1062 |
|
---|
| 1063 | <p>Examples: <a href="i18n-example.html#x1948">i18n/main.cpp</a>, <a href="ftpclient-example.html#x771">network/ftpclient/ftpmainwindow.ui.h</a>, and <a href="qdir-example.html#x1842">qdir/qdir.cpp</a>.
|
---|
| 1064 | <h3 class=fn>const char * <a name="latin1"></a>QString::latin1 () const
|
---|
| 1065 | </h3>
|
---|
| 1066 | Returns a Latin-1 representation of the string. The
|
---|
| 1067 | returned value is undefined if the string contains non-Latin-1
|
---|
| 1068 | characters. If you want to convert strings into formats other than
|
---|
| 1069 | Unicode, see the <a href="qtextcodec.html">QTextCodec</a> classes.
|
---|
| 1070 | <p> This function is mainly useful for boot-strapping legacy code to
|
---|
| 1071 | use Unicode.
|
---|
| 1072 | <p> The result remains valid so long as one unmodified copy of the
|
---|
| 1073 | source string exists.
|
---|
| 1074 | <p> <p>See also <a href="#fromLatin1">fromLatin1</a>(), <a href="#ascii">ascii</a>(), <a href="#utf8">utf8</a>(), and <a href="#local8Bit">local8Bit</a>().
|
---|
| 1075 |
|
---|
| 1076 | <p>Examples: <a href="fileiconview-example.html#x869">fileiconview/qfileiconview.cpp</a> and <a href="networkprotocol-example.html#x692">network/networkprotocol/nntp.cpp</a>.
|
---|
| 1077 | <h3 class=fn><a href="qstring.html">QString</a> <a name="left"></a>QString::left ( uint len ) const
|
---|
| 1078 | </h3>
|
---|
| 1079 | Returns a substring that contains the <em>len</em> leftmost characters
|
---|
| 1080 | of the string.
|
---|
| 1081 | <p> The whole string is returned if <em>len</em> exceeds the length of the
|
---|
| 1082 | string.
|
---|
| 1083 | <p> <pre>
|
---|
| 1084 | QString s = "Pineapple";
|
---|
| 1085 | QString t = s.<a href="#left">left</a>( 4 ); // t == "Pine"
|
---|
| 1086 | </pre>
|
---|
| 1087 |
|
---|
| 1088 | <p> <p>See also <a href="#right">right</a>(), <a href="#mid">mid</a>(), and <a href="#isEmpty">isEmpty</a>().
|
---|
| 1089 |
|
---|
| 1090 | <p>Example: <a href="themes-example.html#x338">themes/themes.cpp</a>.
|
---|
| 1091 | <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
|
---|
| 1092 | </h3>
|
---|
| 1093 | Returns a string of length <em>width</em> that contains this string
|
---|
| 1094 | padded by the <em>fill</em> character.
|
---|
| 1095 | <p> If <em>truncate</em> is FALSE and the length of the string is more than
|
---|
| 1096 | <em>width</em>, then the returned string is a copy of the string.
|
---|
| 1097 | <p> If <em>truncate</em> is TRUE and the length of the string is more than
|
---|
| 1098 | <em>width</em>, then any characters in a copy of the string after length
|
---|
| 1099 | <em>width</em> are removed, and the copy is returned.
|
---|
| 1100 | <p> <pre>
|
---|
| 1101 | QString s( "apple" );
|
---|
| 1102 | QString t = s.<a href="#leftJustify">leftJustify</a>( 8, '.' ); // t == "apple..."
|
---|
| 1103 | </pre>
|
---|
| 1104 |
|
---|
| 1105 | <p> <p>See also <a href="#rightJustify">rightJustify</a>().
|
---|
| 1106 |
|
---|
| 1107 | <h3 class=fn>uint <a name="length"></a>QString::length () const
|
---|
| 1108 | </h3>
|
---|
| 1109 |
|
---|
| 1110 | <p> Returns the length of the string.
|
---|
| 1111 | <p> Null strings and empty strings have zero length.
|
---|
| 1112 | <p> <p>See also <a href="#isNull">isNull</a>() and <a href="#isEmpty">isEmpty</a>().
|
---|
| 1113 |
|
---|
| 1114 | <p>Examples: <a href="dirview-example.html#x1702">dirview/dirview.cpp</a>, <a href="fileiconview-example.html#x870">fileiconview/qfileiconview.cpp</a>, <a href="networkprotocol-example.html#x693">network/networkprotocol/nntp.cpp</a>, <a href="rot-example.html#x1372">rot13/rot13.cpp</a>, and <a href="themes-example.html#x339">themes/themes.cpp</a>.
|
---|
| 1115 | <h3 class=fn><a href="qcstring.html">QCString</a> <a name="local8Bit"></a>QString::local8Bit () const
|
---|
| 1116 | </h3>
|
---|
| 1117 | Returns the string encoded in a locale-specific format. On X11,
|
---|
| 1118 | this is the <a href="qtextcodec.html#codecForLocale">QTextCodec::codecForLocale</a>(). On Windows, it is a
|
---|
| 1119 | system-defined encoding. On Mac OS X, this always uses UTF-8 as
|
---|
| 1120 | the encoding.
|
---|
| 1121 | <p> See <a href="qtextcodec.html">QTextCodec</a> for more diverse coding/decoding of Unicode
|
---|
| 1122 | strings.
|
---|
| 1123 | <p> <p>See also <a href="#fromLocal8Bit">fromLocal8Bit</a>(), <a href="#ascii">ascii</a>(), <a href="#latin1">latin1</a>(), and <a href="#utf8">utf8</a>().
|
---|
| 1124 |
|
---|
| 1125 | <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>
|
---|
| 1126 | </h3>
|
---|
| 1127 |
|
---|
| 1128 | <p> Compares <em>s1</em> with <em>s2</em> and returns an integer less than, equal
|
---|
| 1129 | to, or greater than zero if <em>s1</em> is less than, equal to, or
|
---|
| 1130 | greater than <em>s2</em>.
|
---|
| 1131 | <p> The comparison is performed in a locale- and also
|
---|
| 1132 | platform-dependent manner. Use this function to present sorted
|
---|
| 1133 | lists of strings to the user.
|
---|
| 1134 | <p> <p>See also <a href="#compare">QString::compare</a>() and <a href="qtextcodec.html#locale">QTextCodec::locale</a>().
|
---|
| 1135 |
|
---|
| 1136 | <h3 class=fn>int <a name="localeAwareCompare-2"></a>QString::localeAwareCompare ( const <a href="qstring.html">QString</a> & s ) const
|
---|
| 1137 | </h3>
|
---|
| 1138 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 1139 | <p> Compares this string with <em>s</em>.
|
---|
| 1140 |
|
---|
| 1141 | <h3 class=fn><a href="qstring.html">QString</a> <a name="lower"></a>QString::lower () const
|
---|
| 1142 | </h3>
|
---|
| 1143 | Returns a lowercase copy of the string.
|
---|
| 1144 | <p> <pre>
|
---|
| 1145 | QString string( "TROlltECH" );
|
---|
| 1146 | str = string.<a href="#lower">lower</a>(); // str == "trolltech"
|
---|
| 1147 | </pre>
|
---|
| 1148 |
|
---|
| 1149 | <p> <p>See also <a href="#upper">upper</a>().
|
---|
| 1150 |
|
---|
| 1151 | <p>Example: <a href="scribble-example.html#x941">scribble/scribble.cpp</a>.
|
---|
| 1152 | <h3 class=fn><a href="qstring.html">QString</a> <a name="mid"></a>QString::mid ( uint index, uint len = 0xffffffff ) const
|
---|
| 1153 | </h3>
|
---|
| 1154 | Returns a string that contains the <em>len</em> characters of this
|
---|
| 1155 | string, starting at position <em>index</em>.
|
---|
| 1156 | <p> Returns a null string if the string is empty or <em>index</em> is out of
|
---|
| 1157 | range. Returns the whole string from <em>index</em> if <em>index</em> + <em>len</em>
|
---|
| 1158 | exceeds the length of the string.
|
---|
| 1159 | <p> <pre>
|
---|
| 1160 | QString s( "Five pineapples" );
|
---|
| 1161 | QString t = s.<a href="#mid">mid</a>( 5, 4 ); // t == "pine"
|
---|
| 1162 | </pre>
|
---|
| 1163 |
|
---|
| 1164 | <p> <p>See also <a href="#left">left</a>() and <a href="#right">right</a>().
|
---|
| 1165 |
|
---|
| 1166 | <p>Examples: <a href="mail-example.html#x717">network/mail/smtp.cpp</a>, <a href="qmag-example.html#x1793">qmag/qmag.cpp</a>, and <a href="themes-example.html#x340">themes/themes.cpp</a>.
|
---|
| 1167 | <h3 class=fn><a href="qstring.html">QString</a> <a name="number"></a>QString::number ( long n, int base = 10 )<tt> [static]</tt>
|
---|
| 1168 | </h3>
|
---|
| 1169 | A convenience function that returns a string equivalent of the
|
---|
| 1170 | number <em>n</em> to base <em>base</em>, which is 10 by default and must be
|
---|
| 1171 | between 2 and 36. The returned string is in "C" locale.
|
---|
| 1172 | <p> <pre>
|
---|
| 1173 | long a = 63;
|
---|
| 1174 | QString str = QString::<a href="#number">number</a>( a, 16 ); // str == "3f"
|
---|
| 1175 | QString str = QString::<a href="#number">number</a>( a, 16 ).upper(); // str == "3F"
|
---|
| 1176 | </pre>
|
---|
| 1177 |
|
---|
| 1178 | <p> <p>See also <a href="#setNum">setNum</a>().
|
---|
| 1179 |
|
---|
| 1180 | <p>Examples: <a href="simple-application-example.html#x1580">application/application.cpp</a>, <a href="canvas-chart-example.html#x2893">chart/chartform.cpp</a>, <a href="simple-font-demo-example.html#x2851">fonts/simple-qfont-demo/viewer.cpp</a>, <a href="helpviewer-example.html#x1018">helpviewer/helpwindow.cpp</a>, <a href="mdi-example.html#x2066">mdi/application.cpp</a>, <a href="regexptester-example.html#x2496">regexptester/regexptester.cpp</a>, and <a href="sql.html#x2193">sql/overview/extract/main.cpp</a>.
|
---|
| 1181 | <h3 class=fn><a href="qstring.html">QString</a> <a name="number-2"></a>QString::number ( ulong n, int base = 10 )<tt> [static]</tt>
|
---|
| 1182 | </h3>
|
---|
| 1183 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 1184 | <p> <p>See also <a href="#setNum">setNum</a>().
|
---|
| 1185 |
|
---|
| 1186 | <h3 class=fn><a href="qstring.html">QString</a> <a name="number-3"></a>QString::number ( Q_LLONG n, int base = 10 )<tt> [static]</tt>
|
---|
| 1187 | </h3>
|
---|
| 1188 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 1189 | <p> <p>See also <a href="#setNum">setNum</a>().
|
---|
| 1190 |
|
---|
| 1191 | <h3 class=fn><a href="qstring.html">QString</a> <a name="number-4"></a>QString::number ( Q_ULLONG n, int base = 10 )<tt> [static]</tt>
|
---|
| 1192 | </h3>
|
---|
| 1193 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 1194 | <p> <p>See also <a href="#setNum">setNum</a>().
|
---|
| 1195 |
|
---|
| 1196 | <h3 class=fn><a href="qstring.html">QString</a> <a name="number-5"></a>QString::number ( int n, int base = 10 )<tt> [static]</tt>
|
---|
| 1197 | </h3>
|
---|
| 1198 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 1199 | <p> <p>See also <a href="#setNum">setNum</a>().
|
---|
| 1200 |
|
---|
| 1201 | <h3 class=fn><a href="qstring.html">QString</a> <a name="number-6"></a>QString::number ( uint n, int base = 10 )<tt> [static]</tt>
|
---|
| 1202 | </h3>
|
---|
| 1203 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 1204 | <p> A convenience factory function that returns a string
|
---|
| 1205 | representation of the number <em>n</em> to the base <em>base</em>, which is 10
|
---|
| 1206 | by default and must be between 2 and 36.
|
---|
| 1207 | <p> <p>See also <a href="#setNum">setNum</a>().
|
---|
| 1208 |
|
---|
| 1209 | <h3 class=fn><a href="qstring.html">QString</a> <a name="number-7"></a>QString::number ( double n, char f = 'g', int prec = 6 )<tt> [static]</tt>
|
---|
| 1210 | </h3>
|
---|
| 1211 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 1212 | <p> Argument <em>n</em> is formatted according to the <em>f</em> format specified,
|
---|
| 1213 | which is <tt>g</tt> by default, and can be any of the following:
|
---|
| 1214 | <p> <center><table cellpadding="4" cellspacing="2" border="0">
|
---|
| 1215 | <tr bgcolor="#a2c511"> <th valign="top">Format <th valign="top">Meaning
|
---|
| 1216 | <tr bgcolor="#f0f0f0"> <td valign="top"><tt>e</tt> <td valign="top">format as [-]9.9e[+|-]999
|
---|
| 1217 | <tr bgcolor="#d0d0d0"> <td valign="top"><tt>E</tt> <td valign="top">format as [-]9.9E[+|-]999
|
---|
| 1218 | <tr bgcolor="#f0f0f0"> <td valign="top"><tt>f</tt> <td valign="top">format as [-]9.9
|
---|
| 1219 | <tr bgcolor="#d0d0d0"> <td valign="top"><tt>g</tt> <td valign="top">use <tt>e</tt> or <tt>f</tt> format, whichever is the most concise
|
---|
| 1220 | <tr bgcolor="#f0f0f0"> <td valign="top"><tt>G</tt> <td valign="top">use <tt>E</tt> or <tt>f</tt> format, whichever is the most concise
|
---|
| 1221 | </table></center>
|
---|
| 1222 | <p> With 'e', 'E', and 'f', <em>prec</em> is the number of digits after the
|
---|
| 1223 | decimal point. With 'g' and 'G', <em>prec</em> is the maximum number of
|
---|
| 1224 | significant digits (trailing zeroes are omitted).
|
---|
| 1225 | <p> <pre>
|
---|
| 1226 | double d = 12.34;
|
---|
| 1227 | QString ds = <a href="#QString">QString</a>( "'E' format, precision 3, gives %1" )
|
---|
| 1228 | .arg( d, 0, 'E', 3 );
|
---|
| 1229 | // ds == "1.234E+001"
|
---|
| 1230 | </pre>
|
---|
| 1231 |
|
---|
| 1232 | <p> <p>See also <a href="#setNum">setNum</a>().
|
---|
| 1233 |
|
---|
| 1234 | <h3 class=fn><a name="operator-const-char-*"></a>QString::operator const char * () const
|
---|
| 1235 | </h3>
|
---|
| 1236 |
|
---|
| 1237 | <p> Returns <a href="#ascii">ascii</a>(). Be sure to see the warnings documented in the
|
---|
| 1238 | ascii() function. Note that for new code which you wish to be
|
---|
| 1239 | strictly Unicode-clean, you can define the macro <tt>QT_NO_ASCII_CAST</tt> when compiling your code to hide this function so
|
---|
| 1240 | that automatic casts are not done. This has the added advantage
|
---|
| 1241 | that you catch the programming error described in <a href="#operator!">operator!</a>().
|
---|
| 1242 |
|
---|
| 1243 | <h3 class=fn><a name="operator-std::string"></a>QString::operator std::string () const
|
---|
| 1244 | </h3>
|
---|
| 1245 |
|
---|
| 1246 | <p> Returns <a href="#ascii">ascii</a>() as a std::string.
|
---|
| 1247 | <p> <b>Warning:</b> The function may cause an application to crash if a static C run-time is in use.
|
---|
| 1248 | This can happen in Microsoft Visual C++ if Qt is configured as single-threaded. A safe
|
---|
| 1249 | alternative is to call ascii() directly and construct a std::string manually.
|
---|
| 1250 |
|
---|
| 1251 | <h3 class=fn>bool <a name="operator!"></a>QString::operator! () const
|
---|
| 1252 | </h3>
|
---|
| 1253 |
|
---|
| 1254 | <p> Returns TRUE if this is a null string; otherwise returns FALSE.
|
---|
| 1255 | <p> <pre>
|
---|
| 1256 | QString name = getName();
|
---|
| 1257 | if ( !name )
|
---|
| 1258 | name = "Rodney";
|
---|
| 1259 | </pre>
|
---|
| 1260 |
|
---|
| 1261 | <p> Note that if you say
|
---|
| 1262 | <p> <pre>
|
---|
| 1263 | QString name = getName();
|
---|
| 1264 | if ( name )
|
---|
| 1265 | doSomethingWith(name);
|
---|
| 1266 | </pre>
|
---|
| 1267 |
|
---|
| 1268 | <p> It will call "operator const char*()", which is inefficent; you
|
---|
| 1269 | may wish to define the macro <tt>QT_NO_ASCII_CAST</tt> when writing code
|
---|
| 1270 | which you wish to remain Unicode-clean.
|
---|
| 1271 | <p> When you want the above semantics, use:
|
---|
| 1272 | <p> <pre>
|
---|
| 1273 | QString name = getName();
|
---|
| 1274 | if ( !name.<a href="#isNull">isNull</a>() )
|
---|
| 1275 | doSomethingWith(name);
|
---|
| 1276 | </pre>
|
---|
| 1277 |
|
---|
| 1278 | <p> <p>See also <a href="#isEmpty">isEmpty</a>().
|
---|
| 1279 |
|
---|
| 1280 | <h3 class=fn><a href="qstring.html">QString</a> & <a name="operator+-eq"></a>QString::operator+= ( const <a href="qstring.html">QString</a> & str )
|
---|
| 1281 | </h3>
|
---|
| 1282 | Appends <em>str</em> to the string and returns a reference to the string.
|
---|
| 1283 |
|
---|
| 1284 | <h3 class=fn><a href="qstring.html">QString</a> & <a name="operator+-eq-2"></a>QString::operator+= ( const <a href="qbytearray.html">QByteArray</a> & str )
|
---|
| 1285 | </h3>
|
---|
| 1286 |
|
---|
| 1287 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 1288 | <p> Appends <em>str</em> to the string and returns a reference to the string.
|
---|
| 1289 |
|
---|
| 1290 | <h3 class=fn><a href="qstring.html">QString</a> & <a name="operator+-eq-3"></a>QString::operator+= ( const char * str )
|
---|
| 1291 | </h3>
|
---|
| 1292 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 1293 | <p> Appends <em>str</em> to the string and returns a reference to the string.
|
---|
| 1294 |
|
---|
| 1295 | <h3 class=fn><a href="qstring.html">QString</a> & <a name="operator+-eq-4"></a>QString::operator+= ( const std::string & str )
|
---|
| 1296 | </h3>
|
---|
| 1297 |
|
---|
| 1298 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 1299 | <p> Appends <em>str</em> to the string and returns a reference to the string.
|
---|
| 1300 |
|
---|
| 1301 | <h3 class=fn><a href="qstring.html">QString</a> & <a name="operator+-eq-5"></a>QString::operator+= ( <a href="qchar.html">QChar</a> c )
|
---|
| 1302 | </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 1303 | <p> Appends <em>c</em> to the string and returns a reference to the string.
|
---|
| 1304 |
|
---|
| 1305 | <h3 class=fn><a href="qstring.html">QString</a> & <a name="operator+-eq-6"></a>QString::operator+= ( char c )
|
---|
| 1306 | </h3>
|
---|
| 1307 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 1308 | <p> Appends <em>c</em> to the string and returns a reference to the string.
|
---|
| 1309 |
|
---|
| 1310 | <h3 class=fn><a href="qstring.html">QString</a> & <a name="operator-eq"></a>QString::operator= ( <a href="qchar.html">QChar</a> c )
|
---|
| 1311 | </h3>
|
---|
| 1312 |
|
---|
| 1313 | <p> Sets the string to contain just the single character <em>c</em>.
|
---|
| 1314 |
|
---|
| 1315 | <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 )
|
---|
| 1316 | </h3>
|
---|
| 1317 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 1318 | <p> Assigns a <a href="shclass.html#shallow-copy">shallow copy</a> of <em>s</em> to this string and returns a
|
---|
| 1319 | reference to this string. This is very fast because the string
|
---|
| 1320 | isn't actually copied.
|
---|
| 1321 |
|
---|
| 1322 | <h3 class=fn><a href="qstring.html">QString</a> & <a name="operator-eq-3"></a>QString::operator= ( const char * str )
|
---|
| 1323 | </h3>
|
---|
| 1324 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 1325 | <p> Assigns a <a href="shclass.html#deep-copy">deep copy</a> of <em>str</em>, interpreted as a classic C string
|
---|
| 1326 | to this string and returns a reference to this string.
|
---|
| 1327 | <p> If <em>str</em> is 0, then a null string is created.
|
---|
| 1328 | <p> <p>See also <a href="#isNull">isNull</a>().
|
---|
| 1329 |
|
---|
| 1330 | <h3 class=fn><a href="qstring.html">QString</a> & <a name="operator-eq-4"></a>QString::operator= ( const std::string & s )
|
---|
| 1331 | </h3>
|
---|
| 1332 |
|
---|
| 1333 | <p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 1334 | <p> Makes a <a href="shclass.html#deep-copy">deep copy</a> of <em>s</em> and returns a reference to the deep
|
---|
| 1335 | copy.
|
---|
| 1336 |
|
---|
| 1337 | <h3 class=fn><a href="qstring.html">QString</a> & <a name="operator-eq-5"></a>QString::operator= ( const <a href="qcstring.html">QCString</a> & cstr )
|
---|
| 1338 | </h3>
|
---|
| 1339 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 1340 | <p> Assigns a <a href="shclass.html#deep-copy">deep copy</a> of <em>cstr</em>, interpreted as a classic C
|
---|
| 1341 | string, to this string. Returns a reference to this string.
|
---|
| 1342 |
|
---|
| 1343 | <h3 class=fn><a href="qstring.html">QString</a> & <a name="operator-eq-6"></a>QString::operator= ( char c )
|
---|
| 1344 | </h3>
|
---|
| 1345 |
|
---|
| 1346 | <p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 1347 | <p> Sets the string to contain just the single character <em>c</em>.
|
---|
| 1348 |
|
---|
| 1349 | <h3 class=fn><a href="qchar.html">QChar</a> <a name="operator[]"></a>QString::operator[] ( int i ) const
|
---|
| 1350 | </h3>
|
---|
| 1351 |
|
---|
| 1352 | <p> Returns the character at index <em>i</em>, or QChar::null if <em>i</em> is
|
---|
| 1353 | beyond the length of the string.
|
---|
| 1354 | <p> If the QString is not const (i.e., const QString) or const&
|
---|
| 1355 | (i.e., const QString&), then the non-const overload of operator[]
|
---|
| 1356 | will be used instead.
|
---|
| 1357 |
|
---|
| 1358 | <h3 class=fn><a href="qcharref.html">QCharRef</a> <a name="operator[]-2"></a>QString::operator[] ( int i )
|
---|
| 1359 | </h3>
|
---|
| 1360 |
|
---|
| 1361 | <p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 1362 | <p> The function returns a reference to the character at index <em>i</em>.
|
---|
| 1363 | The resulting reference can then be assigned to, or used
|
---|
| 1364 | immediately, but it will become invalid once further modifications
|
---|
| 1365 | are made to the original string.
|
---|
| 1366 | <p> If <em>i</em> is beyond the length of the string then the string is
|
---|
| 1367 | expanded with QChar::nulls, so that the <a href="qcharref.html">QCharRef</a> references a
|
---|
| 1368 | valid (null) character in the string.
|
---|
| 1369 | <p> The QCharRef internal class can be used much like a constant
|
---|
| 1370 | <a href="qchar.html">QChar</a>, but if you assign to it, you change the original string
|
---|
| 1371 | (which will detach itself because of QString's copy-on-write
|
---|
| 1372 | semantics). You will get compilation errors if you try to use the
|
---|
| 1373 | result as anything but a QChar.
|
---|
| 1374 |
|
---|
| 1375 | <h3 class=fn><a href="qstring.html">QString</a> & <a name="prepend"></a>QString::prepend ( const <a href="qstring.html">QString</a> & s )
|
---|
| 1376 | </h3>
|
---|
| 1377 |
|
---|
| 1378 | <p> Inserts <em>s</em> at the beginning of the string and returns a
|
---|
| 1379 | reference to the string.
|
---|
| 1380 | <p> Equivalent to <a href="#insert">insert</a>(0, <em>s</em>).
|
---|
| 1381 | <p> <pre>
|
---|
| 1382 | QString string = "42";
|
---|
| 1383 | string.<a href="#prepend">prepend</a>( "The answer is " );
|
---|
| 1384 | // string == "The answer is 42"
|
---|
| 1385 | </pre>
|
---|
| 1386 |
|
---|
| 1387 | <p> <p>See also <a href="#insert">insert</a>().
|
---|
| 1388 |
|
---|
| 1389 | <h3 class=fn><a href="qstring.html">QString</a> & <a name="prepend-2"></a>QString::prepend ( char ch )
|
---|
| 1390 | </h3>
|
---|
| 1391 |
|
---|
| 1392 | <p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 1393 | <p> Inserts <em>ch</em> at the beginning of the string and returns a
|
---|
| 1394 | reference to the string.
|
---|
| 1395 | <p> Equivalent to <a href="#insert">insert</a>(0, <em>ch</em>).
|
---|
| 1396 | <p> <p>See also <a href="#insert">insert</a>().
|
---|
| 1397 |
|
---|
| 1398 | <h3 class=fn><a href="qstring.html">QString</a> & <a name="prepend-3"></a>QString::prepend ( <a href="qchar.html">QChar</a> ch )
|
---|
| 1399 | </h3>
|
---|
| 1400 |
|
---|
| 1401 | <p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 1402 | <p> Inserts <em>ch</em> at the beginning of the string and returns a
|
---|
| 1403 | reference to the string.
|
---|
| 1404 | <p> Equivalent to <a href="#insert">insert</a>(0, <em>ch</em>).
|
---|
| 1405 | <p> <p>See also <a href="#insert">insert</a>().
|
---|
| 1406 |
|
---|
| 1407 | <h3 class=fn><a href="qstring.html">QString</a> & <a name="prepend-4"></a>QString::prepend ( const <a href="qbytearray.html">QByteArray</a> & s )
|
---|
| 1408 | </h3>
|
---|
| 1409 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 1410 | <p> Inserts <em>s</em> at the beginning of the string and returns a reference to the string.
|
---|
| 1411 | <p> Equivalent to <a href="#insert">insert</a>(0, <em>s</em>).
|
---|
| 1412 | <p> <p>See also <a href="#insert">insert</a>().
|
---|
| 1413 |
|
---|
| 1414 | <h3 class=fn><a href="qstring.html">QString</a> & <a name="prepend-5"></a>QString::prepend ( const char * s )
|
---|
| 1415 | </h3>
|
---|
| 1416 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 1417 | <p> Inserts <em>s</em> at the beginning of the string and returns a reference to the string.
|
---|
| 1418 | <p> Equivalent to <a href="#insert">insert</a>(0, <em>s</em>).
|
---|
| 1419 | <p> <p>See also <a href="#insert">insert</a>().
|
---|
| 1420 |
|
---|
| 1421 | <h3 class=fn><a href="qstring.html">QString</a> & <a name="prepend-6"></a>QString::prepend ( const std::string & s )
|
---|
| 1422 | </h3>
|
---|
| 1423 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 1424 | <p> Inserts <em>s</em> at the beginning of the string and returns a reference to the string.
|
---|
| 1425 | <p> Equivalent to <a href="#insert">insert</a>(0, <em>s</em>).
|
---|
| 1426 | <p> <p>See also <a href="#insert">insert</a>().
|
---|
| 1427 |
|
---|
| 1428 | <h3 class=fn><a href="qchar.html">QChar</a> & <a name="ref"></a>QString::ref ( uint i )
|
---|
| 1429 | </h3>
|
---|
| 1430 |
|
---|
| 1431 | <p> Returns the <a href="qchar.html">QChar</a> at index <em>i</em> by reference, expanding the string
|
---|
| 1432 | with QChar::null if necessary. The resulting reference can be
|
---|
| 1433 | assigned to, or otherwise used immediately, but becomes invalid
|
---|
| 1434 | once furher modifications are made to the string.
|
---|
| 1435 | <p> <pre>
|
---|
| 1436 | QString string("ABCDEF");
|
---|
| 1437 | <a href="qchar.html">QChar</a> ch = string.<a href="#ref">ref</a>( 3 ); // ch == 'D'
|
---|
| 1438 | </pre>
|
---|
| 1439 |
|
---|
| 1440 | <p> <p>See also <a href="#constref">constref</a>().
|
---|
| 1441 |
|
---|
| 1442 | <h3 class=fn><a href="qstring.html">QString</a> & <a name="remove"></a>QString::remove ( uint index, uint len )
|
---|
| 1443 | </h3>
|
---|
| 1444 | Removes <em>len</em> characters from the string starting at position <em>index</em>, and returns a reference to the string.
|
---|
| 1445 | <p> If <em>index</em> is beyond the length of the string, nothing happens.
|
---|
| 1446 | If <em>index</em> is within the string, but <em>index</em> + <em>len</em> is beyond
|
---|
| 1447 | the end of the string, the string is truncated at position <em>index</em>.
|
---|
| 1448 | <p> <pre>
|
---|
| 1449 | QString string( "Montreal" );
|
---|
| 1450 | string.<a href="#remove">remove</a>( 1, 4 ); // string == "Meal"
|
---|
| 1451 | </pre>
|
---|
| 1452 |
|
---|
| 1453 | <p> <p>See also <a href="#insert">insert</a>() and <a href="#replace">replace</a>().
|
---|
| 1454 |
|
---|
| 1455 | <h3 class=fn><a href="qstring.html">QString</a> & <a name="remove-2"></a>QString::remove ( const <a href="qstring.html">QString</a> & str, bool cs = TRUE )
|
---|
| 1456 | </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 1457 | <p> Removes every occurrence of <em>str</em> in the string. Returns a
|
---|
| 1458 | reference to the string.
|
---|
| 1459 | <p> If <em>cs</em> is TRUE (the default), the search is case sensitive;
|
---|
| 1460 | otherwise the search is case insensitive.
|
---|
| 1461 | <p> This is the same as <a href="#replace">replace</a>(<em>str</em>, "", <em>cs</em>).
|
---|
| 1462 |
|
---|
| 1463 | <h3 class=fn><a href="qstring.html">QString</a> & <a name="remove-3"></a>QString::remove ( <a href="qchar.html">QChar</a> c )
|
---|
| 1464 | </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 1465 | <p> Removes every occurrence of the character <em>c</em> in the string.
|
---|
| 1466 | Returns a reference to the string.
|
---|
| 1467 | <p> This is the same as <a href="#replace">replace</a>(<em>c</em>, "").
|
---|
| 1468 |
|
---|
| 1469 | <h3 class=fn><a href="qstring.html">QString</a> & <a name="remove-4"></a>QString::remove ( char c )
|
---|
| 1470 | </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 1471 | <p>
|
---|
| 1472 | <p> Removes every occurrence of the character <em>c</em> in the string.
|
---|
| 1473 | Returns a reference to the string.
|
---|
| 1474 | <p> This is the same as <a href="#replace">replace</a>(<em>c</em>, "").
|
---|
| 1475 |
|
---|
| 1476 | <h3 class=fn><a href="qstring.html">QString</a> & <a name="remove-5"></a>QString::remove ( const char * str )
|
---|
| 1477 | </h3>
|
---|
| 1478 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 1479 | <p> Removes every occurrence of <em>str</em> in the string. Returns a
|
---|
| 1480 | reference to the string.
|
---|
| 1481 |
|
---|
| 1482 | <h3 class=fn><a href="qstring.html">QString</a> & <a name="remove-6"></a>QString::remove ( const <a href="qregexp.html">QRegExp</a> & rx )
|
---|
| 1483 | </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 1484 | <p> Removes every occurrence of the <a href="qregexp.html#regular-expression">regular expression</a> <em>rx</em> in the
|
---|
| 1485 | string. Returns a reference to the string.
|
---|
| 1486 | <p> This is the same as <a href="#replace">replace</a>(<em>rx</em>, "").
|
---|
| 1487 |
|
---|
| 1488 | <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 )
|
---|
| 1489 | </h3>
|
---|
| 1490 | Replaces <em>len</em> characters from the string with <em>s</em>, starting at
|
---|
| 1491 | position <em>index</em>, and returns a reference to the string.
|
---|
| 1492 | <p> If <em>index</em> is beyond the length of the string, nothing is deleted
|
---|
| 1493 | and <em>s</em> is appended at the end of the string. If <em>index</em> is
|
---|
| 1494 | valid, but <em>index</em> + <em>len</em> is beyond the end of the string,
|
---|
| 1495 | the string is truncated at position <em>index</em>, then <em>s</em> is
|
---|
| 1496 | appended at the end.
|
---|
| 1497 | <p> <pre>
|
---|
| 1498 | QString string( "Say yes!" );
|
---|
| 1499 | string = string.<a href="#replace">replace</a>( 4, 3, "NO" );
|
---|
| 1500 | // string == "Say NO!"
|
---|
| 1501 | </pre>
|
---|
| 1502 |
|
---|
| 1503 | <p> <b>Warning:</b> Qt 3.3.3 and earlier had different semantics for the
|
---|
| 1504 | case <em>index</em> >= <a href="#length">length</a>(), which contradicted the documentation.
|
---|
| 1505 | To avoid portability problems between Qt 3 versions and with Qt
|
---|
| 1506 | 4, we recommend that you never call the function with <em>index</em> >=
|
---|
| 1507 | length().
|
---|
| 1508 | <p> <p>See also <a href="#insert">insert</a>() and <a href="#remove">remove</a>().
|
---|
| 1509 |
|
---|
| 1510 | <p>Examples: <a href="listviews-example.html#x162">listviews/listviews.cpp</a>, <a href="networkprotocol-example.html#x694">network/networkprotocol/nntp.cpp</a>, <a href="qmag-example.html#x1794">qmag/qmag.cpp</a>, and <a href="regexptester-example.html#x2497">regexptester/regexptester.cpp</a>.
|
---|
| 1511 | <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 )
|
---|
| 1512 | </h3>
|
---|
| 1513 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 1514 | <p> Replaces <em>len</em> characters with <em>slen</em> characters of <a href="qchar.html">QChar</a> data
|
---|
| 1515 | from <em>s</em>, starting at position <em>index</em>, and returns a reference
|
---|
| 1516 | to the string.
|
---|
| 1517 | <p> <p>See also <a href="#insert">insert</a>() and <a href="#remove">remove</a>().
|
---|
| 1518 |
|
---|
| 1519 | <h3 class=fn><a href="qstring.html">QString</a> & <a name="replace-3"></a>QString::replace ( uint index, uint len, <a href="qchar.html">QChar</a> c )
|
---|
| 1520 | </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 1521 | <p> This is the same as <a href="#replace">replace</a>(<em>index</em>, <em>len</em>, QString(<em>c</em>)).
|
---|
| 1522 |
|
---|
| 1523 | <h3 class=fn><a href="qstring.html">QString</a> & <a name="replace-4"></a>QString::replace ( uint index, uint len, char c )
|
---|
| 1524 | </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 1525 | <p>
|
---|
| 1526 | <p> This is the same as <a href="#replace">replace</a>(<em>index</em>, <em>len</em>, <a href="qchar.html">QChar</a>(<em>c</em>)).
|
---|
| 1527 |
|
---|
| 1528 | <h3 class=fn><a href="qstring.html">QString</a> & <a name="replace-5"></a>QString::replace ( <a href="qchar.html">QChar</a> c, const <a href="qstring.html">QString</a> & after, bool cs = TRUE )
|
---|
| 1529 | </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 1530 | <p> Replaces every occurrence of the character <em>c</em> in the string
|
---|
| 1531 | with <em>after</em>. Returns a reference to the string.
|
---|
| 1532 | <p> If <em>cs</em> is TRUE (the default), the search is case sensitive;
|
---|
| 1533 | otherwise the search is case insensitive.
|
---|
| 1534 | <p> Example:
|
---|
| 1535 | <pre>
|
---|
| 1536 | QString s = "a,b,c";
|
---|
| 1537 | s.<a href="#replace">replace</a>( QChar(','), " or " );
|
---|
| 1538 | // s == "a or b or c"
|
---|
| 1539 | </pre>
|
---|
| 1540 |
|
---|
| 1541 |
|
---|
| 1542 | <h3 class=fn><a href="qstring.html">QString</a> & <a name="replace-6"></a>QString::replace ( char c, const <a href="qstring.html">QString</a> & after, bool cs = TRUE )
|
---|
| 1543 | </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 1544 | <p>
|
---|
| 1545 | <p> Replaces every occurrence of the character <em>c</em> in the string
|
---|
| 1546 | with <em>after</em>. Returns a reference to the string.
|
---|
| 1547 | <p> If <em>cs</em> is TRUE (the default), the search is case sensitive;
|
---|
| 1548 | otherwise the search is case insensitive.
|
---|
| 1549 |
|
---|
| 1550 | <h3 class=fn><a href="qstring.html">QString</a> & <a name="replace-7"></a>QString::replace ( const <a href="qstring.html">QString</a> & before, const <a href="qstring.html">QString</a> & after, bool cs = TRUE )
|
---|
| 1551 | </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 1552 | <p> Replaces every occurrence of the string <em>before</em> in the string
|
---|
| 1553 | with the string <em>after</em>. Returns a reference to the string.
|
---|
| 1554 | <p> If <em>cs</em> is TRUE (the default), the search is case sensitive;
|
---|
| 1555 | otherwise the search is case insensitive.
|
---|
| 1556 | <p> Example:
|
---|
| 1557 | <pre>
|
---|
| 1558 | QString s = "Greek is Greek";
|
---|
| 1559 | s.<a href="#replace">replace</a>( "Greek", "English" );
|
---|
| 1560 | // s == "English is English"
|
---|
| 1561 | </pre>
|
---|
| 1562 |
|
---|
| 1563 |
|
---|
| 1564 | <h3 class=fn><a href="qstring.html">QString</a> & <a name="replace-8"></a>QString::replace ( const <a href="qregexp.html">QRegExp</a> & rx, const <a href="qstring.html">QString</a> & after )
|
---|
| 1565 | </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 1566 | <p> Replaces every occurrence of the regexp <em>rx</em> in the string with
|
---|
| 1567 | <em>after</em>. Returns a reference to the string. For example:
|
---|
| 1568 | <pre>
|
---|
| 1569 | QString s = "banana";
|
---|
| 1570 | s.<a href="#replace">replace</a>( QRegExp("an"), "" );
|
---|
| 1571 | // s == "ba"
|
---|
| 1572 | </pre>
|
---|
| 1573 |
|
---|
| 1574 | <p> For regexps containing <a href="qregexp.html#capturing-text">capturing
|
---|
| 1575 | parentheses</a>, occurrences of <b>\1</b>, <b>\2</b>, ...,
|
---|
| 1576 | in <em>after</em> are replaced with <em>rx</em>.cap(1), cap(2), ...
|
---|
| 1577 | <p> <pre>
|
---|
| 1578 | QString t = "A <i>bon mot</i>.";
|
---|
| 1579 | t.<a href="#replace">replace</a>( QRegExp("<i>([^<]*)</i>"), "\\emph{\\1}" );
|
---|
| 1580 | // t == "A \\emph{bon mot}."
|
---|
| 1581 | </pre>
|
---|
| 1582 |
|
---|
| 1583 | <p> <p>See also <a href="#find">find</a>(), <a href="#findRev">findRev</a>(), and <a href="qregexp.html#cap">QRegExp::cap</a>().
|
---|
| 1584 |
|
---|
| 1585 | <h3 class=fn><a href="qstring.html">QString</a> & <a name="replace-9"></a>QString::replace ( <a href="qchar.html">QChar</a> c1, <a href="qchar.html">QChar</a> c2 )
|
---|
| 1586 | </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 1587 | <p> Replaces every occurrence of <em>c1</em> with the char <em>c2</em>. Returns a
|
---|
| 1588 | reference to the string.
|
---|
| 1589 |
|
---|
| 1590 | <h3 class=fn>void <a name="reserve"></a>QString::reserve ( uint minCapacity )
|
---|
| 1591 | </h3>
|
---|
| 1592 | Ensures that at least <em>minCapacity</em> characters are allocated to
|
---|
| 1593 | the string.
|
---|
| 1594 | <p> This function is useful for code that needs to build up a long
|
---|
| 1595 | string and wants to avoid repeated reallocation. In this example,
|
---|
| 1596 | we want to add to the string until some condition is true, and
|
---|
| 1597 | we're fairly sure that size is big enough:
|
---|
| 1598 | <pre>
|
---|
| 1599 | QString result;
|
---|
| 1600 | int len = 0;
|
---|
| 1601 | result.<a href="#reserve">reserve</a>(maxLen);
|
---|
| 1602 | while (...) {
|
---|
| 1603 | result[len++] = ... // fill part of the space
|
---|
| 1604 | }
|
---|
| 1605 | result.<a href="#squeeze">squeeze</a>();
|
---|
| 1606 | </pre>
|
---|
| 1607 |
|
---|
| 1608 | <p> If <em>maxLen</em> is an underestimate, the worst that will happen is
|
---|
| 1609 | that the loop will slow down.
|
---|
| 1610 | <p> If it is not possible to allocate enough memory, the string
|
---|
| 1611 | remains unchanged.
|
---|
| 1612 | <p> <p>See also <a href="#capacity">capacity</a>(), <a href="#squeeze">squeeze</a>(), and <a href="#setLength">setLength</a>().
|
---|
| 1613 |
|
---|
| 1614 | <h3 class=fn><a href="qstring.html">QString</a> <a name="right"></a>QString::right ( uint len ) const
|
---|
| 1615 | </h3>
|
---|
| 1616 | Returns a string that contains the <em>len</em> rightmost characters of
|
---|
| 1617 | the string.
|
---|
| 1618 | <p> If <em>len</em> is greater than the length of the string then the whole
|
---|
| 1619 | string is returned.
|
---|
| 1620 | <p> <pre>
|
---|
| 1621 | QString string( "Pineapple" );
|
---|
| 1622 | QString t = string.<a href="#right">right</a>( 5 ); // t == "apple"
|
---|
| 1623 | </pre>
|
---|
| 1624 |
|
---|
| 1625 | <p> <p>See also <a href="#left">left</a>(), <a href="#mid">mid</a>(), and <a href="#isEmpty">isEmpty</a>().
|
---|
| 1626 |
|
---|
| 1627 | <p>Example: <a href="fileiconview-example.html#x871">fileiconview/qfileiconview.cpp</a>.
|
---|
| 1628 | <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
|
---|
| 1629 | </h3>
|
---|
| 1630 | Returns a string of length <em>width</em> that contains the <em>fill</em>
|
---|
| 1631 | character followed by the string.
|
---|
| 1632 | <p> If <em>truncate</em> is FALSE and the length of the string is more than
|
---|
| 1633 | <em>width</em>, then the returned string is a copy of the string.
|
---|
| 1634 | <p> If <em>truncate</em> is TRUE and the length of the string is more than
|
---|
| 1635 | <em>width</em>, then the resulting string is truncated at position <em>width</em>.
|
---|
| 1636 | <p> <pre>
|
---|
| 1637 | QString string( "apple" );
|
---|
| 1638 | QString t = string.<a href="#rightJustify">rightJustify</a>( 8, '.' ); // t == "...apple"
|
---|
| 1639 | </pre>
|
---|
| 1640 |
|
---|
| 1641 | <p> <p>See also <a href="#leftJustify">leftJustify</a>().
|
---|
| 1642 |
|
---|
| 1643 | <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
|
---|
| 1644 | </h3>
|
---|
| 1645 |
|
---|
| 1646 | <p> This function returns a section of the string.
|
---|
| 1647 | <p> This string is treated as a sequence of fields separated by the
|
---|
| 1648 | character, <em>sep</em>. The returned string consists of the fields from
|
---|
| 1649 | position <em>start</em> to position <em>end</em> inclusive. If <em>end</em> is not
|
---|
| 1650 | specified, all fields from position <em>start</em> to the end of the
|
---|
| 1651 | string are included. Fields are numbered 0, 1, 2, etc., counting
|
---|
| 1652 | from the left, and -1, -2, etc., counting from right to left.
|
---|
| 1653 | <p> The <em>flags</em> argument can be used to affect some aspects of the
|
---|
| 1654 | function's behaviour, e.g. whether to be case sensitive, whether
|
---|
| 1655 | to skip empty fields and how to deal with leading and trailing
|
---|
| 1656 | separators; see <a href="#SectionFlags-enum">SectionFlags</a>.
|
---|
| 1657 | <p> <pre>
|
---|
| 1658 | QString csv( "forename,middlename,surname,phone" );
|
---|
| 1659 | QString s = csv.<a href="#section">section</a>( ',', 2, 2 ); // s == "surname"
|
---|
| 1660 |
|
---|
| 1661 | QString path( "/usr/local/bin/myapp" ); // First field is empty
|
---|
| 1662 | QString s = path.<a href="#section">section</a>( '/', 3, 4 ); // s == "bin/myapp"
|
---|
| 1663 | QString s = path.<a href="#section">section</a>( '/', 3, 3, SectionSkipEmpty ); // s == "myapp"
|
---|
| 1664 | </pre>
|
---|
| 1665 |
|
---|
| 1666 | <p> If <em>start</em> or <em>end</em> is negative, we count fields from the right
|
---|
| 1667 | of the string, the right-most field being -1, the one from
|
---|
| 1668 | right-most field being -2, and so on.
|
---|
| 1669 | <p> <pre>
|
---|
| 1670 | QString csv( "forename,middlename,surname,phone" );
|
---|
| 1671 | QString s = csv.<a href="#section">section</a>( ',', -3, -2 ); // s == "middlename,surname"
|
---|
| 1672 |
|
---|
| 1673 | QString path( "/usr/local/bin/myapp" ); // First field is empty
|
---|
| 1674 | QString s = path.<a href="#section">section</a>( '/', -1 ); // s == "myapp"
|
---|
| 1675 | </pre>
|
---|
| 1676 |
|
---|
| 1677 | <p> <p>See also <a href="qstringlist.html#split">QStringList::split</a>().
|
---|
| 1678 |
|
---|
| 1679 | <p>Examples: <a href="tutorial2-03.html#x2551">chart/element.cpp</a> and <a href="ftpclient-example.html#x772">network/ftpclient/ftpmainwindow.ui.h</a>.
|
---|
| 1680 | <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
|
---|
| 1681 | </h3>
|
---|
| 1682 |
|
---|
| 1683 | <p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 1684 | <p>
|
---|
| 1685 | <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
|
---|
| 1686 | </h3>
|
---|
| 1687 |
|
---|
| 1688 | <p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 1689 | <p>
|
---|
| 1690 | <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
|
---|
| 1691 | </h3>
|
---|
| 1692 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 1693 | <p> This function returns a section of the string.
|
---|
| 1694 | <p> This string is treated as a sequence of fields separated by the
|
---|
| 1695 | string, <em>sep</em>. The returned string consists of the fields from
|
---|
| 1696 | position <em>start</em> to position <em>end</em> inclusive. If <em>end</em> is not
|
---|
| 1697 | specified, all fields from position <em>start</em> to the end of the
|
---|
| 1698 | string are included. Fields are numbered 0, 1, 2, etc., counting
|
---|
| 1699 | from the left, and -1, -2, etc., counting from right to left.
|
---|
| 1700 | <p> The <em>flags</em> argument can be used to affect some aspects of the
|
---|
| 1701 | function's behaviour, e.g. whether to be case sensitive, whether
|
---|
| 1702 | to skip empty fields and how to deal with leading and trailing
|
---|
| 1703 | separators; see <a href="#SectionFlags-enum">SectionFlags</a>.
|
---|
| 1704 | <p> <pre>
|
---|
| 1705 | QString data( "forename**middlename**surname**phone" );
|
---|
| 1706 | QString s = data.<a href="#section">section</a>( "**", 2, 2 ); // s == "surname"
|
---|
| 1707 | </pre>
|
---|
| 1708 |
|
---|
| 1709 | <p> If <em>start</em> or <em>end</em> is negative, we count fields from the right
|
---|
| 1710 | of the string, the right-most field being -1, the one from
|
---|
| 1711 | right-most field being -2, and so on.
|
---|
| 1712 | <p> <pre>
|
---|
| 1713 | QString data( "forename**middlename**surname**phone" );
|
---|
| 1714 | QString s = data.<a href="#section">section</a>( "**", -3, -2 ); // s == "middlename**surname"
|
---|
| 1715 | </pre>
|
---|
| 1716 |
|
---|
| 1717 | <p> <p>See also <a href="qstringlist.html#split">QStringList::split</a>().
|
---|
| 1718 |
|
---|
| 1719 | <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
|
---|
| 1720 | </h3>
|
---|
| 1721 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 1722 | <p> This function returns a section of the string.
|
---|
| 1723 | <p> This string is treated as a sequence of fields separated by the
|
---|
| 1724 | <a href="qregexp.html#regular-expression">regular expression</a>, <em>reg</em>. The returned string consists of the
|
---|
| 1725 | 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
|
---|
| 1726 | of the string are included. Fields are numbered 0, 1, 2, etc., counting
|
---|
| 1727 | from the left, and -1, -2, etc., counting from right to left.
|
---|
| 1728 | <p> The <em>flags</em> argument can be used to affect some aspects of the
|
---|
| 1729 | function's behaviour, e.g. whether to be case sensitive, whether
|
---|
| 1730 | to skip empty fields and how to deal with leading and trailing
|
---|
| 1731 | separators; see <a href="#SectionFlags-enum">SectionFlags</a>.
|
---|
| 1732 | <p> <pre>
|
---|
| 1733 | QString line( "forename\tmiddlename surname \t \t phone" );
|
---|
| 1734 | <a href="qregexp.html">QRegExp</a> sep( "\s+" );
|
---|
| 1735 | QString s = line.<a href="#section">section</a>( sep, 2, 2 ); // s == "surname"
|
---|
| 1736 | </pre>
|
---|
| 1737 |
|
---|
| 1738 | <p> If <em>start</em> or <em>end</em> is negative, we count fields from the right
|
---|
| 1739 | of the string, the right-most field being -1, the one from
|
---|
| 1740 | right-most field being -2, and so on.
|
---|
| 1741 | <p> <pre>
|
---|
| 1742 | QString line( "forename\tmiddlename surname \t \t phone" );
|
---|
| 1743 | <a href="qregexp.html">QRegExp</a> sep( "\\s+" );
|
---|
| 1744 | QString s = line.<a href="#section">section</a>( sep, -3, -2 ); // s == "middlename surname"
|
---|
| 1745 | </pre>
|
---|
| 1746 |
|
---|
| 1747 | <p> <b>Warning:</b> Using this <a href="qregexp.html">QRegExp</a> version is much more expensive than
|
---|
| 1748 | the overloaded string and character versions.
|
---|
| 1749 | <p> <p>See also <a href="qstringlist.html#split">QStringList::split</a>() and <a href="#simplifyWhiteSpace">simplifyWhiteSpace</a>().
|
---|
| 1750 |
|
---|
| 1751 | <h3 class=fn><a href="qstring.html">QString</a> & <a name="setAscii"></a>QString::setAscii ( const char * str, int len = -1 )
|
---|
| 1752 | </h3>
|
---|
| 1753 | Sets this string to <em>str</em>, interpreted as a classic 8-bit ASCII C
|
---|
| 1754 | string. If <em>len</em> is -1 (the default), then it is set to
|
---|
| 1755 | strlen(str).
|
---|
| 1756 | <p> If <em>str</em> is 0 a null string is created. If <em>str</em> is "", an empty
|
---|
| 1757 | string is created.
|
---|
| 1758 | <p> <p>See also <a href="#isNull">isNull</a>() and <a href="#isEmpty">isEmpty</a>().
|
---|
| 1759 |
|
---|
| 1760 | <h3 class=fn>void <a name="setExpand"></a>QString::setExpand ( uint index, <a href="qchar.html">QChar</a> c )
|
---|
| 1761 | </h3> <b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
|
---|
| 1762 | <p> Sets the character at position <em>index</em> to <em>c</em> and expands the
|
---|
| 1763 | string if necessary, filling with spaces.
|
---|
| 1764 | <p> This method is redundant in Qt 3.x, because operator[] will expand
|
---|
| 1765 | the string as necessary.
|
---|
| 1766 |
|
---|
| 1767 | <h3 class=fn><a href="qstring.html">QString</a> & <a name="setLatin1"></a>QString::setLatin1 ( const char * str, int len = -1 )
|
---|
| 1768 | </h3>
|
---|
| 1769 | Sets this string to <em>str</em>, interpreted as a classic Latin-1 C
|
---|
| 1770 | string. If <em>len</em> is -1 (the default), then it is set to
|
---|
| 1771 | strlen(str).
|
---|
| 1772 | <p> If <em>str</em> is 0 a null string is created. If <em>str</em> is "", an empty
|
---|
| 1773 | string is created.
|
---|
| 1774 | <p> <p>See also <a href="#isNull">isNull</a>() and <a href="#isEmpty">isEmpty</a>().
|
---|
| 1775 |
|
---|
| 1776 | <h3 class=fn>void <a name="setLength"></a>QString::setLength ( uint newLen )
|
---|
| 1777 | </h3>
|
---|
| 1778 | Ensures that at least <em>newLen</em> characters are allocated to the
|
---|
| 1779 | string, and sets the length of the string to <em>newLen</em>. Any new
|
---|
| 1780 | space allocated contains arbitrary data.
|
---|
| 1781 | <p> <p>See also <a href="#reserve">reserve</a>() and <a href="#truncate">truncate</a>().
|
---|
| 1782 |
|
---|
| 1783 | <h3 class=fn><a href="qstring.html">QString</a> & <a name="setNum"></a>QString::setNum ( Q_LLONG n, int base = 10 )
|
---|
| 1784 | </h3>
|
---|
| 1785 | Sets the string to the printed value of <em>n</em> in base <em>base</em> and
|
---|
| 1786 | returns a reference to the string. The returned string is in "C" locale.
|
---|
| 1787 | <p> The base is 10 by default and must be between 2 and 36.
|
---|
| 1788 | <p> <pre>
|
---|
| 1789 | QString string;
|
---|
| 1790 | string = string.<a href="#setNum">setNum</a>( 1234 ); // string == "1234"
|
---|
| 1791 | </pre>
|
---|
| 1792 |
|
---|
| 1793 |
|
---|
| 1794 | <h3 class=fn><a href="qstring.html">QString</a> & <a name="setNum-2"></a>QString::setNum ( short n, int base = 10 )
|
---|
| 1795 | </h3>
|
---|
| 1796 |
|
---|
| 1797 | <p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 1798 | <p> Sets the string to the printed value of <em>n</em> in base <em>base</em> and
|
---|
| 1799 | returns a reference to the string.
|
---|
| 1800 | <p> The base is 10 by default and must be between 2 and 36.
|
---|
| 1801 |
|
---|
| 1802 | <h3 class=fn><a href="qstring.html">QString</a> & <a name="setNum-3"></a>QString::setNum ( ushort n, int base = 10 )
|
---|
| 1803 | </h3>
|
---|
| 1804 |
|
---|
| 1805 | <p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 1806 | <p> Sets the string to the printed value of <em>n</em> in base <em>base</em> and
|
---|
| 1807 | returns a reference to the string.
|
---|
| 1808 | <p> The base is 10 by default and must be between 2 and 36.
|
---|
| 1809 |
|
---|
| 1810 | <h3 class=fn><a href="qstring.html">QString</a> & <a name="setNum-4"></a>QString::setNum ( int n, int base = 10 )
|
---|
| 1811 | </h3>
|
---|
| 1812 |
|
---|
| 1813 | <p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 1814 | <p> Sets the string to the printed value of <em>n</em> in base <em>base</em> and
|
---|
| 1815 | returns a reference to the string.
|
---|
| 1816 | <p> The base is 10 by default and must be between 2 and 36.
|
---|
| 1817 |
|
---|
| 1818 | <h3 class=fn><a href="qstring.html">QString</a> & <a name="setNum-5"></a>QString::setNum ( uint n, int base = 10 )
|
---|
| 1819 | </h3>
|
---|
| 1820 |
|
---|
| 1821 | <p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 1822 | <p> Sets the string to the printed value of <em>n</em> in base <em>base</em> and
|
---|
| 1823 | returns a reference to the string.
|
---|
| 1824 | <p> The base is 10 by default and must be between 2 and 36.
|
---|
| 1825 |
|
---|
| 1826 | <h3 class=fn><a href="qstring.html">QString</a> & <a name="setNum-6"></a>QString::setNum ( long n, int base = 10 )
|
---|
| 1827 | </h3>
|
---|
| 1828 |
|
---|
| 1829 | <p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 1830 | <p>
|
---|
| 1831 | <h3 class=fn><a href="qstring.html">QString</a> & <a name="setNum-7"></a>QString::setNum ( ulong n, int base = 10 )
|
---|
| 1832 | </h3>
|
---|
| 1833 |
|
---|
| 1834 | <p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 1835 | <p>
|
---|
| 1836 | <h3 class=fn><a href="qstring.html">QString</a> & <a name="setNum-8"></a>QString::setNum ( Q_ULLONG n, int base = 10 )
|
---|
| 1837 | </h3>
|
---|
| 1838 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 1839 | <p> Sets the string to the printed value of <em>n</em> in base <em>base</em> and
|
---|
| 1840 | returns a reference to the string.
|
---|
| 1841 | <p> The base is 10 by default and must be between 2 and 36.
|
---|
| 1842 |
|
---|
| 1843 | <h3 class=fn><a href="qstring.html">QString</a> & <a name="setNum-9"></a>QString::setNum ( float n, char f = 'g', int prec = 6 )
|
---|
| 1844 | </h3>
|
---|
| 1845 |
|
---|
| 1846 | <p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 1847 | <p> Sets the string to the printed value of <em>n</em>, formatted in format
|
---|
| 1848 | <em>f</em> with precision <em>prec</em>, and returns a reference to the
|
---|
| 1849 | string.
|
---|
| 1850 | <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.
|
---|
| 1851 |
|
---|
| 1852 | <h3 class=fn><a href="qstring.html">QString</a> & <a name="setNum-a"></a>QString::setNum ( double n, char f = 'g', int prec = 6 )
|
---|
| 1853 | </h3>
|
---|
| 1854 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 1855 | <p> Sets the string to the printed value of <em>n</em>, formatted in format
|
---|
| 1856 | <em>f</em> with precision <em>prec</em>, and returns a reference to the
|
---|
| 1857 | string.
|
---|
| 1858 | <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.
|
---|
| 1859 |
|
---|
| 1860 | <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 )
|
---|
| 1861 | </h3>
|
---|
| 1862 | Resizes the string to <em>len</em> characters and copies <em>unicode</em> into
|
---|
| 1863 | the string. If <em>unicode</em> is 0, nothing is copied, but the
|
---|
| 1864 | string is still resized to <em>len</em>. If <em>len</em> is zero, then the
|
---|
| 1865 | string becomes a <a href="#isNull">null</a> string.
|
---|
| 1866 | <p> <p>See also <a href="#setLatin1">setLatin1</a>() and <a href="#isNull">isNull</a>().
|
---|
| 1867 |
|
---|
| 1868 | <h3 class=fn><a href="qstring.html">QString</a> & <a name="setUnicodeCodes"></a>QString::setUnicodeCodes ( const ushort * unicode_as_ushorts, uint len )
|
---|
| 1869 | </h3>
|
---|
| 1870 | Resizes the string to <em>len</em> characters and copies <em>unicode_as_ushorts</em> into the string (on some X11 client platforms
|
---|
| 1871 | this will involve a byte-swapping pass).
|
---|
| 1872 | <p> If <em>unicode_as_ushorts</em> is 0, nothing is copied, but the string
|
---|
| 1873 | is still resized to <em>len</em>. If <em>len</em> is zero, the string becomes
|
---|
| 1874 | a <a href="#isNull">null</a> string.
|
---|
| 1875 | <p> <p>See also <a href="#setLatin1">setLatin1</a>() and <a href="#isNull">isNull</a>().
|
---|
| 1876 |
|
---|
| 1877 | <h3 class=fn><a href="qstring.html">QString</a> <a name="simplifyWhiteSpace"></a>QString::simplifyWhiteSpace () const
|
---|
| 1878 | </h3>
|
---|
| 1879 | Returns a string that has whitespace removed from the start and
|
---|
| 1880 | the end, and which has each sequence of internal whitespace
|
---|
| 1881 | replaced with a single space.
|
---|
| 1882 | <p> Whitespace means any character for which <a href="qchar.html#isSpace">QChar::isSpace</a>() returns
|
---|
| 1883 | TRUE. This includes Unicode characters with decimal values 9
|
---|
| 1884 | (TAB), 10 (LF), 11 (VT), 12 (FF), 13 (CR), and 32 (Space).
|
---|
| 1885 | <p> <pre>
|
---|
| 1886 | QString string = " lots\t of\nwhite space ";
|
---|
| 1887 | QString t = string.<a href="#simplifyWhiteSpace">simplifyWhiteSpace</a>();
|
---|
| 1888 | // t == "lots of white space"
|
---|
| 1889 | </pre>
|
---|
| 1890 |
|
---|
| 1891 | <p> <p>See also <a href="#stripWhiteSpace">stripWhiteSpace</a>().
|
---|
| 1892 |
|
---|
| 1893 | <h3 class=fn><a href="qstring.html">QString</a> & <a name="sprintf"></a>QString::sprintf ( const char * cformat, ... )
|
---|
| 1894 | </h3>
|
---|
| 1895 | Safely builds a formatted string from the format string <em>cformat</em>
|
---|
| 1896 | and an arbitrary list of arguments. The format string supports all
|
---|
| 1897 | the escape sequences of printf() in the standard C library.
|
---|
| 1898 | <p> The %s escape sequence expects a <a href="#utf8">utf8</a>() encoded string. The format
|
---|
| 1899 | string <em>cformat</em> is expected to be in latin1. If you need a
|
---|
| 1900 | Unicode format string, use <a href="#arg">arg</a>() instead. For typesafe string
|
---|
| 1901 | building, with full Unicode support, you can use <a href="qtextostream.html">QTextOStream</a> like
|
---|
| 1902 | this:
|
---|
| 1903 | <p> <pre>
|
---|
| 1904 | QString str;
|
---|
| 1905 | QString s = ...;
|
---|
| 1906 | int x = ...;
|
---|
| 1907 | QTextOStream( &str ) << s << " : " << x;
|
---|
| 1908 | </pre>
|
---|
| 1909 |
|
---|
| 1910 | <p> For <a href="qobject.html#tr">translations,</a> especially if the
|
---|
| 1911 | strings contains more than one escape sequence, you should
|
---|
| 1912 | consider using the arg() function instead. This allows the order
|
---|
| 1913 | of the replacements to be controlled by the translator, and has
|
---|
| 1914 | Unicode support.
|
---|
| 1915 | <p> The %lc escape sequence expects a unicode character of type ushort
|
---|
| 1916 | (as returned by <a href="qchar.html#unicode">QChar::unicode</a>()).
|
---|
| 1917 | The %ls escape sequence expects a pointer to a zero-terminated
|
---|
| 1918 | array of unicode characters of type ushort (as returned by
|
---|
| 1919 | <a href="#ucs2">QString::ucs2</a>()).
|
---|
| 1920 | <p> <p>See also <a href="#arg">arg</a>().
|
---|
| 1921 |
|
---|
| 1922 | <p>Examples: <a href="dclock-example.html#x1103">dclock/dclock.cpp</a>, <a href="forever-example.html#x1052">forever/forever.cpp</a>, <a href="layout-example.html#x542">layout/layout.cpp</a>, <a href="qmag-example.html#x1795">qmag/qmag.cpp</a>, <a href="scrollview-example.html#x656">scrollview/scrollview.cpp</a>, <a href="tooltip-example.html#x449">tooltip/tooltip.cpp</a>, and <a href="xform-example.html#x1265">xform/xform.cpp</a>.
|
---|
| 1923 | <h3 class=fn>void <a name="squeeze"></a>QString::squeeze ()
|
---|
| 1924 | </h3>
|
---|
| 1925 | Squeezes the string's capacity to the current content.
|
---|
| 1926 | <p> <p>See also <a href="#capacity">capacity</a>() and <a href="#reserve">reserve</a>().
|
---|
| 1927 |
|
---|
| 1928 | <h3 class=fn>bool <a name="startsWith"></a>QString::startsWith ( const <a href="qstring.html">QString</a> & s, bool cs = TRUE ) const
|
---|
| 1929 | </h3>
|
---|
| 1930 | Returns TRUE if the string starts with <em>s</em>; otherwise returns
|
---|
| 1931 | FALSE.
|
---|
| 1932 | <p> If <em>cs</em> is TRUE (the default), the search is case sensitive;
|
---|
| 1933 | otherwise the search is case insensitive.
|
---|
| 1934 | <p> <pre>
|
---|
| 1935 | QString str( "Bananas" );
|
---|
| 1936 | str.<a href="#startsWith">startsWith</a>( "Ban" ); // returns TRUE
|
---|
| 1937 | str.<a href="#startsWith">startsWith</a>( "Car" ); // returns FALSE
|
---|
| 1938 | </pre>
|
---|
| 1939 |
|
---|
| 1940 | <p> <p>See also <a href="#endsWith">endsWith</a>().
|
---|
| 1941 |
|
---|
| 1942 | <h3 class=fn><a href="qstring.html">QString</a> <a name="stripWhiteSpace"></a>QString::stripWhiteSpace () const
|
---|
| 1943 | </h3>
|
---|
| 1944 | Returns a string that has whitespace removed from the start and
|
---|
| 1945 | the end.
|
---|
| 1946 | <p> Whitespace means any character for which <a href="qchar.html#isSpace">QChar::isSpace</a>() returns
|
---|
| 1947 | TRUE. This includes Unicode characters with decimal values 9
|
---|
| 1948 | (TAB), 10 (LF), 11 (VT), 12 (FF), 13 (CR) and 32 (Space), and may
|
---|
| 1949 | also include other Unicode characters.
|
---|
| 1950 | <p> <pre>
|
---|
| 1951 | QString string = " white space ";
|
---|
| 1952 | QString s = string.<a href="#stripWhiteSpace">stripWhiteSpace</a>(); // s == "white space"
|
---|
| 1953 | </pre>
|
---|
| 1954 |
|
---|
| 1955 | <p> <p>See also <a href="#simplifyWhiteSpace">simplifyWhiteSpace</a>().
|
---|
| 1956 |
|
---|
| 1957 | <h3 class=fn>double <a name="toDouble"></a>QString::toDouble ( bool * ok = 0 ) const
|
---|
| 1958 | </h3>
|
---|
| 1959 | Returns the string converted to a <tt>double</tt> value.
|
---|
| 1960 | <p> If <em>ok</em> is not 0: if a conversion error occurs, <em>*ok</em> is set to
|
---|
| 1961 | FALSE; otherwise <em>*ok</em> is set to TRUE.
|
---|
| 1962 | <p> <pre>
|
---|
| 1963 | QString string( "1234.56" );
|
---|
| 1964 | double a = string.<a href="#toDouble">toDouble</a>(); // a == 1234.56
|
---|
| 1965 | </pre>
|
---|
| 1966 |
|
---|
| 1967 | <p> The string-to-number functions:
|
---|
| 1968 | <ul>
|
---|
| 1969 | <li> <a href="#toShort">toShort</a>()
|
---|
| 1970 | <li> <a href="#toUShort">toUShort</a>()
|
---|
| 1971 | <li> <a href="#toInt">toInt</a>()
|
---|
| 1972 | <li> <a href="#toUInt">toUInt</a>()
|
---|
| 1973 | <li> <a href="#toLong">toLong</a>()
|
---|
| 1974 | <li> <a href="#toULong">toULong</a>()
|
---|
| 1975 | <li> <a href="#toLongLong">toLongLong</a>()
|
---|
| 1976 | <li> <a href="#toULongLong">toULongLong</a>()
|
---|
| 1977 | <li> <a href="#toFloat">toFloat</a>()
|
---|
| 1978 | <li> <a href="#toDouble">toDouble</a>()
|
---|
| 1979 | </ul>
|
---|
| 1980 | can handle numbers
|
---|
| 1981 | represented in various locales. These representations may use different
|
---|
| 1982 | characters for the decimal point, thousands group sepearator
|
---|
| 1983 | and even individual digits. QString's functions try to interpret
|
---|
| 1984 | the string according to the current locale. The current locale is
|
---|
| 1985 | determined from the system at application startup and can be changed
|
---|
| 1986 | by calling <a href="qlocale.html#setDefault">QLocale::setDefault</a>(). If the string cannot be interpreted
|
---|
| 1987 | according to the current locale, this function falls back
|
---|
| 1988 | on the "C" locale.
|
---|
| 1989 | <p> <pre>
|
---|
| 1990 | bool ok;
|
---|
| 1991 | double d;
|
---|
| 1992 |
|
---|
| 1993 | QLocale::<a href="qlocale.html#setDefault">setDefault</a>(QLocale::C);
|
---|
| 1994 | d = <a href="#QString">QString</a>( "1234,56" ).toDouble(&ok); // ok == false
|
---|
| 1995 | d = <a href="#QString">QString</a>( "1234.56" ).toDouble(&ok); // ok == true, d == 1234.56
|
---|
| 1996 |
|
---|
| 1997 | QLocale::<a href="qlocale.html#setDefault">setDefault</a>(QLocale::German);
|
---|
| 1998 | d = <a href="#QString">QString</a>( "1234,56" ).toDouble(&ok); // ok == true, d == 1234.56
|
---|
| 1999 | d = <a href="#QString">QString</a>( "1234.56" ).toDouble(&ok); // ok == true, d == 1234.56
|
---|
| 2000 | </pre>
|
---|
| 2001 |
|
---|
| 2002 | <p> Due to the ambiguity between the decimal point and thousands group
|
---|
| 2003 | separator in various locales, these functions do not handle
|
---|
| 2004 | thousands group separators. If you need to convert such numbers,
|
---|
| 2005 | use the corresponding function in <a href="qlocale.html">QLocale</a>.
|
---|
| 2006 | <p> <pre>
|
---|
| 2007 | bool ok;
|
---|
| 2008 | QLocale::<a href="qlocale.html#setDefault">setDefault</a>(QLocale::C);
|
---|
| 2009 | double d = <a href="#QString">QString</a>( "1,234,567.89" ).toDouble(&ok); // ok == false
|
---|
| 2010 | </pre>
|
---|
| 2011 |
|
---|
| 2012 | <p> <b>Warning:</b> If the string contains trailing whitespace this function
|
---|
| 2013 | will fail, and set <em>*ok</em> to false if <em>ok</em> is not 0. Leading
|
---|
| 2014 | whitespace is ignored.
|
---|
| 2015 | <p> <p>See also <a href="#number">number</a>(), <a href="qlocale.html#setDefault">QLocale::setDefault</a>(), <a href="qlocale.html#toDouble">QLocale::toDouble</a>(), and <a href="#stripWhiteSpace">stripWhiteSpace</a>().
|
---|
| 2016 |
|
---|
| 2017 | <h3 class=fn>float <a name="toFloat"></a>QString::toFloat ( bool * ok = 0 ) const
|
---|
| 2018 | </h3>
|
---|
| 2019 | Returns the string converted to a <tt>float</tt> value.
|
---|
| 2020 | <p> Returns 0.0 if the conversion fails.
|
---|
| 2021 | <p> If <em>ok</em> is not 0: if a conversion error occurs, <em>*ok</em> is set to
|
---|
| 2022 | FALSE; otherwise <em>*ok</em> is set to TRUE.
|
---|
| 2023 | <p> For information on how string-to-number functions in QString handle
|
---|
| 2024 | localized input, see <a href="#toDouble">toDouble</a>().
|
---|
| 2025 | <p> <b>Warning:</b> If the string contains trailing whitespace this function
|
---|
| 2026 | will fail, settings <em>*ok</em> to false if <em>ok</em> is not 0.
|
---|
| 2027 | Leading whitespace is ignored.
|
---|
| 2028 | <p> <p>See also <a href="#number">number</a>().
|
---|
| 2029 |
|
---|
| 2030 | <h3 class=fn>int <a name="toInt"></a>QString::toInt ( bool * ok = 0, int base = 10 ) const
|
---|
| 2031 | </h3>
|
---|
| 2032 | Returns the string converted to an <tt>int</tt> using base <em>base</em>, which is 10 by default and must be between 2 and 36 or 0. If
|
---|
| 2033 | <em>base</em> is 0, the base is determined automatically using the
|
---|
| 2034 | following rules:
|
---|
| 2035 | <ul>
|
---|
| 2036 | <li>If the string begins with "0x", it is assumed to
|
---|
| 2037 | be hexadecimal;
|
---|
| 2038 | <li>If it begins with "0", it is assumed to be octal;
|
---|
| 2039 | <li>Otherwise it is assumed to be decimal.
|
---|
| 2040 | </ul>
|
---|
| 2041 | <p> Returns 0 if the conversion fails.
|
---|
| 2042 | <p> If <em>ok</em> is not 0: if a conversion error occurs, <em>*ok</em> is set to
|
---|
| 2043 | FALSE; otherwise <em>*ok</em> is set to TRUE.
|
---|
| 2044 | <p> <pre>
|
---|
| 2045 | QString str( "FF" );
|
---|
| 2046 | bool ok;
|
---|
| 2047 | int hex = str.<a href="#toInt">toInt</a>( &ok, 16 ); // hex == 255, ok == TRUE
|
---|
| 2048 | int dec = str.<a href="#toInt">toInt</a>( &ok, 10 ); // dec == 0, ok == FALSE
|
---|
| 2049 | </pre>
|
---|
| 2050 |
|
---|
| 2051 | <p> Leading and trailing whitespace is ignored by this function.
|
---|
| 2052 | <p> For information on how string-to-number functions in QString handle
|
---|
| 2053 | localized input, see <a href="#toDouble">toDouble</a>().
|
---|
| 2054 | <p> <p>See also <a href="#number">number</a>().
|
---|
| 2055 |
|
---|
| 2056 | <h3 class=fn>long <a name="toLong"></a>QString::toLong ( bool * ok = 0, int base = 10 ) const
|
---|
| 2057 | </h3>
|
---|
| 2058 | Returns the string converted to a <tt>long</tt> using base <em>base</em>, which is 10 by default and must be between 2 and 36 or 0. If
|
---|
| 2059 | <em>base</em> is 0, the base is determined automatically using the
|
---|
| 2060 | following rules:
|
---|
| 2061 | <ul>
|
---|
| 2062 | <li>If the string begins with "0x", it is assumed to
|
---|
| 2063 | be hexadecimal;
|
---|
| 2064 | <li>If it begins with "0", it is assumed to be octal;
|
---|
| 2065 | <li>Otherwise it is assumed to be decimal.
|
---|
| 2066 | </ul>
|
---|
| 2067 | <p> Returns 0 if the conversion fails.
|
---|
| 2068 | <p> If <em>ok</em> is not 0: if a conversion error occurs, <em>*ok</em> is set to
|
---|
| 2069 | FALSE; otherwise <em>*ok</em> is set to TRUE.
|
---|
| 2070 | <p> Leading and trailing whitespace is ignored by this function.
|
---|
| 2071 | <p> For information on how string-to-number functions in QString handle
|
---|
| 2072 | localized input, see <a href="#toDouble">toDouble</a>().
|
---|
| 2073 | <p> <p>See also <a href="#number">number</a>().
|
---|
| 2074 |
|
---|
| 2075 | <h3 class=fn>Q_LLONG <a name="toLongLong"></a>QString::toLongLong ( bool * ok = 0, int base = 10 ) const
|
---|
| 2076 | </h3>
|
---|
| 2077 | Returns the string converted to a <tt>long long</tt> using base <em>base</em>, which is 10 by default and must be between 2 and 36 or 0. If
|
---|
| 2078 | <em>base</em> is 0, the base is determined automatically using the
|
---|
| 2079 | following rules:
|
---|
| 2080 | <ul>
|
---|
| 2081 | <li>If the string begins with "0x", it is assumed to
|
---|
| 2082 | be hexadecimal;
|
---|
| 2083 | <li>If it begins with "0", it is assumed to be octal;
|
---|
| 2084 | <li>Otherwise it is assumed to be decimal.
|
---|
| 2085 | </ul>
|
---|
| 2086 | <p> Returns 0 if the conversion fails.
|
---|
| 2087 | <p> If <em>ok</em> is not 0: if a conversion error occurs, <em>*ok</em> is set to
|
---|
| 2088 | FALSE; otherwise <em>*ok</em> is set to TRUE.
|
---|
| 2089 | <p> Leading and trailing whitespace is ignored by this function.
|
---|
| 2090 | <p> For information on how string-to-number functions in QString handle
|
---|
| 2091 | localized input, see <a href="#toDouble">toDouble</a>().
|
---|
| 2092 | <p> <p>See also <a href="#number">number</a>().
|
---|
| 2093 |
|
---|
| 2094 | <h3 class=fn>short <a name="toShort"></a>QString::toShort ( bool * ok = 0, int base = 10 ) const
|
---|
| 2095 | </h3>
|
---|
| 2096 | Returns the string converted to a <tt>short</tt> using base <em>base</em>, which is 10 by default and must be between 2 and 36 or 0. If
|
---|
| 2097 | <em>base</em> is 0, the base is determined automatically using the
|
---|
| 2098 | following rules:
|
---|
| 2099 | <ul>
|
---|
| 2100 | <li>If the string begins with "0x", it is assumed to
|
---|
| 2101 | be hexadecimal;
|
---|
| 2102 | <li>If it begins with "0", it is assumed to be octal;
|
---|
| 2103 | <li>Otherwise it is assumed to be decimal.
|
---|
| 2104 | </ul>
|
---|
| 2105 | <p> Returns 0 if the conversion fails.
|
---|
| 2106 | <p> If <em>ok</em> is not 0: if a conversion error occurs, <em>*ok</em> is set to
|
---|
| 2107 | FALSE; otherwise <em>*ok</em> is set to TRUE.
|
---|
| 2108 | <p> Leading and trailing whitespace is ignored by this function.
|
---|
| 2109 | <p> For information on how string-to-number functions in QString handle
|
---|
| 2110 | localized input, see <a href="#toDouble">toDouble</a>().
|
---|
| 2111 | <p> <p>See also <a href="#number">number</a>().
|
---|
| 2112 |
|
---|
| 2113 | <h3 class=fn>uint <a name="toUInt"></a>QString::toUInt ( bool * ok = 0, int base = 10 ) const
|
---|
| 2114 | </h3>
|
---|
| 2115 | Returns the string converted to an <tt>unsigned int</tt> using base <em>base</em>, which is 10 by default and must be between 2 and 36 or 0. If
|
---|
| 2116 | <em>base</em> is 0, the base is determined automatically using the
|
---|
| 2117 | following rules:
|
---|
| 2118 | <ul>
|
---|
| 2119 | <li>If the string begins with "0x", it is assumed to
|
---|
| 2120 | be hexadecimal;
|
---|
| 2121 | <li>If it begins with "0", it is assumed to be octal;
|
---|
| 2122 | <li>Otherwise it is assumed to be decimal.
|
---|
| 2123 | </ul>
|
---|
| 2124 | <p> Returns 0 if the conversion fails.
|
---|
| 2125 | <p> If <em>ok</em> is not 0: if a conversion error occurs, <em>*ok</em> is set to
|
---|
| 2126 | FALSE; otherwise <em>*ok</em> is set to TRUE.
|
---|
| 2127 | <p> Leading and trailing whitespace is ignored by this function.
|
---|
| 2128 | <p> For information on how string-to-number functions in QString handle
|
---|
| 2129 | localized input, see <a href="#toDouble">toDouble</a>().
|
---|
| 2130 | <p> <p>See also <a href="#number">number</a>().
|
---|
| 2131 |
|
---|
| 2132 | <h3 class=fn>ulong <a name="toULong"></a>QString::toULong ( bool * ok = 0, int base = 10 ) const
|
---|
| 2133 | </h3>
|
---|
| 2134 | Returns the string converted to an <tt>unsigned long</tt> using base <em>base</em>, which is 10 by default and must be between 2 and 36 or 0. If
|
---|
| 2135 | <em>base</em> is 0, the base is determined automatically using the
|
---|
| 2136 | following rules:
|
---|
| 2137 | <ul>
|
---|
| 2138 | <li>If the string begins with "0x", it is assumed to
|
---|
| 2139 | be hexadecimal;
|
---|
| 2140 | <li>If it begins with "0", it is assumed to be octal;
|
---|
| 2141 | <li>Otherwise it is assumed to be decimal.
|
---|
| 2142 | </ul>
|
---|
| 2143 | <p> Returns 0 if the conversion fails.
|
---|
| 2144 | <p> If <em>ok</em> is not 0: if a conversion error occurs, <em>*ok</em> is set to
|
---|
| 2145 | FALSE; otherwise <em>*ok</em> is set to TRUE.
|
---|
| 2146 | <p> Leading and trailing whitespace is ignored by this function.
|
---|
| 2147 | <p> For information on how string-to-number functions in QString handle
|
---|
| 2148 | localized input, see <a href="#toDouble">toDouble</a>().
|
---|
| 2149 | <p> <p>See also <a href="#number">number</a>().
|
---|
| 2150 |
|
---|
| 2151 | <h3 class=fn>Q_ULLONG <a name="toULongLong"></a>QString::toULongLong ( bool * ok = 0, int base = 10 ) const
|
---|
| 2152 | </h3>
|
---|
| 2153 | Returns the string converted to an <tt>unsigned long long</tt> using base <em>base</em>, which is 10 by default and must be between 2 and 36 or 0. If
|
---|
| 2154 | <em>base</em> is 0, the base is determined automatically using the
|
---|
| 2155 | following rules:
|
---|
| 2156 | <ul>
|
---|
| 2157 | <li>If the string begins with "0x", it is assumed to
|
---|
| 2158 | be hexadecimal;
|
---|
| 2159 | <li>If it begins with "0", it is assumed to be octal;
|
---|
| 2160 | <li>Otherwise it is assumed to be decimal.
|
---|
| 2161 | </ul>
|
---|
| 2162 | <p> Returns 0 if the conversion fails.
|
---|
| 2163 | <p> If <em>ok</em> is not 0: if a conversion error occurs, <em>*ok</em> is set to
|
---|
| 2164 | FALSE; otherwise <em>*ok</em> is set to TRUE.
|
---|
| 2165 | <p> Leading and trailing whitespace is ignored by this function.
|
---|
| 2166 | <p> For information on how string-to-number functions in QString handle
|
---|
| 2167 | localized input, see <a href="#toDouble">toDouble</a>().
|
---|
| 2168 | <p> <p>See also <a href="#number">number</a>().
|
---|
| 2169 |
|
---|
| 2170 | <h3 class=fn>ushort <a name="toUShort"></a>QString::toUShort ( bool * ok = 0, int base = 10 ) const
|
---|
| 2171 | </h3>
|
---|
| 2172 | Returns the string converted to an <tt>unsigned short</tt> using base <em>base</em>, which is 10 by default and must be between 2 and 36 or 0. If
|
---|
| 2173 | <em>base</em> is 0, the base is determined automatically using the
|
---|
| 2174 | following rules:
|
---|
| 2175 | <ul>
|
---|
| 2176 | <li>If the string begins with "0x", it is assumed to
|
---|
| 2177 | be hexadecimal;
|
---|
| 2178 | <li>If it begins with "0", it is assumed to be octal;
|
---|
| 2179 | <li>Otherwise it is assumed to be decimal.
|
---|
| 2180 | </ul>
|
---|
| 2181 | <p> Returns 0 if the conversion fails.
|
---|
| 2182 | <p> If <em>ok</em> is not 0: if a conversion error occurs, <em>*ok</em> is set to
|
---|
| 2183 | FALSE; otherwise <em>*ok</em> is set to TRUE.
|
---|
| 2184 | <p> Leading and trailing whitespace is ignored by this function.
|
---|
| 2185 | <p> For information on how string-to-number functions in QString handle
|
---|
| 2186 | localized input, see <a href="#toDouble">toDouble</a>().
|
---|
| 2187 | <p> <p>See also <a href="#number">number</a>().
|
---|
| 2188 |
|
---|
| 2189 | <h3 class=fn>void <a name="truncate"></a>QString::truncate ( uint newLen )
|
---|
| 2190 | </h3>
|
---|
| 2191 | If <em>newLen</em> is less than the length of the string, then the
|
---|
| 2192 | string is truncated at position <em>newLen</em>. Otherwise nothing
|
---|
| 2193 | happens.
|
---|
| 2194 | <p> <pre>
|
---|
| 2195 | QString s = "truncate me";
|
---|
| 2196 | s.<a href="#truncate">truncate</a>( 5 ); // s == "trunc"
|
---|
| 2197 | </pre>
|
---|
| 2198 |
|
---|
| 2199 | <p> <p>See also <a href="#setLength">setLength</a>().
|
---|
| 2200 |
|
---|
| 2201 | <p>Example: <a href="mail-example.html#x718">network/mail/smtp.cpp</a>.
|
---|
| 2202 | <h3 class=fn>const unsigned short * <a name="ucs2"></a>QString::ucs2 () const
|
---|
| 2203 | </h3>
|
---|
| 2204 | Returns the QString as a zero terminated array of unsigned shorts
|
---|
| 2205 | if the string is not null; otherwise returns zero.
|
---|
| 2206 | <p> The result remains valid so long as one unmodified
|
---|
| 2207 | copy of the source string exists.
|
---|
| 2208 |
|
---|
| 2209 | <p>Example: <a href="activeqt-dotnet.html#x2467">dotnet/wrapper/lib/tools.cpp</a>.
|
---|
| 2210 | <h3 class=fn>const <a href="qchar.html">QChar</a> * <a name="unicode"></a>QString::unicode () const
|
---|
| 2211 | </h3>
|
---|
| 2212 |
|
---|
| 2213 | <p> Returns the Unicode representation of the string. The result
|
---|
| 2214 | remains valid until the string is modified.
|
---|
| 2215 |
|
---|
| 2216 | <h3 class=fn><a href="qstring.html">QString</a> <a name="upper"></a>QString::upper () const
|
---|
| 2217 | </h3>
|
---|
| 2218 | Returns an uppercase copy of the string.
|
---|
| 2219 | <p> <pre>
|
---|
| 2220 | QString string( "TeXt" );
|
---|
| 2221 | str = string.<a href="#upper">upper</a>(); // t == "TEXT"
|
---|
| 2222 | </pre>
|
---|
| 2223 |
|
---|
| 2224 | <p> <p>See also <a href="#lower">lower</a>().
|
---|
| 2225 |
|
---|
| 2226 | <p>Examples: <a href="scribble-example.html#x942">scribble/scribble.cpp</a> and <a href="sql.html#x2240">sql/overview/custom1/main.cpp</a>.
|
---|
| 2227 | <h3 class=fn><a href="qcstring.html">QCString</a> <a name="utf8"></a>QString::utf8 () const
|
---|
| 2228 | </h3>
|
---|
| 2229 | Returns the string encoded in UTF-8 format.
|
---|
| 2230 | <p> See <a href="qtextcodec.html">QTextCodec</a> for more diverse coding/decoding of Unicode strings.
|
---|
| 2231 | <p> <p>See also <a href="#fromUtf8">fromUtf8</a>(), <a href="#ascii">ascii</a>(), <a href="#latin1">latin1</a>(), and <a href="#local8Bit">local8Bit</a>().
|
---|
| 2232 |
|
---|
| 2233 | <p>Example: <a href="archivesearch-example.html#x483">network/archivesearch/archivedialog.ui.h</a>.
|
---|
| 2234 | <hr><h2>Related Functions</h2>
|
---|
| 2235 | <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 )
|
---|
| 2236 | </h3>
|
---|
| 2237 |
|
---|
| 2238 | <p>
|
---|
| 2239 | <p> Returns TRUE if <em>s1</em> is not equal to <em>s2</em>; otherwise returns FALSE.
|
---|
| 2240 | Note that a null string is not equal to a not-null empty string.
|
---|
| 2241 | <p> Equivalent to <a href="#compare">compare</a>(<em>s1</em>, <em>s2</em>) != 0.
|
---|
| 2242 | <p> <p>See also <a href="#isNull">isNull</a>() and <a href="#isEmpty">isEmpty</a>().
|
---|
| 2243 |
|
---|
| 2244 | <h3 class=fn>bool <a name="operator!-eq-2"></a>operator!= ( const <a href="qstring.html">QString</a> & s1, const char * s2 )
|
---|
| 2245 | </h3>
|
---|
| 2246 |
|
---|
| 2247 | <p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 2248 | <p>
|
---|
| 2249 | <p> Returns TRUE if <em>s1</em> is not equal to <em>s2</em>; otherwise returns FALSE.
|
---|
| 2250 | Note that a null string is not equal to a not-null empty string.
|
---|
| 2251 | <p> Equivalent to <a href="#compare">compare</a>(<em>s1</em>, <em>s2</em>) != 0.
|
---|
| 2252 | <p> <p>See also <a href="#isNull">isNull</a>() and <a href="#isEmpty">isEmpty</a>().
|
---|
| 2253 |
|
---|
| 2254 | <h3 class=fn>bool <a name="operator!-eq-3"></a>operator!= ( const char * s1, const <a href="qstring.html">QString</a> & s2 )
|
---|
| 2255 | </h3>
|
---|
| 2256 |
|
---|
| 2257 | <p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 2258 | <p>
|
---|
| 2259 | <p> Returns TRUE if <em>s1</em> is not equal to <em>s2</em>; otherwise returns FALSE.
|
---|
| 2260 | Note that a null string is not equal to a not-null empty string.
|
---|
| 2261 | <p> Equivalent to <a href="#compare">compare</a>(<em>s1</em>, <em>s2</em>) != 0.
|
---|
| 2262 | <p> <p>See also <a href="#isNull">isNull</a>() and <a href="#isEmpty">isEmpty</a>().
|
---|
| 2263 |
|
---|
| 2264 | <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 )
|
---|
| 2265 | </h3>
|
---|
| 2266 |
|
---|
| 2267 | <p>
|
---|
| 2268 | <p> Returns a string which is the result of concatenating the string
|
---|
| 2269 | <em>s1</em> and the string <em>s2</em>.
|
---|
| 2270 | <p> Equivalent to <em>s1</em>.<a href="#append">append</a>(<em>s2</em>).
|
---|
| 2271 |
|
---|
| 2272 | <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 )
|
---|
| 2273 | </h3>
|
---|
| 2274 |
|
---|
| 2275 | <p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 2276 | <p>
|
---|
| 2277 | <p> Returns a string which is the result of concatenating the string
|
---|
| 2278 | <em>s1</em> and character <em>s2</em>.
|
---|
| 2279 | <p> Equivalent to <em>s1</em>.<a href="#append">append</a>(<em>s2</em>).
|
---|
| 2280 |
|
---|
| 2281 | <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 )
|
---|
| 2282 | </h3>
|
---|
| 2283 |
|
---|
| 2284 | <p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 2285 | <p>
|
---|
| 2286 | <p> Returns a string which is the result of concatenating the
|
---|
| 2287 | character <em>s1</em> and string <em>s2</em>.
|
---|
| 2288 |
|
---|
| 2289 | <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 )
|
---|
| 2290 | </h3>
|
---|
| 2291 |
|
---|
| 2292 | <p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 2293 | <p>
|
---|
| 2294 | <p> Returns a string which is the result of concatenating the string
|
---|
| 2295 | <em>s</em> and character <em>c</em>.
|
---|
| 2296 | <p> Equivalent to <em>s</em>.<a href="#append">append</a>(<em>c</em>).
|
---|
| 2297 |
|
---|
| 2298 | <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 )
|
---|
| 2299 | </h3>
|
---|
| 2300 |
|
---|
| 2301 | <p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 2302 | <p>
|
---|
| 2303 | <p> Returns a string which is the result of concatenating the
|
---|
| 2304 | character <em>c</em> and string <em>s</em>.
|
---|
| 2305 | <p> Equivalent to <em>s</em>.<a href="#prepend">prepend</a>(<em>c</em>).
|
---|
| 2306 |
|
---|
| 2307 | <h3 class=fn>bool <a name="operator-lt"></a>operator< ( const <a href="qstring.html">QString</a> & s1, const char * s2 )
|
---|
| 2308 | </h3>
|
---|
| 2309 |
|
---|
| 2310 | <p>
|
---|
| 2311 | <p> Returns TRUE if <em>s1</em> is lexically less than <em>s2</em>; otherwise returns FALSE.
|
---|
| 2312 | The comparison is case sensitive.
|
---|
| 2313 | <p> Equivalent to <a href="#compare">compare</a>(<em>s1</em>, <em>s2</em>) < 0.
|
---|
| 2314 |
|
---|
| 2315 | <h3 class=fn>bool <a name="operator-lt-2"></a>operator< ( const char * s1, const <a href="qstring.html">QString</a> & s2 )
|
---|
| 2316 | </h3>
|
---|
| 2317 |
|
---|
| 2318 | <p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 2319 | <p>
|
---|
| 2320 | <p> Returns TRUE if <em>s1</em> is lexically less than <em>s2</em>; otherwise returns FALSE.
|
---|
| 2321 | The comparison is case sensitive.
|
---|
| 2322 | <p> Equivalent to <a href="#compare">compare</a>(<em>s1</em>, <em>s2</em>) < 0.
|
---|
| 2323 |
|
---|
| 2324 | <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 )
|
---|
| 2325 | </h3>
|
---|
| 2326 |
|
---|
| 2327 | <p> Writes the string <em>str</em> to the stream <em>s</em>.
|
---|
| 2328 | <p> See also <a href="datastreamformat.html">Format of the QDataStream operators</a>
|
---|
| 2329 |
|
---|
| 2330 | <h3 class=fn>bool <a name="operator-lt-eq"></a>operator<= ( const <a href="qstring.html">QString</a> & s1, const char * s2 )
|
---|
| 2331 | </h3>
|
---|
| 2332 |
|
---|
| 2333 | <p>
|
---|
| 2334 | <p> Returns TRUE if <em>s1</em> is lexically less than or equal to <em>s2</em>;
|
---|
| 2335 | otherwise returns FALSE.
|
---|
| 2336 | The comparison is case sensitive.
|
---|
| 2337 | Note that a null string is not equal to a not-null empty string.
|
---|
| 2338 | <p> Equivalent to <a href="#compare">compare</a>(<em>s1</em>,<em>s2</em>) <= 0.
|
---|
| 2339 | <p> <p>See also <a href="#isNull">isNull</a>() and <a href="#isEmpty">isEmpty</a>().
|
---|
| 2340 |
|
---|
| 2341 | <h3 class=fn>bool <a name="operator-lt-eq-2"></a>operator<= ( const char * s1, const <a href="qstring.html">QString</a> & s2 )
|
---|
| 2342 | </h3>
|
---|
| 2343 |
|
---|
| 2344 | <p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 2345 | <p>
|
---|
| 2346 | <p> Returns TRUE if <em>s1</em> is lexically less than or equal to <em>s2</em>;
|
---|
| 2347 | otherwise returns FALSE.
|
---|
| 2348 | The comparison is case sensitive.
|
---|
| 2349 | Note that a null string is not equal to a not-null empty string.
|
---|
| 2350 | <p> Equivalent to <a href="#compare">compare</a>(<em>s1</em>, <em>s2</em>) <= 0.
|
---|
| 2351 | <p> <p>See also <a href="#isNull">isNull</a>() and <a href="#isEmpty">isEmpty</a>().
|
---|
| 2352 |
|
---|
| 2353 | <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 )
|
---|
| 2354 | </h3>
|
---|
| 2355 |
|
---|
| 2356 | <p>
|
---|
| 2357 | <p> Returns TRUE if <em>s1</em> is equal to <em>s2</em>; otherwise returns FALSE.
|
---|
| 2358 | Note that a null string is not equal to a not-null empty string.
|
---|
| 2359 | <p> Equivalent to <a href="#compare">compare</a>(<em>s1</em>, <em>s2</em>) == 0.
|
---|
| 2360 | <p> <p>See also <a href="#isNull">isNull</a>() and <a href="#isEmpty">isEmpty</a>().
|
---|
| 2361 |
|
---|
| 2362 | <h3 class=fn>bool <a name="operator-eq-eq-2"></a>operator== ( const <a href="qstring.html">QString</a> & s1, const char * s2 )
|
---|
| 2363 | </h3>
|
---|
| 2364 |
|
---|
| 2365 | <p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 2366 | <p>
|
---|
| 2367 | <p> Returns TRUE if <em>s1</em> is equal to <em>s2</em>; otherwise returns FALSE.
|
---|
| 2368 | Note that a null string is not equal to a not-null empty string.
|
---|
| 2369 | <p> Equivalent to <a href="#compare">compare</a>(<em>s1</em>, <em>s2</em>) == 0.
|
---|
| 2370 | <p> <p>See also <a href="#isNull">isNull</a>() and <a href="#isEmpty">isEmpty</a>().
|
---|
| 2371 |
|
---|
| 2372 | <h3 class=fn>bool <a name="operator-eq-eq-3"></a>operator== ( const char * s1, const <a href="qstring.html">QString</a> & s2 )
|
---|
| 2373 | </h3>
|
---|
| 2374 |
|
---|
| 2375 | <p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 2376 | <p>
|
---|
| 2377 | <p> Returns TRUE if <em>s1</em> is equal to <em>s2</em>; otherwise returns FALSE.
|
---|
| 2378 | Note that a null string is not equal to a not-null empty string.
|
---|
| 2379 | <p> Equivalent to <a href="#compare">compare</a>(<em>s1</em>, <em>s2</em>) == 0.
|
---|
| 2380 | <p> <p>See also <a href="#isNull">isNull</a>() and <a href="#isEmpty">isEmpty</a>().
|
---|
| 2381 |
|
---|
| 2382 | <h3 class=fn>bool <a name="operator-gt"></a>operator> ( const <a href="qstring.html">QString</a> & s1, const char * s2 )
|
---|
| 2383 | </h3>
|
---|
| 2384 |
|
---|
| 2385 | <p>
|
---|
| 2386 | <p> Returns TRUE if <em>s1</em> is lexically greater than <em>s2</em>; otherwise
|
---|
| 2387 | returns FALSE.
|
---|
| 2388 | The comparison is case sensitive.
|
---|
| 2389 | <p> Equivalent to <a href="#compare">compare</a>(<em>s1</em>, <em>s2</em>) > 0.
|
---|
| 2390 |
|
---|
| 2391 | <h3 class=fn>bool <a name="operator-gt-2"></a>operator> ( const char * s1, const <a href="qstring.html">QString</a> & s2 )
|
---|
| 2392 | </h3>
|
---|
| 2393 |
|
---|
| 2394 | <p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 2395 | <p>
|
---|
| 2396 | <p> Returns TRUE if <em>s1</em> is lexically greater than <em>s2</em>; otherwise
|
---|
| 2397 | returns FALSE.
|
---|
| 2398 | The comparison is case sensitive.
|
---|
| 2399 | <p> Equivalent to <a href="#compare">compare</a>(<em>s1</em>, <em>s2</em>) > 0.
|
---|
| 2400 |
|
---|
| 2401 | <h3 class=fn>bool <a name="operator-gt-eq"></a>operator>= ( const <a href="qstring.html">QString</a> & s1, const char * s2 )
|
---|
| 2402 | </h3>
|
---|
| 2403 |
|
---|
| 2404 | <p>
|
---|
| 2405 | <p> Returns TRUE if <em>s1</em> is lexically greater than or equal to <em>s2</em>;
|
---|
| 2406 | otherwise returns FALSE.
|
---|
| 2407 | The comparison is case sensitive.
|
---|
| 2408 | Note that a null string is not equal to a not-null empty string.
|
---|
| 2409 | <p> Equivalent to <a href="#compare">compare</a>(<em>s1</em>, <em>s2</em>) >= 0.
|
---|
| 2410 | <p> <p>See also <a href="#isNull">isNull</a>() and <a href="#isEmpty">isEmpty</a>().
|
---|
| 2411 |
|
---|
| 2412 | <h3 class=fn>bool <a name="operator-gt-eq-2"></a>operator>= ( const char * s1, const <a href="qstring.html">QString</a> & s2 )
|
---|
| 2413 | </h3>
|
---|
| 2414 |
|
---|
| 2415 | <p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 2416 | <p>
|
---|
| 2417 | <p> Returns TRUE if <em>s1</em> is lexically greater than or equal to <em>s2</em>;
|
---|
| 2418 | otherwise returns FALSE.
|
---|
| 2419 | The comparison is case sensitive.
|
---|
| 2420 | Note that a null string is not equal to a not-null empty string.
|
---|
| 2421 | <p> Equivalent to <a href="#compare">compare</a>(<em>s1</em>, <em>s2</em>) >= 0.
|
---|
| 2422 | <p> <p>See also <a href="#isNull">isNull</a>() and <a href="#isEmpty">isEmpty</a>().
|
---|
| 2423 |
|
---|
| 2424 | <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 )
|
---|
| 2425 | </h3>
|
---|
| 2426 |
|
---|
| 2427 | <p> Reads a string from the stream <em>s</em> into string <em>str</em>.
|
---|
| 2428 | <p> See also <a href="datastreamformat.html">Format of the QDataStream operators</a>
|
---|
| 2429 |
|
---|
| 2430 | <!-- eof -->
|
---|
| 2431 | <hr><p>
|
---|
| 2432 | This file is part of the <a href="index.html">Qt toolkit</a>.
|
---|
| 2433 | Copyright © 1995-2007
|
---|
| 2434 | <a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
|
---|
| 2435 | <table width=100% cellspacing=0 border=0><tr>
|
---|
| 2436 | <td>Copyright © 2007
|
---|
| 2437 | <a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
|
---|
| 2438 | <td align=right><div align=right>Qt 3.3.8</div>
|
---|
| 2439 | </table></div></address></body>
|
---|
| 2440 | </html>
|
---|