1QString(3qt)                                                      QString(3qt)
2
3
4

NAME

6       QString - Abstraction of Unicode text and the classic C
7       '\0'-terminated char array
8

SYNOPSIS

10       All the functions in this class are reentrant when Qt is built with
11       thread support.</p>
12
13       #include <qstring.h>
14
15   Public Members
16       QString ()
17       QString ( QChar ch )
18       QString ( const QString & s )
19       QString ( const QByteArray & ba )
20       QString ( const QChar * unicode, uint length )
21       QString ( const char * str )
22       QString ( const std::string & str )
23       ~QString ()
24       QString & operator= ( const QString & s )
25       QString & operator= ( const char * str )
26       QString & operator= ( const std::string & s )
27       QString & operator= ( const QCString & cstr )
28       QString & operator= ( QChar c )
29       QString & operator= ( char c )
30       bool isNull () const
31       bool isEmpty () const
32       uint length () const
33       void truncate ( uint newLen )
34       QString & fill ( QChar c, int len = -1 )
35       QString copy () const  (obsolete)
36       QString arg ( long a, int fieldWidth = 0, int base = 10 ) const
37       QString arg ( ulong a, int fieldWidth = 0, int base = 10 ) const
38       QString arg ( Q_LLONG a, int fieldWidth = 0, int base = 10 ) const
39       QString arg ( Q_ULLONG a, int fieldWidth = 0, int base = 10 ) const
40       QString arg ( int a, int fieldWidth = 0, int base = 10 ) const
41       QString arg ( uint a, int fieldWidth = 0, int base = 10 ) const
42       QString arg ( short a, int fieldWidth = 0, int base = 10 ) const
43       QString arg ( ushort a, int fieldWidth = 0, int base = 10 ) const
44       QString arg ( double a, int fieldWidth = 0, char fmt = 'g', int prec =
45           -1 ) const
46       QString arg ( char a, int fieldWidth = 0 ) const
47       QString arg ( QChar a, int fieldWidth = 0 ) const
48       QString arg ( const QString & a, int fieldWidth = 0 ) const
49       QString arg ( const QString & a1, const QString & a2 ) const
50       QString arg ( const QString & a1, const QString & a2, const QString &
51           a3 ) const
52       QString arg ( const QString & a1, const QString & a2, const QString &
53           a3, const QString & a4 ) const
54       QString & sprintf ( const char * cformat, ... )
55       int find ( QChar c, int index = 0, bool cs = TRUE ) const
56       int find ( char c, int index = 0, bool cs = TRUE ) const
57       int find ( const QString & str, int index = 0, bool cs = TRUE ) const
58       int find ( const QRegExp & rx, int index = 0 ) const
59       int find ( const char * str, int index = 0 ) const
60       int findRev ( QChar c, int index = -1, bool cs = TRUE ) const
61       int findRev ( char c, int index = -1, bool cs = TRUE ) const
62       int findRev ( const QString & str, int index = -1, bool cs = TRUE )
63           const
64       int findRev ( const QRegExp & rx, int index = -1 ) const
65       int findRev ( const char * str, int index = -1 ) const
66       int contains ( QChar c, bool cs = TRUE ) const
67       int contains ( char c, bool cs = TRUE ) const
68       int contains ( const char * str, bool cs = TRUE ) const
69       int contains ( const QString & str, bool cs = TRUE ) const
70       int contains ( const QRegExp & rx ) const
71       enum SectionFlags { SectionDefault = 0x00, SectionSkipEmpty = 0x01,
72           SectionIncludeLeadingSep = 0x02, SectionIncludeTrailingSep = 0x04,
73           SectionCaseInsensitiveSeps = 0x08 }
74       QString section ( QChar sep, int start, int end = 0xffffffff, int flags
75           = SectionDefault ) const
76       QString section ( char sep, int start, int end = 0xffffffff, int flags
77           = SectionDefault ) const
78       QString section ( const char * sep, int start, int end = 0xffffffff,
79           int flags = SectionDefault ) const
80       QString section ( const QString & sep, int start, int end = 0xffffffff,
81           int flags = SectionDefault ) const
82       QString section ( const QRegExp & reg, int start, int end = 0xffffffff,
83           int flags = SectionDefault ) const
84       QString left ( uint len ) const
85       QString right ( uint len ) const
86       QString mid ( uint index, uint len = 0xffffffff ) const
87       QString leftJustify ( uint width, QChar fill = ' ', bool truncate =
88           FALSE ) const
89       QString rightJustify ( uint width, QChar fill = ' ', bool truncate =
90           FALSE ) const
91       QString lower () const
92       QString upper () const
93       QString stripWhiteSpace () const
94       QString simplifyWhiteSpace () const
95       QString & insert ( uint index, const QString & s )
96       QString & insert ( uint index, const QByteArray & s )
97       QString & insert ( uint index, const char * s )
98       QString & insert ( uint index, const QChar * s, uint len )
99       QString & insert ( uint index, QChar c )
100       QString & insert ( uint index, char c )
101       QString & append ( char ch )
102       QString & append ( QChar ch )
103       QString & append ( const QString & str )
104       QString & append ( const QByteArray & str )
105       QString & append ( const char * str )
106       QString & append ( const std::string & str )
107       QString & prepend ( char ch )
108       QString & prepend ( QChar ch )
109       QString & prepend ( const QString & s )
110       QString & prepend ( const QByteArray & s )
111       QString & prepend ( const char * s )
112       QString & prepend ( const std::string & s )
113       QString & remove ( uint index, uint len )
114       QString & remove ( const QString & str, bool cs = TRUE )
115       QString & remove ( QChar c )
116       QString & remove ( char c )
117       QString & remove ( const char * str )
118       QString & remove ( const QRegExp & rx )
119       QString & replace ( uint index, uint len, const QString & s )
120       QString & replace ( uint index, uint len, const QChar * s, uint slen )
121       QString & replace ( uint index, uint len, QChar c )
122       QString & replace ( uint index, uint len, char c )
123       QString & replace ( QChar c, const QString & after, bool cs = TRUE )
124       QString & replace ( char c, const QString & after, bool cs = TRUE )
125       QString & replace ( const QString & before, const QString & after, bool
126           cs = TRUE )
127       QString & replace ( const QRegExp & rx, const QString & after )
128       QString & replace ( QChar c1, QChar c2 )
129       short toShort ( bool * ok = 0, int base = 10 ) const
130       ushort toUShort ( bool * ok = 0, int base = 10 ) const
131       int toInt ( bool * ok = 0, int base = 10 ) const
132       uint toUInt ( bool * ok = 0, int base = 10 ) const
133       long toLong ( bool * ok = 0, int base = 10 ) const
134       ulong toULong ( bool * ok = 0, int base = 10 ) const
135       Q_LLONG toLongLong ( bool * ok = 0, int base = 10 ) const
136       Q_ULLONG toULongLong ( bool * ok = 0, int base = 10 ) const
137       float toFloat ( bool * ok = 0 ) const
138       double toDouble ( bool * ok = 0 ) const
139       QString & setNum ( short n, int base = 10 )
140       QString & setNum ( ushort n, int base = 10 )
141       QString & setNum ( int n, int base = 10 )
142       QString & setNum ( uint n, int base = 10 )
143       QString & setNum ( long n, int base = 10 )
144       QString & setNum ( ulong n, int base = 10 )
145       QString & setNum ( Q_LLONG n, int base = 10 )
146       QString & setNum ( Q_ULLONG n, int base = 10 )
147       QString & setNum ( float n, char f = 'g', int prec = 6 )
148       QString & setNum ( double n, char f = 'g', int prec = 6 )
149       void setExpand ( uint index, QChar c )  (obsolete)
150       QString & operator+= ( const QString & str )
151       QString & operator+= ( const QByteArray & str )
152       QString & operator+= ( const char * str )
153       QString & operator+= ( const std::string & str )
154       QString & operator+= ( QChar c )
155       QString & operator+= ( char c )
156       QChar at ( uint i ) const
157       QChar operator[] ( int i ) const
158       QCharRef at ( uint i )
159       QCharRef operator[] ( int i )
160       QChar constref ( uint i ) const
161       QChar & ref ( uint i )
162       const QChar * unicode () const
163       const char * ascii () const
164       const char * latin1 () const
165       QCString utf8 () const
166       QCString local8Bit () const
167       bool operator! () const
168       operator const char * () const
169       operator std::string () const
170       const unsigned short * ucs2 () const
171       QString & setUnicode ( const QChar * unicode, uint len )
172       QString & setUnicodeCodes ( const ushort * unicode_as_ushorts, uint len
173           )
174       QString & setAscii ( const char * str, int len = -1 )
175       QString & setLatin1 ( const char * str, int len = -1 )
176       int compare ( const QString & s ) const
177       int localeAwareCompare ( const QString & s ) const
178       void compose ()
179       const char * data () const  (obsolete)
180       bool startsWith ( const QString & s, bool cs = TRUE ) const
181       bool endsWith ( const QString & s, bool cs = TRUE ) const
182       void setLength ( uint newLen )
183       uint capacity () const
184       void reserve ( uint minCapacity )
185       void squeeze ()
186
187   Static Public Members
188       QString number ( long n, int base = 10 )
189       QString number ( ulong n, int base = 10 )
190       QString number ( Q_LLONG n, int base = 10 )
191       QString number ( Q_ULLONG n, int base = 10 )
192       QString number ( int n, int base = 10 )
193       QString number ( uint n, int base = 10 )
194       QString number ( double n, char f = 'g', int prec = 6 )
195       QString fromAscii ( const char * ascii, int len = -1 )
196       QString fromLatin1 ( const char * chars, int len = -1 )
197       QString fromUtf8 ( const char * utf8, int len = -1 )
198       QString fromLocal8Bit ( const char * local8Bit, int len = -1 )
199       QString fromUcs2 ( const unsigned short * str )
200       int compare ( const QString & s1, const QString & s2 )
201       int localeAwareCompare ( const QString & s1, const QString & s2 )
202
204       bool operator== ( const QString & s1, const QString & s2 )
205       bool operator== ( const QString & s1, const char * s2 )
206       bool operator== ( const char * s1, const QString & s2 )
207       bool operator!= ( const QString & s1, const QString & s2 )
208       bool operator!= ( const QString & s1, const char * s2 )
209       bool operator!= ( const char * s1, const QString & s2 )
210       bool operator< ( const QString & s1, const char * s2 )
211       bool operator< ( const char * s1, const QString & s2 )
212       bool operator<= ( const QString & s1, const char * s2 )
213       bool operator<= ( const char * s1, const QString & s2 )
214       bool operator> ( const QString & s1, const char * s2 )
215       bool operator> ( const char * s1, const QString & s2 )
216       bool operator>= ( const QString & s1, const char * s2 )
217       bool operator>= ( const char * s1, const QString & s2 )
218       const QString operator+ ( const QString & s1, const QString & s2 )
219       const QString operator+ ( const QString & s1, const char * s2 )
220       const QString operator+ ( const char * s1, const QString & s2 )
221       const QString operator+ ( const QString & s, char c )
222       const QString operator+ ( char c, const QString & s )
223       QDataStream & operator<< ( QDataStream & s, const QString & str )
224       QDataStream & operator>> ( QDataStream & s, QString & str )
225

DESCRIPTION

227       The QString class provides an abstraction of Unicode text and the
228       classic C '&#92;0'-terminated char array.
229
230       QString uses implicit sharing, which makes it very efficient and easy
231       to use.
232
233       In all of the QString methods that take const char * parameters, the
234       const char * is interpreted as a classic C-style '&#92;0'-terminated
235       ASCII string. It is legal for the const char * parameter to be 0. If
236       the const char * is not '&#92;0'-terminated, the results are undefined.
237       Functions that copy classic C strings into a QString will not copy the
238       terminating '&#92;0' character. The QChar array of the QString (as
239       returned by unicode()) is generally not terminated by a '&#92;0'. If
240       you need to pass a QString to a function that requires a C
241       '&#92;0'-terminated string use latin1().
242
243       A QString that has not been assigned to anything is null, i.e. both the
244       length and data pointer is 0. A QString that references the empty
245       string ("", a single '&#92;0' char) is empty. Both null and empty
246       QStrings are legal parameters to the methods. Assigning (const char *)
247       0 to QString gives a null QString. For convenience, QString::null is a
248       null QString. When sorting, empty strings come first, followed by non-
249       empty strings, followed by null strings. We recommend using if (
250       !str.isNull() ) to check for a non-null string rather than if ( !str );
251       see operator!() for an explanation.
252
253       Note that if you find that you are mixing usage of QCString, QString,
254       and QByteArray, this causes lots of unnecessary copying and might
255       indicate that the true nature of the data you are dealing with is
256       uncertain. If the data is '&#92;0'-terminated 8-bit data, use QCString;
257       if it is unterminated (i.e. contains '&#92;0's) 8-bit data, use
258       QByteArray; if it is text, use QString.
259
260       Lists of strings are handled by the QStringList class. You can split a
261       string into a list of strings using QStringList::split(), and join a
262       list of strings into a single string with an optional separator using
263       QStringList::join(). You can obtain a list of strings from a string
264       list that contain a particular substring or that match a particular
265       regex using QStringList::grep().
266
267       Note for C programmers
268
269       Due to C++'s type system and the fact that QString is implicitly
270       shared, QStrings can be treated like ints or other simple base types.
271       For example:
272
273           QString boolToString( bool b )
274           {
275               QString result;
276               if ( b )
277                   result = "True";
278               else
279                   result = "False";
280               return result;
281           }
282
283       The variable, result, is an auto variable allocated on the stack. When
284       return is called, because we're returning by value, The copy
285       constructor is called and a copy of the string is returned. (No actual
286       copying takes place thanks to the implicit sharing, see below.)
287
288       Throughout Qt's source code you will encounter QString usages like
289       this:
290
291           QString func( const QString& input )
292           {
293               QString output = input;
294               // process output
295               return output;
296           }
297
298       The 'copying' of input to output is almost as fast as copying a pointer
299       because behind the scenes copying is achieved by incrementing a
300       reference count. QString (like all Qt's implicitly shared classes)
301       operates on a copy-on-write basis, only copying if an instance is
302       actually changed.
303
304       If you wish to create a deep copy of a QString without losing any
305       Unicode information then you should use QDeepCopy.
306
307       See also QChar, QCString, QByteArray, QConstString, Implicitly and
308       Explicitly Shared Classes, Text Related Classes, and Non-GUI Classes.
309
310   Member Type Documentation

QString::SectionFlags

312       QString::SectionDefault - Empty fields are counted, leading and
313       trailing separators are not included, and the separator is compared
314       case sensitively.
315
316       QString::SectionSkipEmpty - Treat empty fields as if they don't exist,
317       i.e. they are not considered as far as start and end are concerned.
318
319       QString::SectionIncludeLeadingSep - Include the leading separator (if
320       any) in the result string.
321
322       QString::SectionIncludeTrailingSep - Include the trailing separator (if
323       any) in the result string.
324
325       QString::SectionCaseInsensitiveSeps - Compare the separator case-
326       insensitively.
327
328       Any of the last four values can be OR-ed together to form a flag.
329
330       See also section().
331

MEMBER FUNCTION DOCUMENTATION

QString::QString ()

334       Constructs a null string, i.e. both the length and data pointer are 0.
335
336       See also isNull().
337

QString::QString ( QChar ch )

339       Constructs a string of length one, containing the character ch.
340

QString::QString ( const QString & s )

342       Constructs an implicitly shared copy of s. This is very fast since it
343       only involves incrementing a reference count.
344

QString::QString ( const QByteArray & ba )

346       Constructs a string that is a deep copy of ba interpreted as a classic
347       C string.
348

QString::QString ( const QChar * unicode, uint length )

350       Constructs a string that is a deep copy of the first length characters
351       in the QChar array.
352
353       If unicode and length are 0, then a null string is created.
354
355       If only unicode is 0, the string is empty but has length characters of
356       space preallocated: QString expands automatically anyway, but this may
357       speed up some cases a little. We recommend using the plain constructor
358       and setLength() for this purpose since it will result in more readable
359       code.
360
361       See also isNull() and setLength().
362

QString::QString ( const char * str )

364       Constructs a string that is a deep copy of str, interpreted as a
365       classic C string. The encoding is assumed to be Latin-1, unless you
366       change it using QTextCodec::setCodecForCStrings().
367
368       If str is 0, then a null string is created.
369
370       This is a cast constructor, but it is perfectly safe: converting a
371       Latin-1 const char * to QString preserves all the information. You can
372       disable this constructor by defining QT_NO_CAST_ASCII when you compile
373       your applications. You can also make QString objects by using
374       setLatin1(), fromLatin1(), fromLocal8Bit(), and fromUtf8(). Or whatever
375       encoding is appropriate for the 8-bit data you have.
376
377       See also isNull() and fromAscii().
378

QString::QString ( const std::string & str )

380       Constructs a string that is a deep copy of str.
381
382       This is the same as fromAscii(str).
383

QString::~QString ()

385       Destroys the string and frees the string's data if this is the last
386       reference to the string.
387

QString & QString::append ( const QString & str )

389       Appends str to the string and returns a reference to the result.
390
391               string = "Test";
392               string.append( "ing" );        // string == "Testing"
393
394       Equivalent to operator+=().
395
396       Example: dirview/dirview.cpp.
397

QString & QString::append ( char ch )

399       This is an overloaded member function, provided for convenience. It
400       behaves essentially like the above function.
401
402       Appends character ch to the string and returns a reference to the
403       result.
404
405       Equivalent to operator+=().
406

QString & QString::append ( QChar ch )

408       This is an overloaded member function, provided for convenience. It
409       behaves essentially like the above function.
410
411       Appends character ch to the string and returns a reference to the
412       result.
413
414       Equivalent to operator+=().
415

QString & QString::append ( const QByteArray & str )

417       This is an overloaded member function, provided for convenience. It
418       behaves essentially like the above function.
419
420       Appends str to the string and returns a reference to the result.
421
422       Equivalent to operator+=().
423

QString & QString::append ( const char * str )

425       This is an overloaded member function, provided for convenience. It
426       behaves essentially like the above function.
427
428       Appends str to the string and returns a reference to the result.
429
430       Equivalent to operator+=().
431

QString & QString::append ( const std::string & str )

433       This is an overloaded member function, provided for convenience. It
434       behaves essentially like the above function.
435
436       Appends str to the string and returns a reference to the result.
437
438       Equivalent to operator+=().
439

QString QString::arg ( const QString & a, int fieldWidth = 0 ) const

441       This function will return a string that replaces the lowest numbered
442       occurrence of %1, %2, ..., %9 with a.
443
444       The fieldWidth value specifies the minimum amount of space that a is
445       padded to. A positive value will produce right-aligned text, whereas a
446       negative value will produce left-aligned text.
447
448       The following example shows how we could create a 'status' string when
449       processing a list of files:
450
451           QString status = QString( "Processing file %1 of %2: %3" )
452                               .arg( i )         // current file's number
453                               .arg( total )     // number of files to process
454                               .arg( fileName ); // current file's name
455
456       It is generally fine to use filenames and numbers as we have done in
457       the example above. But note that using arg() to construct natural
458       language sentences does not usually translate well into other languages
459       because sentence structure and word order often differ between
460       languages.
461
462       If there is no place marker (%1, %2, etc.), a warning message
463       (qWarning()) is output and the result is undefined.
464
465       Warning: If any placeholder occurs more than once, the result is
466       undefined.
467

QString QString::arg ( long a, int fieldWidth = 0, int base = 10 ) const

469       This is an overloaded member function, provided for convenience. It
470       behaves essentially like the above function.
471
472       The fieldWidth value specifies the minimum amount of space that a is
473       padded to. A positive value will produce a right-aligned number,
474       whereas a negative value will produce a left-aligned number.
475
476       a is expressed in base base, which is 10 by default and must be between
477       2 and 36.
478
479       The '%' can be followed by an 'L', in which case the sequence is
480       replaced with a localized representation of a. The conversion uses the
481       default locale. The default locale is determined from the system's
482       locale settings at application startup. It can be changed using
483       QLocale::setDefault(). The 'L' flag is ignored if base is not 10.
484
485               QString str;
486               str = QString( "Decimal 63 is %1 in hexadecimal" )
487                       .arg( 63, 0, 16 );
488               // str == "Decimal 63 is 3f in hexadecimal"
489               QLocale::setDefault(QLocale::English, QLocale::UnitedStates);
490               str = QString( "%1 %L2 %L3" )
491                       .arg( 12345 )
492                       .arg( 12345 )
493                       .arg( 12345, 0, 16 );
494               // str == "12345 12,345 3039"
495

QString QString::arg ( ulong a, int fieldWidth = 0, int base = 10 ) const

497       This is an overloaded member function, provided for convenience. It
498       behaves essentially like the above function.
499
500       a is expressed in base base, which is 10 by default and must be between
501       2 and 36. If base is 10, the '%L' syntax can be used to produce
502       localized strings.
503

QString QString::arg ( Q_LLONG a, int fieldWidth = 0, int base = 10 ) const

505       This is an overloaded member function, provided for convenience. It
506       behaves essentially like the above function.
507
508       a is expressed in base base, which is 10 by default and must be between
509       2 and 36. If base is 10, the '%L' syntax can be used to produce
510       localized strings.
511

QString QString::arg ( Q_ULLONG a, int fieldWidth = 0, int base = 10 ) const

513       This is an overloaded member function, provided for convenience. It
514       behaves essentially like the above function.
515
516       a is expressed in base base, which is 10 by default and must be between
517       2 and 36. If base is 10, the '%L' syntax can be used to produce
518       localized strings.
519

QString QString::arg ( int a, int fieldWidth = 0, int base = 10 ) const

521       This is an overloaded member function, provided for convenience. It
522       behaves essentially like the above function.
523
524       a is expressed in base base, which is 10 by default and must be between
525       2 and 36. If base is 10, the '%L' syntax can be used to produce
526       localized strings.
527

QString QString::arg ( uint a, int fieldWidth = 0, int base = 10 ) const

529       This is an overloaded member function, provided for convenience. It
530       behaves essentially like the above function.
531
532       a is expressed in base base, which is 10 by default and must be between
533       2 and 36. If base is 10, the '%L' syntax can be used to produce
534       localized strings.
535

QString QString::arg ( short a, int fieldWidth = 0, int base = 10 ) const

537       This is an overloaded member function, provided for convenience. It
538       behaves essentially like the above function.
539
540       a is expressed in base base, which is 10 by default and must be between
541       2 and 36. If base is 10, the '%L' syntax can be used to produce
542       localized strings.
543

QString QString::arg ( ushort a, int fieldWidth = 0, int base = 10 ) const

545       This is an overloaded member function, provided for convenience. It
546       behaves essentially like the above function.
547
548       a is expressed in base base, which is 10 by default and must be between
549       2 and 36. If base is 10, the '%L' syntax can be used to produce
550       localized strings.
551

QString QString::arg ( double a, int fieldWidth = 0, char fmt = 'g', int prec

553       = -1 ) const
554       This is an overloaded member function, provided for convenience. It
555       behaves essentially like the above function.
556
557       Argument a is formatted according to the fmt format specified, which is
558       'g' by default and can be any of the following:
559
560       <center>.nf
561
562       </center>
563
564       With 'e', 'E', and 'f', prec is the number of digits after the decimal
565       point. With 'g' and 'G', prec is the maximum number of significant
566       digits (trailing zeroes are omitted).
567
568               double d = 12.34;
569               QString ds = QString( "'E' format, precision 3, gives %1" )
570                               .arg( d, 0, 'E', 3 );
571               // ds == "'E' format, precision 3, gives 1.234E+01"
572
573       The '%L' syntax can be used to produce localized strings.
574

QString QString::arg ( char a, int fieldWidth = 0 ) const

576       This is an overloaded member function, provided for convenience. It
577       behaves essentially like the above function.
578
579       a is assumed to be in the Latin-1 character set.
580

QString QString::arg ( QChar a, int fieldWidth = 0 ) const

582       This is an overloaded member function, provided for convenience. It
583       behaves essentially like the above function.
584

QString QString::arg ( const QString & a1, const QString & a2 ) const

586       This is an overloaded member function, provided for convenience. It
587       behaves essentially like the above function.
588
589       This is the same as str.arg(a1).arg(a2), except that the strings are
590       replaced in one pass. This can make a difference if a1 contains e.g.
591       %1:
592
593           QString str( "%1 %2" );
594           str.arg( "Hello", "world" );        // returns "Hello world"
595           str.arg( "Hello" ).arg( "world" );  // returns "Hello world"
596           str.arg( "(%1)", "Hello" );           // returns "(%1) Hello"
597           str.arg( "(%1)" ).arg( "Hello" );     // returns "(Hello) %2"
598

QString QString::arg ( const QString & a1, const QString & a2, const QString &

600       a3 ) const
601       This is an overloaded member function, provided for convenience. It
602       behaves essentially like the above function.
603
604       This is the same as calling str.arg(a1).arg(a2).arg(a3), except that
605       the strings are replaced in one pass.
606

QString QString::arg ( const QString & a1, const QString & a2, const QString &

608       a3, const QString & a4 ) const
609       This is an overloaded member function, provided for convenience. It
610       behaves essentially like the above function.
611
612       This is the same as calling str.arg(a1).arg(a2).arg(a3).arg(a4), except
613       that the strings are replaced in one pass.
614

const char * QString::ascii () const

616       Returns an 8-bit ASCII representation of the string.
617
618       If a codec has been set using QTextCodec::codecForCStrings(), it is
619       used to convert Unicode to 8-bit char. Otherwise, this function does
620       the same as latin1().
621
622       See also fromAscii(), latin1(), utf8(), and local8Bit().
623
624       Example: network/networkprotocol/nntp.cpp.
625

QChar QString::at ( uint i ) const

627       Returns the character at index i, or 0 if i is beyond the length of the
628       string.
629
630               const QString string( "abcdefgh" );
631               QChar ch = string.at( 4 );
632               // ch == 'e'
633
634       If the QString is not const (i.e. const QString) or const& (i.e. const
635       QString &), then the non-const overload of at() will be used instead.
636

QCharRef QString::at ( uint i )

638       This is an overloaded member function, provided for convenience. It
639       behaves essentially like the above function.
640
641       The function returns a reference to the character at index i. The
642       resulting reference can then be assigned to, or used immediately, but
643       it will become invalid once further modifications are made to the
644       original string.
645
646       If i is beyond the length of the string then the string is expanded
647       with QChar::null.
648

uint QString::capacity () const

650       Returns the number of characters this string can hold in the allocated
651       memory.
652
653       See also reserve() and squeeze().
654

int QString::compare ( const QString & s1, const QString & s2 ) [static]

656       Lexically compares s1 with s2 and returns an integer less than, equal
657       to, or greater than zero if s1 is less than, equal to, or greater than
658       s2.
659
660       The comparison is based exclusively on the numeric Unicode values of
661       the characters and is very fast, but is not what a human would expect.
662       Consider sorting user-interface strings with
663       QString::localeAwareCompare().
664
665               int a = QString::compare( "def", "abc" );   // a > 0
666               int b = QString::compare( "abc", "def" );   // b < 0
667               int c = QString::compare( "abc", "abc" );   // c == 0
668

int QString::compare ( const QString & s ) const

670       This is an overloaded member function, provided for convenience. It
671       behaves essentially like the above function.
672
673       Lexically compares this string with s and returns an integer less than,
674       equal to, or greater than zero if it is less than, equal to, or greater
675       than s.
676

void QString::compose ()

678       Warning: This function is not supported in Qt 3.x. It is provided for
679       experimental and illustrative purposes only. It is mainly of interest
680       to those experimenting with Arabic and other composition-rich texts.
681
682       Applies possible ligatures to a QString. Useful when composition-rich
683       text requires rendering with glyph-poor fonts, but it also makes
684       compositions such as QChar(0x0041) ('A') and QChar(0x0308) (Unicode
685       accent diaresis), giving QChar(0x00c4) (German A Umlaut).
686

QChar QString::constref ( uint i ) const

688       Returns the QChar at index i by value.
689
690       Equivalent to at(i).
691
692       See also ref().
693

int QString::contains ( QChar c, bool cs = TRUE ) const

695       Returns the number of times the character c occurs in the string.
696
697       If cs is TRUE (the default), the search is case sensitive; otherwise
698       the search is case insensitive.
699
700           QString string( "Trolltech and Qt" );
701           int n = string.contains( 't', FALSE );
702           // n == 3
703
704       Examples:
705

int QString::contains ( char c, bool cs = TRUE ) const

707       This is an overloaded member function, provided for convenience. It
708       behaves essentially like the above function.
709

int QString::contains ( const char * str, bool cs = TRUE ) const

711       This is an overloaded member function, provided for convenience. It
712       behaves essentially like the above function.
713
714       Returns the number of times the string str occurs in the string.
715
716       If cs is TRUE (the default), the search is case sensitive; otherwise
717       the search is case insensitive.
718

int QString::contains ( const QString & str, bool cs = TRUE ) const

720       This is an overloaded member function, provided for convenience. It
721       behaves essentially like the above function.
722
723       Returns the number of times str occurs in the string.
724
725       If cs is TRUE (the default), the search is case sensitive; otherwise
726       the search is case insensitive.
727
728       This function counts overlapping strings, so in the example below,
729       there are two instances of "ana" in "bananas".
730
731           QString str( "bananas" );
732           int i = str.contains( "ana" );  // i == 2
733
734       See also findRev().
735

int QString::contains ( const QRegExp & rx ) const

737       This is an overloaded member function, provided for convenience. It
738       behaves essentially like the above function.
739
740       Returns the number of times the regexp, rx, matches in the string.
741
742       This function counts overlapping matches, so in the example below,
743       there are four instances of "ana" or "ama".
744
745               QString str = "banana and panama";
746               QRegExp rxp = QRegExp( "a[nm]a", TRUE, FALSE );
747               int i = str.contains( rxp );    // i == 4
748
749       See also find() and findRev().
750

QString QString::copy () const

752       This function is obsolete. It is provided to keep old source working.
753       We strongly advise against using it in new code.
754
755       In Qt 2.0 and later, all calls to this function are needless. Just
756       remove them.
757

const char * QString::data () const

759       This function is obsolete. It is provided to keep old source working.
760       We strongly advise against using it in new code.
761
762       Returns a pointer to a '&#92;0'-terminated classic C string.
763
764       In Qt 1.x, this returned a char* allowing direct manipulation of the
765       string as a sequence of bytes. In Qt 2.x where QString is a Unicode
766       string, char* conversion constructs a temporary string, and hence
767       direct character operations are meaningless.
768

bool QString::endsWith ( const QString & s, bool cs = TRUE ) const

770       Returns TRUE if the string ends with s; otherwise returns FALSE.
771
772       If cs is TRUE (the default), the search is case sensitive; otherwise
773       the search is case insensitive.
774
775               QString str( "Bananas" );
776               str.endsWith( "anas" );         // returns TRUE
777               str.endsWith( "pple" );         // returns FALSE
778
779       See also startsWith().
780
781       Example: chart/main.cpp.
782

QString & QString::fill ( QChar c, int len = -1 )

784       Fills the string with len characters of value c, and returns a
785       reference to the string.
786
787       If len is negative (the default), the current string length is used.
788
789               QString str;
790               str.fill( 'g', 5 );      // string == "ggggg"
791

int QString::find ( const QRegExp & rx, int index = 0 ) const

793       Finds the first match of the regular expression rx, starting from
794       position index. If index is -1, the search starts at the last
795       character; if -2, at the next to last character and so on. (See
796       findRev() for searching backwards.)
797
798       Returns the position of the first match of rx or -1 if no match was
799       found.
800
801               QString string( "bananas" );
802               int i = string.find( QRegExp("an"), 0 );    // i == 1
803
804       See also findRev(), replace(), and contains().
805
806       Example: network/mail/smtp.cpp.
807

int QString::find ( QChar c, int index = 0, bool cs = TRUE ) const

809       This is an overloaded member function, provided for convenience. It
810       behaves essentially like the above function.
811
812       Finds the first occurrence of the character c, starting at position
813       index. If index is -1, the search starts at the last character; if -2,
814       at the next to last character and so on. (See findRev() for searching
815       backwards.)
816
817       If cs is TRUE (the default), the search is case sensitive; otherwise
818       the search is case insensitive.
819
820       Returns the position of c or -1 if c could not be found.
821

int QString::find ( char c, int index = 0, bool cs = TRUE ) const

823       This is an overloaded member function, provided for convenience. It
824       behaves essentially like the above function.
825
826       Find character c starting from position index.
827
828       If cs is TRUE (the default), the search is case sensitive; otherwise
829       the search is case insensitive.
830

int QString::find ( const QString & str, int index = 0, bool cs = TRUE ) const

832
833       This is an overloaded member function, provided for convenience. It
834       behaves essentially like the above function.
835
836       Finds the first occurrence of the string str, starting at position
837       index. If index is -1, the search starts at the last character, if it
838       is -2, at the next to last character and so on. (See findRev() for
839       searching backwards.)
840
841       If cs is TRUE (the default), the search is case sensitive; otherwise
842       the search is case insensitive.
843
844       Returns the position of str or -1 if str could not be found.
845

int QString::find ( const char * str, int index = 0 ) const

847       This is an overloaded member function, provided for convenience. It
848       behaves essentially like the above function.
849
850       Equivalent to find(QString(str), index).
851

int QString::findRev ( const char * str, int index = -1 ) const

853       Equivalent to findRev(QString(str), index).
854

int QString::findRev ( QChar c, int index = -1, bool cs = TRUE ) const

856       This is an overloaded member function, provided for convenience. It
857       behaves essentially like the above function.
858
859       Finds the first occurrence of the character c, starting at position
860       index and searching backwards. If the index is -1, the search starts at
861       the last character, if it is -2, at the next to last character and so
862       on.
863
864       Returns the position of c or -1 if c could not be found.
865
866       If cs is TRUE (the default), the search is case sensitive; otherwise
867       the search is case insensitive.
868
869               QString string( "bananas" );
870               int i = string.findRev( 'a' );      // i == 5
871

int QString::findRev ( char c, int index = -1, bool cs = TRUE ) const

873       This is an overloaded member function, provided for convenience. It
874       behaves essentially like the above function.
875
876       Find character c starting from position index and working backwards.
877
878       If cs is TRUE (the default), the search is case sensitive; otherwise
879       the search is case insensitive.
880

int QString::findRev ( const QString & str, int index = -1, bool cs = TRUE )

882       const
883       This is an overloaded member function, provided for convenience. It
884       behaves essentially like the above function.
885
886       Finds the first occurrence of the string str, starting at position
887       index and searching backwards. If the index is -1, the search starts at
888       the last character, if it is -2, at the next to last character and so
889       on.
890
891       Returns the position of str or -1 if str could not be found.
892
893       If cs is TRUE (the default), the search is case sensitive; otherwise
894       the search is case insensitive.
895
896           QString string("bananas");
897           int i = string.findRev( "ana" );      // i == 3
898

int QString::findRev ( const QRegExp & rx, int index = -1 ) const

900       This is an overloaded member function, provided for convenience. It
901       behaves essentially like the above function.
902
903       Finds the first match of the regexp rx, starting at position index and
904       searching backwards. If the index is -1, the search starts at the last
905       character, if it is -2, at the next to last character and so on. (See
906       findRev() for searching backwards.)
907
908       Returns the position of the match or -1 if no match was found.
909
910               QString string( "bananas" );
911               int i = string.findRev( QRegExp("an") );      // i == 3
912
913       See also find().
914

QString QString::fromAscii ( const char * ascii, int len = -1 ) [static]

916       Returns the Unicode string decoded from the first len bytes of ascii,
917       ignoring the rest of ascii. If len is -1 then the length of ascii is
918       used. If len is bigger than the length of ascii then it will use the
919       length of ascii.
920
921       If a codec has been set using QTextCodec::codecForCStrings(), it is
922       used to convert the string from 8-bit characters to Unicode. Otherwise,
923       this function does the same as fromLatin1().
924
925       This is the same as the QString(const char*) constructor, but you can
926       make that constructor invisible if you compile with the define
927       QT_NO_CAST_ASCII, in which case you can explicitly create a QString
928       from 8-bit ASCII text using this function.
929
930               QString str = QString::fromAscii( "123456789", 5 );
931               // str == "12345"
932

QString QString::fromLatin1 ( const char * chars, int len = -1 ) [static]

934       Returns the Unicode string decoded from the first len bytes of chars,
935       ignoring the rest of chars. If len is -1 then the length of chars is
936       used. If len is bigger than the length of chars then it will use the
937       length of chars.
938
939       See also fromAscii().
940
941       Examples:
942

QString QString::fromLocal8Bit ( const char * local8Bit, int len = -1 )

944       [static]
945       Returns the Unicode string decoded from the first len bytes of
946       local8Bit, ignoring the rest of local8Bit. If len is -1 then the length
947       of local8Bit is used. If len is bigger than the length of local8Bit
948       then it will use the length of local8Bit.
949
950               QString str = QString::fromLocal8Bit( "123456789", 5 );
951               // str == "12345"
952
953       local8Bit is assumed to be encoded in a locale-specific format.
954
955       See QTextCodec for more diverse coding/decoding of Unicode strings.
956

QString QString::fromUcs2 ( const unsigned short * str ) [static]

958       Constructs a string that is a deep copy of str, interpreted as a UCS2
959       encoded, zero terminated, Unicode string.
960
961       If str is 0, then a null string is created.
962
963       See also isNull().
964

QString QString::fromUtf8 ( const char * utf8, int len = -1 ) [static]

966       Returns the Unicode string decoded from the first len bytes of utf8,
967       ignoring the rest of utf8. If len is -1 then the length of utf8 is
968       used. If len is bigger than the length of utf8 then it will use the
969       length of utf8.
970
971               QString str = QString::fromUtf8( "123456789", 5 );
972               // str == "12345"
973
974       See QTextCodec for more diverse coding/decoding of Unicode strings.
975
976       Example: fonts/simple-qfont-demo/viewer.cpp.
977

QString & QString::insert ( uint index, const QString & s )

979       Inserts s into the string at position index.
980
981       If index is beyond the end of the string, the string is extended with
982       spaces to length index and s is then appended and returns a reference
983       to the string.
984
985               QString string( "I like fish" );
986               str = string.insert( 2, "don't " );
987               // str == "I don't like fish"
988
989       See also remove() and replace().
990
991       Examples:
992

QString & QString::insert ( uint index, const QByteArray & s )

994       This is an overloaded member function, provided for convenience. It
995       behaves essentially like the above function.
996
997       Inserts s into the string at position index and returns a reference to
998       the string.
999

QString & QString::insert ( uint index, const char * s )

1001       This is an overloaded member function, provided for convenience. It
1002       behaves essentially like the above function.
1003
1004       Inserts s into the string at position index and returns a reference to
1005       the string.
1006

QString & QString::insert ( uint index, const QChar * s, uint len )

1008       This is an overloaded member function, provided for convenience. It
1009       behaves essentially like the above function.
1010
1011       Inserts the first len characters in s into the string at position index
1012       and returns a reference to the string.
1013

QString & QString::insert ( uint index, QChar c )

1015       This is an overloaded member function, provided for convenience. It
1016       behaves essentially like the above function.
1017
1018       Insert c into the string at position index and returns a reference to
1019       the string.
1020
1021       If index is beyond the end of the string, the string is extended with
1022       spaces (ASCII 32) to length index and c is then appended.
1023

QString & QString::insert ( uint index, char c )

1025       This is an overloaded member function, provided for convenience. It
1026       behaves essentially like the above function.
1027
1028       Insert character c at position index.
1029

bool QString::isEmpty () const

1031       Returns TRUE if the string is empty, i.e. if length() == 0; otherwise
1032       returns FALSE. Null strings are also empty.
1033
1034               QString a( "" );
1035               a.isEmpty();        // TRUE
1036               a.isNull();         // FALSE
1037               QString b;
1038               b.isEmpty();        // TRUE
1039               b.isNull();         // TRUE
1040
1041       See also isNull() and length().
1042
1043       Examples:
1044

bool QString::isNull () const

1046       Returns TRUE if the string is null; otherwise returns FALSE. A null
1047       string is always empty.
1048
1049               QString a;          // a.unicode() == 0, a.length() == 0
1050               a.isNull();         // TRUE, because a.unicode() == 0
1051               a.isEmpty();        // TRUE, because a.length() == 0
1052
1053       See also isEmpty() and length().
1054
1055       Examples:
1056

const char * QString::latin1 () const

1058       Returns a Latin-1 representation of the string. The returned value is
1059       undefined if the string contains non-Latin-1 characters. If you want to
1060       convert strings into formats other than Unicode, see the QTextCodec
1061       classes.
1062
1063       This function is mainly useful for boot-strapping legacy code to use
1064       Unicode.
1065
1066       The result remains valid so long as one unmodified copy of the source
1067       string exists.
1068
1069       See also fromLatin1(), ascii(), utf8(), and local8Bit().
1070
1071       Examples:
1072

QString QString::left ( uint len ) const

1074       Returns a substring that contains the len leftmost characters of the
1075       string.
1076
1077       The whole string is returned if len exceeds the length of the string.
1078
1079               QString s = "Pineapple";
1080               QString t = s.left( 4 );    // t == "Pine"
1081
1082       See also right(), mid(), and isEmpty().
1083
1084       Example: themes/themes.cpp.
1085

QString QString::leftJustify ( uint width, QChar fill = ' ', bool truncate =

1087       FALSE ) const
1088       Returns a string of length width that contains this string padded by
1089       the fill character.
1090
1091       If truncate is FALSE and the length of the string is more than width,
1092       then the returned string is a copy of the string.
1093
1094       If truncate is TRUE and the length of the string is more than width,
1095       then any characters in a copy of the string after length width are
1096       removed, and the copy is returned.
1097
1098               QString s( "apple" );
1099               QString t = s.leftJustify( 8, '.' );        // t == "apple..."
1100
1101       See also rightJustify().
1102

uint QString::length () const

1104       Returns the length of the string.
1105
1106       Null strings and empty strings have zero length.
1107
1108       See also isNull() and isEmpty().
1109
1110       Examples:
1111

QCString QString::local8Bit () const

1113       Returns the string encoded in a locale-specific format. On X11, this is
1114       the QTextCodec::codecForLocale(). On Windows, it is a system-defined
1115       encoding. On Mac OS X, this always uses UTF-8 as the encoding.
1116
1117       See QTextCodec for more diverse coding/decoding of Unicode strings.
1118
1119       See also fromLocal8Bit(), ascii(), latin1(), and utf8().
1120

int QString::localeAwareCompare ( const QString & s1, const QString & s2 )

1122       [static]
1123       Compares s1 with s2 and returns an integer less than, equal to, or
1124       greater than zero if s1 is less than, equal to, or greater than s2.
1125
1126       The comparison is performed in a locale- and also platform-dependent
1127       manner. Use this function to present sorted lists of strings to the
1128       user.
1129
1130       See also QString::compare() and QTextCodec::locale().
1131

int QString::localeAwareCompare ( const QString & s ) const

1133       This is an overloaded member function, provided for convenience. It
1134       behaves essentially like the above function.
1135
1136       Compares this string with s.
1137

QString QString::lower () const

1139       Returns a lowercase copy of the string.
1140
1141               QString string( "TROlltECH" );
1142               str = string.lower();   // str == "trolltech"
1143
1144       See also upper().
1145
1146       Example: scribble/scribble.cpp.
1147

QString QString::mid ( uint index, uint len = 0xffffffff ) const

1149       Returns a string that contains the len characters of this string,
1150       starting at position index.
1151
1152       Returns a null string if the string is empty or index is out of range.
1153       Returns the whole string from index if index + len exceeds the length
1154       of the string.
1155
1156               QString s( "Five pineapples" );
1157               QString t = s.mid( 5, 4 );                  // t == "pine"
1158
1159       See also left() and right().
1160
1161       Examples:
1162

QString QString::number ( long n, int base = 10 ) [static]

1164       A convenience function that returns a string equivalent of the number n
1165       to base base, which is 10 by default and must be between 2 and 36. The
1166       returned string is in "C" locale.
1167
1168               long a = 63;
1169               QString str = QString::number( a, 16 );             // str == "3f"
1170               QString str = QString::number( a, 16 ).upper();     // str == "3F"
1171
1172       See also setNum().
1173
1174       Examples:
1175

QString QString::number ( ulong n, int base = 10 ) [static]

1177       This is an overloaded member function, provided for convenience. It
1178       behaves essentially like the above function.
1179
1180       See also setNum().
1181

QString QString::number ( Q_LLONG n, int base = 10 ) [static]

1183       This is an overloaded member function, provided for convenience. It
1184       behaves essentially like the above function.
1185
1186       See also setNum().
1187

QString QString::number ( Q_ULLONG n, int base = 10 ) [static]

1189       This is an overloaded member function, provided for convenience. It
1190       behaves essentially like the above function.
1191
1192       See also setNum().
1193

QString QString::number ( int n, int base = 10 ) [static]

1195       This is an overloaded member function, provided for convenience. It
1196       behaves essentially like the above function.
1197
1198       See also setNum().
1199

QString QString::number ( uint n, int base = 10 ) [static]

1201       This is an overloaded member function, provided for convenience. It
1202       behaves essentially like the above function.
1203
1204       A convenience factory function that returns a string representation of
1205       the number n to the base base, which is 10 by default and must be
1206       between 2 and 36.
1207
1208       See also setNum().
1209

QString QString::number ( double n, char f = 'g', int prec = 6 ) [static]

1211       This is an overloaded member function, provided for convenience. It
1212       behaves essentially like the above function.
1213
1214       Argument n is formatted according to the f format specified, which is g
1215       by default, and can be any of the following:
1216
1217       <center>.nf
1218
1219       </center>
1220
1221       With 'e', 'E', and 'f', prec is the number of digits after the decimal
1222       point. With 'g' and 'G', prec is the maximum number of significant
1223       digits (trailing zeroes are omitted).
1224
1225           double d = 12.34;
1226           QString ds = QString( "'E' format, precision 3, gives %1" )
1227                           .arg( d, 0, 'E', 3 );
1228           // ds == "1.234E+001"
1229
1230       See also setNum().
1231

QString::operator const char * () const

1233       Returns ascii(). Be sure to see the warnings documented in the ascii()
1234       function. Note that for new code which you wish to be strictly Unicode-
1235       clean, you can define the macro QT_NO_ASCII_CAST when compiling your
1236       code to hide this function so that automatic casts are not done. This
1237       has the added advantage that you catch the programming error described
1238       in operator!().
1239

QString::operator std::string () const

1241       Returns ascii() as a std::string.
1242
1243       Warning: The function may cause an application to crash if a static C
1244       run-time is in use. This can happen in Microsoft Visual C++ if Qt is
1245       configured as single-threaded. A safe alternative is to call ascii()
1246       directly and construct a std::string manually.
1247

bool QString::operator! () const

1249       Returns TRUE if this is a null string; otherwise returns FALSE.
1250
1251               QString name = getName();
1252               if ( !name )
1253                   name = "Rodney";
1254
1255       Note that if you say
1256
1257               QString name = getName();
1258               if ( name )
1259                   doSomethingWith(name);
1260
1261       It will call "operator const char*()", which is inefficent; you may
1262       wish to define the macro QT_NO_ASCII_CAST when writing code which you
1263       wish to remain Unicode-clean.
1264
1265       When you want the above semantics, use:
1266
1267               QString name = getName();
1268               if ( !name.isNull() )
1269                   doSomethingWith(name);
1270
1271       See also isEmpty().
1272

QString & QString::operator+= ( const QString & str )

1274       Appends str to the string and returns a reference to the string.
1275

QString & QString::operator+= ( const QByteArray & str )

1277       This is an overloaded member function, provided for convenience. It
1278       behaves essentially like the above function.
1279
1280       Appends str to the string and returns a reference to the string.
1281

QString & QString::operator+= ( const char * str )

1283       This is an overloaded member function, provided for convenience. It
1284       behaves essentially like the above function.
1285
1286       Appends str to the string and returns a reference to the string.
1287

QString & QString::operator+= ( const std::string & str )

1289       This is an overloaded member function, provided for convenience. It
1290       behaves essentially like the above function.
1291
1292       Appends str to the string and returns a reference to the string.
1293

QString & QString::operator+= ( QChar c )

1295       This is an overloaded member function, provided for convenience. It
1296       behaves essentially like the above function.
1297
1298       Appends c to the string and returns a reference to the string.
1299

QString & QString::operator+= ( char c )

1301       This is an overloaded member function, provided for convenience. It
1302       behaves essentially like the above function.
1303
1304       Appends c to the string and returns a reference to the string.
1305

QString & QString::operator= ( QChar c )

1307       Sets the string to contain just the single character c.
1308

QString & QString::operator= ( const QString & s )

1310       This is an overloaded member function, provided for convenience. It
1311       behaves essentially like the above function.
1312
1313       Assigns a shallow copy of s to this string and returns a reference to
1314       this string. This is very fast because the string isn't actually
1315       copied.
1316

QString & QString::operator= ( const char * str )

1318       This is an overloaded member function, provided for convenience. It
1319       behaves essentially like the above function.
1320
1321       Assigns a deep copy of str, interpreted as a classic C string to this
1322       string and returns a reference to this string.
1323
1324       If str is 0, then a null string is created.
1325
1326       See also isNull().
1327

QString & QString::operator= ( const std::string & s )

1329       This is an overloaded member function, provided for convenience. It
1330       behaves essentially like the above function.
1331
1332       Makes a deep copy of s and returns a reference to the deep copy.
1333

QString & QString::operator= ( const QCString & cstr )

1335       This is an overloaded member function, provided for convenience. It
1336       behaves essentially like the above function.
1337
1338       Assigns a deep copy of cstr, interpreted as a classic C string, to this
1339       string. Returns a reference to this string.
1340

QString & QString::operator= ( char c )

1342       This is an overloaded member function, provided for convenience. It
1343       behaves essentially like the above function.
1344
1345       Sets the string to contain just the single character c.
1346

QChar QString::operator[] ( int i ) const

1348       Returns the character at index i, or QChar::null if i is beyond the
1349       length of the string.
1350
1351       If the QString is not const (i.e., const QString) or const& (i.e.,
1352       const QString&), then the non-const overload of operator[] will be used
1353       instead.
1354

QCharRef QString::operator[] ( int i )

1356       This is an overloaded member function, provided for convenience. It
1357       behaves essentially like the above function.
1358
1359       The function returns a reference to the character at index i. The
1360       resulting reference can then be assigned to, or used immediately, but
1361       it will become invalid once further modifications are made to the
1362       original string.
1363
1364       If i is beyond the length of the string then the string is expanded
1365       with QChar::nulls, so that the QCharRef references a valid (null)
1366       character in the string.
1367
1368       The QCharRef internal class can be used much like a constant QChar, but
1369       if you assign to it, you change the original string (which will detach
1370       itself because of QString's copy-on-write semantics). You will get
1371       compilation errors if you try to use the result as anything but a
1372       QChar.
1373

QString & QString::prepend ( const QString & s )

1375       Inserts s at the beginning of the string and returns a reference to the
1376       string.
1377
1378       Equivalent to insert(0, s).
1379
1380               QString string = "42";
1381               string.prepend( "The answer is " );
1382               // string == "The answer is 42"
1383
1384       See also insert().
1385

QString & QString::prepend ( char ch )

1387       This is an overloaded member function, provided for convenience. It
1388       behaves essentially like the above function.
1389
1390       Inserts ch at the beginning of the string and returns a reference to
1391       the string.
1392
1393       Equivalent to insert(0, ch).
1394
1395       See also insert().
1396

QString & QString::prepend ( QChar ch )

1398       This is an overloaded member function, provided for convenience. It
1399       behaves essentially like the above function.
1400
1401       Inserts ch at the beginning of the string and returns a reference to
1402       the string.
1403
1404       Equivalent to insert(0, ch).
1405
1406       See also insert().
1407

QString & QString::prepend ( const QByteArray & s )

1409       This is an overloaded member function, provided for convenience. It
1410       behaves essentially like the above function.
1411
1412       Inserts s at the beginning of the string and returns a reference to the
1413       string.
1414
1415       Equivalent to insert(0, s).
1416
1417       See also insert().
1418

QString & QString::prepend ( const char * s )

1420       This is an overloaded member function, provided for convenience. It
1421       behaves essentially like the above function.
1422
1423       Inserts s at the beginning of the string and returns a reference to the
1424       string.
1425
1426       Equivalent to insert(0, s).
1427
1428       See also insert().
1429

QString & QString::prepend ( const std::string & s )

1431       This is an overloaded member function, provided for convenience. It
1432       behaves essentially like the above function.
1433
1434       Inserts s at the beginning of the string and returns a reference to the
1435       string.
1436
1437       Equivalent to insert(0, s).
1438
1439       See also insert().
1440

QChar & QString::ref ( uint i )

1442       Returns the QChar at index i by reference, expanding the string with
1443       QChar::null if necessary. The resulting reference can be assigned to,
1444       or otherwise used immediately, but becomes invalid once furher
1445       modifications are made to the string.
1446
1447               QString string("ABCDEF");
1448               QChar ch = string.ref( 3 );         // ch == 'D'
1449
1450       See also constref().
1451

QString & QString::remove ( uint index, uint len )

1453       Removes len characters from the string starting at position index, and
1454       returns a reference to the string.
1455
1456       If index is beyond the length of the string, nothing happens. If index
1457       is within the string, but index + len is beyond the end of the string,
1458       the string is truncated at position index.
1459
1460               QString string( "Montreal" );
1461               string.remove( 1, 4 );      // string == "Meal"
1462
1463       See also insert() and replace().
1464

QString & QString::remove ( const QString & str, bool cs = TRUE )

1466       This is an overloaded member function, provided for convenience. It
1467       behaves essentially like the above function.
1468
1469       Removes every occurrence of str in the string. Returns a reference to
1470       the string.
1471
1472       If cs is TRUE (the default), the search is case sensitive; otherwise
1473       the search is case insensitive.
1474
1475       This is the same as replace(str, "", cs).
1476

QString & QString::remove ( QChar c )

1478       This is an overloaded member function, provided for convenience. It
1479       behaves essentially like the above function.
1480
1481       Removes every occurrence of the character c in the string. Returns a
1482       reference to the string.
1483
1484       This is the same as replace(c, "").
1485

QString & QString::remove ( char c )

1487       This is an overloaded member function, provided for convenience. It
1488       behaves essentially like the above function.
1489
1490       Removes every occurrence of the character c in the string. Returns a
1491       reference to the string.
1492
1493       This is the same as replace(c, "").
1494

QString & QString::remove ( const char * str )

1496       This is an overloaded member function, provided for convenience. It
1497       behaves essentially like the above function.
1498
1499       Removes every occurrence of str in the string. Returns a reference to
1500       the string.
1501

QString & QString::remove ( const QRegExp & rx )

1503       This is an overloaded member function, provided for convenience. It
1504       behaves essentially like the above function.
1505
1506       Removes every occurrence of the regular expression rx in the string.
1507       Returns a reference to the string.
1508
1509       This is the same as replace(rx, "").
1510

QString & QString::replace ( uint index, uint len, const QString & s )

1512       Replaces len characters from the string with s, starting at position
1513       index, and returns a reference to the string.
1514
1515       If index is beyond the length of the string, nothing is deleted and s
1516       is appended at the end of the string. If index is valid, but index +
1517       len is beyond the end of the string, the string is truncated at
1518       position index, then s is appended at the end.
1519
1520               QString string( "Say yes!" );
1521               string = string.replace( 4, 3, "NO" );
1522               // string == "Say NO!"
1523
1524       Warning: Qt 3.3.3 and earlier had different semantics for the case
1525       index >= length(), which contradicted the documentation. To avoid
1526       portability problems between Qt 3 versions and with Qt 4, we recommend
1527       that you never call the function with index >= length().
1528
1529       See also insert() and remove().
1530
1531       Examples:
1532

QString & QString::replace ( uint index, uint len, const QChar * s, uint slen

1534       )
1535       This is an overloaded member function, provided for convenience. It
1536       behaves essentially like the above function.
1537
1538       Replaces len characters with slen characters of QChar data from s,
1539       starting at position index, and returns a reference to the string.
1540
1541       See also insert() and remove().
1542

QString & QString::replace ( uint index, uint len, QChar c )

1544       This is an overloaded member function, provided for convenience. It
1545       behaves essentially like the above function.
1546
1547       This is the same as replace(index, len, QString(c)).
1548

QString & QString::replace ( uint index, uint len, char c )

1550       This is an overloaded member function, provided for convenience. It
1551       behaves essentially like the above function.
1552
1553       This is the same as replace(index, len, QChar(c)).
1554

QString & QString::replace ( QChar c, const QString & after, bool cs = TRUE )

1556       This is an overloaded member function, provided for convenience. It
1557       behaves essentially like the above function.
1558
1559       Replaces every occurrence of the character c in the string with after.
1560       Returns a reference to the string.
1561
1562       If cs is TRUE (the default), the search is case sensitive; otherwise
1563       the search is case insensitive.
1564
1565       Example:
1566
1567           QString s = "a,b,c";
1568           s.replace( QChar(','), " or " );
1569           // s == "a or b or c"
1570

QString & QString::replace ( char c, const QString & after, bool cs = TRUE )

1572       This is an overloaded member function, provided for convenience. It
1573       behaves essentially like the above function.
1574
1575       Replaces every occurrence of the character c in the string with after.
1576       Returns a reference to the string.
1577
1578       If cs is TRUE (the default), the search is case sensitive; otherwise
1579       the search is case insensitive.
1580

QString & QString::replace ( const QString & before, const QString & after,

1582       bool cs = TRUE )
1583       This is an overloaded member function, provided for convenience. It
1584       behaves essentially like the above function.
1585
1586       Replaces every occurrence of the string before in the string with the
1587       string after. Returns a reference to the string.
1588
1589       If cs is TRUE (the default), the search is case sensitive; otherwise
1590       the search is case insensitive.
1591
1592       Example:
1593
1594           QString s = "Greek is Greek";
1595           s.replace( "Greek", "English" );
1596           // s == "English is English"
1597

QString & QString::replace ( const QRegExp & rx, const QString & after )

1599       This is an overloaded member function, provided for convenience. It
1600       behaves essentially like the above function.
1601
1602       Replaces every occurrence of the regexp rx in the string with after.
1603       Returns a reference to the string. For example:
1604
1605           QString s = "banana";
1606           s.replace( QRegExp("an"), "" );
1607           // s == "ba"
1608
1609       For regexps containing capturing parentheses, occurrences of &#92;1,
1610       &#92;2, ..., in after are replaced with rx.cap(1), cap(2), ...
1611
1612           QString t = "A <i>bon mot</i>.";
1613           t.replace( QRegExp("<i>([^<]*)</i>"), "\\emph{\\1}" );
1614           // t == "A \\emph{bon mot}."
1615
1616       See also find(), findRev(), and QRegExp::cap().
1617

QString & QString::replace ( QChar c1, QChar c2 )

1619       This is an overloaded member function, provided for convenience. It
1620       behaves essentially like the above function.
1621
1622       Replaces every occurrence of c1 with the char c2. Returns a reference
1623       to the string.
1624

void QString::reserve ( uint minCapacity )

1626       Ensures that at least minCapacity characters are allocated to the
1627       string.
1628
1629       This function is useful for code that needs to build up a long string
1630       and wants to avoid repeated reallocation. In this example, we want to
1631       add to the string until some condition is true, and we're fairly sure
1632       that size is big enough:
1633
1634               QString result;
1635               int len = 0;
1636               result.reserve(maxLen);
1637               while (...) {
1638                   result[len++] = ...         // fill part of the space
1639               }
1640               result.squeeze();
1641
1642       If maxLen is an underestimate, the worst that will happen is that the
1643       loop will slow down.
1644
1645       If it is not possible to allocate enough memory, the string remains
1646       unchanged.
1647
1648       See also capacity(), squeeze(), and setLength().
1649

QString QString::right ( uint len ) const

1651       Returns a string that contains the len rightmost characters of the
1652       string.
1653
1654       If len is greater than the length of the string then the whole string
1655       is returned.
1656
1657               QString string( "Pineapple" );
1658               QString t = string.right( 5 );   // t == "apple"
1659
1660       See also left(), mid(), and isEmpty().
1661
1662       Example: fileiconview/qfileiconview.cpp.
1663

QString QString::rightJustify ( uint width, QChar fill = ' ', bool truncate =

1665       FALSE ) const
1666       Returns a string of length width that contains the fill character
1667       followed by the string.
1668
1669       If truncate is FALSE and the length of the string is more than width,
1670       then the returned string is a copy of the string.
1671
1672       If truncate is TRUE and the length of the string is more than width,
1673       then the resulting string is truncated at position width.
1674
1675               QString string( "apple" );
1676               QString t = string.rightJustify( 8, '.' );  // t == "...apple"
1677
1678       See also leftJustify().
1679

QString QString::section ( QChar sep, int start, int end = 0xffffffff, int

1681       flags = SectionDefault ) const
1682       This function returns a section of the string.
1683
1684       This string is treated as a sequence of fields separated by the
1685       character, sep. The returned string consists of the fields from
1686       position start to position end inclusive. If end is not specified, all
1687       fields from position start to the end of the string are included.
1688       Fields are numbered 0, 1, 2, etc., counting from the left, and -1, -2,
1689       etc., counting from right to left.
1690
1691       The flags argument can be used to affect some aspects of the function's
1692       behaviour, e.g. whether to be case sensitive, whether to skip empty
1693       fields and how to deal with leading and trailing separators; see
1694       SectionFlags.
1695
1696           QString csv( "forename,middlename,surname,phone" );
1697           QString s = csv.section( ',', 2, 2 );   // s == "surname"
1698           QString path( "/usr/local/bin/myapp" ); // First field is empty
1699           QString s = path.section( '/', 3, 4 );  // s == "bin/myapp"
1700           QString s = path.section( '/', 3, 3, SectionSkipEmpty ); // s == "myapp"
1701
1702       If start or end is negative, we count fields from the right of the
1703       string, the right-most field being -1, the one from right-most field
1704       being -2, and so on.
1705
1706           QString csv( "forename,middlename,surname,phone" );
1707           QString s = csv.section( ',', -3, -2 );  // s == "middlename,surname"
1708           QString path( "/usr/local/bin/myapp" ); // First field is empty
1709           QString s = path.section( '/', -1 ); // s == "myapp"
1710
1711       See also QStringList::split().
1712
1713       Examples:
1714

QString QString::section ( char sep, int start, int end = 0xffffffff, int

1716       flags = SectionDefault ) const
1717       This is an overloaded member function, provided for convenience. It
1718       behaves essentially like the above function.
1719

QString QString::section ( const char * sep, int start, int end = 0xffffffff,

1721       int flags = SectionDefault ) const
1722       This is an overloaded member function, provided for convenience. It
1723       behaves essentially like the above function.
1724

QString QString::section ( const QString & sep, int start, int end =

1726       0xffffffff, int flags = SectionDefault ) const
1727       This is an overloaded member function, provided for convenience. It
1728       behaves essentially like the above function.
1729
1730       This function returns a section of the string.
1731
1732       This string is treated as a sequence of fields separated by the string,
1733       sep. The returned string consists of the fields from position start to
1734       position end inclusive. If end is not specified, all fields from
1735       position start to the end of the string are included. Fields are
1736       numbered 0, 1, 2, etc., counting from the left, and -1, -2, etc.,
1737       counting from right to left.
1738
1739       The flags argument can be used to affect some aspects of the function's
1740       behaviour, e.g. whether to be case sensitive, whether to skip empty
1741       fields and how to deal with leading and trailing separators; see
1742       SectionFlags.
1743
1744           QString data( "forename**middlename**surname**phone" );
1745           QString s = data.section( "**", 2, 2 ); // s == "surname"
1746
1747       If start or end is negative, we count fields from the right of the
1748       string, the right-most field being -1, the one from right-most field
1749       being -2, and so on.
1750
1751           QString data( "forename**middlename**surname**phone" );
1752           QString s = data.section( "**", -3, -2 ); // s == "middlename**surname"
1753
1754       See also QStringList::split().
1755

QString QString::section ( const QRegExp & reg, int start, int end =

1757       0xffffffff, int flags = SectionDefault ) const
1758       This is an overloaded member function, provided for convenience. It
1759       behaves essentially like the above function.
1760
1761       This function returns a section of the string.
1762
1763       This string is treated as a sequence of fields separated by the regular
1764       expression, reg. The returned string consists of the fields from
1765       position start to position end inclusive. If end is not specified, all
1766       fields from position start to the end of the string are included.
1767       Fields are numbered 0, 1, 2, etc., counting from the left, and -1, -2,
1768       etc., counting from right to left.
1769
1770       The flags argument can be used to affect some aspects of the function's
1771       behaviour, e.g. whether to be case sensitive, whether to skip empty
1772       fields and how to deal with leading and trailing separators; see
1773       SectionFlags.
1774
1775           QString line( "forename\tmiddlename  surname \t \t phone" );
1776           QRegExp sep( "\s+" );
1777           QString s = line.section( sep, 2, 2 ); // s == "surname"
1778
1779       If start or end is negative, we count fields from the right of the
1780       string, the right-most field being -1, the one from right-most field
1781       being -2, and so on.
1782
1783           QString line( "forename\tmiddlename  surname \t \t phone" );
1784           QRegExp sep( "\\s+" );
1785           QString s = line.section( sep, -3, -2 ); // s == "middlename  surname"
1786
1787       Warning: Using this QRegExp version is much more expensive than the
1788       overloaded string and character versions.
1789
1790       See also QStringList::split() and simplifyWhiteSpace().
1791

QString & QString::setAscii ( const char * str, int len = -1 )

1793       Sets this string to str, interpreted as a classic 8-bit ASCII C string.
1794       If len is -1 (the default), then it is set to strlen(str).
1795
1796       If str is 0 a null string is created. If str is "", an empty string is
1797       created.
1798
1799       See also isNull() and isEmpty().
1800

void QString::setExpand ( uint index, QChar c )

1802       This function is obsolete. It is provided to keep old source working.
1803       We strongly advise against using it in new code.
1804
1805       Sets the character at position index to c and expands the string if
1806       necessary, filling with spaces.
1807
1808       This method is redundant in Qt 3.x, because operator[] will expand the
1809       string as necessary.
1810

QString & QString::setLatin1 ( const char * str, int len = -1 )

1812       Sets this string to str, interpreted as a classic Latin-1 C string. If
1813       len is -1 (the default), then it is set to strlen(str).
1814
1815       If str is 0 a null string is created. If str is "", an empty string is
1816       created.
1817
1818       See also isNull() and isEmpty().
1819

void QString::setLength ( uint newLen )

1821       Ensures that at least newLen characters are allocated to the string,
1822       and sets the length of the string to newLen. Any new space allocated
1823       contains arbitrary data.
1824
1825       See also reserve() and truncate().
1826

QString & QString::setNum ( Q_LLONG n, int base = 10 )

1828       Sets the string to the printed value of n in base base and returns a
1829       reference to the string. The returned string is in "C" locale.
1830
1831       The base is 10 by default and must be between 2 and 36.
1832
1833               QString string;
1834               string = string.setNum( 1234 );     // string == "1234"
1835

QString & QString::setNum ( short n, int base = 10 )

1837       This is an overloaded member function, provided for convenience. It
1838       behaves essentially like the above function.
1839
1840       Sets the string to the printed value of n in base base and returns a
1841       reference to the string.
1842
1843       The base is 10 by default and must be between 2 and 36.
1844

QString & QString::setNum ( ushort n, int base = 10 )

1846       This is an overloaded member function, provided for convenience. It
1847       behaves essentially like the above function.
1848
1849       Sets the string to the printed value of n in base base and returns a
1850       reference to the string.
1851
1852       The base is 10 by default and must be between 2 and 36.
1853

QString & QString::setNum ( int n, int base = 10 )

1855       This is an overloaded member function, provided for convenience. It
1856       behaves essentially like the above function.
1857
1858       Sets the string to the printed value of n in base base and returns a
1859       reference to the string.
1860
1861       The base is 10 by default and must be between 2 and 36.
1862

QString & QString::setNum ( uint n, int base = 10 )

1864       This is an overloaded member function, provided for convenience. It
1865       behaves essentially like the above function.
1866
1867       Sets the string to the printed value of n in base base and returns a
1868       reference to the string.
1869
1870       The base is 10 by default and must be between 2 and 36.
1871

QString & QString::setNum ( long n, int base = 10 )

1873       This is an overloaded member function, provided for convenience. It
1874       behaves essentially like the above function.
1875

QString & QString::setNum ( ulong n, int base = 10 )

1877       This is an overloaded member function, provided for convenience. It
1878       behaves essentially like the above function.
1879

QString & QString::setNum ( Q_ULLONG n, int base = 10 )

1881       This is an overloaded member function, provided for convenience. It
1882       behaves essentially like the above function.
1883
1884       Sets the string to the printed value of n in base base and returns a
1885       reference to the string.
1886
1887       The base is 10 by default and must be between 2 and 36.
1888

QString & QString::setNum ( float n, char f = 'g', int prec = 6 )

1890       This is an overloaded member function, provided for convenience. It
1891       behaves essentially like the above function.
1892
1893       Sets the string to the printed value of n, formatted in format f with
1894       precision prec, and returns a reference to the string.
1895
1896       The format f can be 'f', 'F', 'e', 'E', 'g' or 'G'. See arg() for an
1897       explanation of the formats.
1898

QString & QString::setNum ( double n, char f = 'g', int prec = 6 )

1900       This is an overloaded member function, provided for convenience. It
1901       behaves essentially like the above function.
1902
1903       Sets the string to the printed value of n, formatted in format f with
1904       precision prec, and returns a reference to the string.
1905
1906       The format f can be 'f', 'F', 'e', 'E', 'g' or 'G'. See arg() for an
1907       explanation of the formats.
1908

QString & QString::setUnicode ( const QChar * unicode, uint len )

1910       Resizes the string to len characters and copies unicode into the
1911       string. If unicode is 0, nothing is copied, but the string is still
1912       resized to len. If len is zero, then the string becomes a null string.
1913
1914       See also setLatin1() and isNull().
1915

QString & QString::setUnicodeCodes ( const ushort * unicode_as_ushorts, uint

1917       len )
1918       Resizes the string to len characters and copies unicode_as_ushorts into
1919       the string (on some X11 client platforms this will involve a byte-
1920       swapping pass).
1921
1922       If unicode_as_ushorts is 0, nothing is copied, but the string is still
1923       resized to len. If len is zero, the string becomes a null string.
1924
1925       See also setLatin1() and isNull().
1926

QString QString::simplifyWhiteSpace () const

1928       Returns a string that has whitespace removed from the start and the
1929       end, and which has each sequence of internal whitespace replaced with a
1930       single space.
1931
1932       Whitespace means any character for which QChar::isSpace() returns TRUE.
1933       This includes Unicode characters with decimal values 9 (TAB), 10 (LF),
1934       11 (VT), 12 (FF), 13 (CR), and 32 (Space).
1935
1936               QString string = "  lots\t of\nwhite    space ";
1937               QString t = string.simplifyWhiteSpace();
1938               // t == "lots of white space"
1939
1940       See also stripWhiteSpace().
1941

QString & QString::sprintf ( const char * cformat, ... )

1943       Safely builds a formatted string from the format string cformat and an
1944       arbitrary list of arguments. The format string supports all the escape
1945       sequences of printf() in the standard C library.
1946
1947       The %s escape sequence expects a utf8() encoded string. The format
1948       string cformat is expected to be in latin1. If you need a Unicode
1949       format string, use arg() instead. For typesafe string building, with
1950       full Unicode support, you can use QTextOStream like this:
1951
1952               QString str;
1953               QString s = ...;
1954               int x = ...;
1955               QTextOStream( &str ) << s << " : " << x;
1956
1957       For translations, especially if the strings contains more than one
1958       escape sequence, you should consider using the arg() function instead.
1959       This allows the order of the replacements to be controlled by the
1960       translator, and has Unicode support.
1961
1962       The %lc escape sequence expects a unicode character of type ushort (as
1963       returned by QChar::unicode()). The %ls escape sequence expects a
1964       pointer to a zero-terminated array of unicode characters of type ushort
1965       (as returned by QString::ucs2()).
1966
1967       See also arg().
1968
1969       Examples:
1970

void QString::squeeze ()

1972       Squeezes the string's capacity to the current content.
1973
1974       See also capacity() and reserve().
1975

bool QString::startsWith ( const QString & s, bool cs = TRUE ) const

1977       Returns TRUE if the string starts with s; otherwise returns FALSE.
1978
1979       If cs is TRUE (the default), the search is case sensitive; otherwise
1980       the search is case insensitive.
1981
1982               QString str( "Bananas" );
1983               str.startsWith( "Ban" );     // returns TRUE
1984               str.startsWith( "Car" );     // returns FALSE
1985
1986       See also endsWith().
1987

QString QString::stripWhiteSpace () const

1989       Returns a string that has whitespace removed from the start and the
1990       end.
1991
1992       Whitespace means any character for which QChar::isSpace() returns TRUE.
1993       This includes Unicode characters with decimal values 9 (TAB), 10 (LF),
1994       11 (VT), 12 (FF), 13 (CR) and 32 (Space), and may also include other
1995       Unicode characters.
1996
1997               QString string = "   white space   ";
1998               QString s = string.stripWhiteSpace();       // s == "white space"
1999
2000       See also simplifyWhiteSpace().
2001

double QString::toDouble ( bool * ok = 0 ) const

2003       Returns the string converted to a double value.
2004
2005       If ok is not 0: if a conversion error occurs, *ok is set to FALSE;
2006       otherwise *ok is set to TRUE.
2007
2008               QString string( "1234.56" );
2009               double a = string.toDouble();   // a == 1234.56
2010
2011       The string-to-number functions:
2012
2013       toShort()
2014
2015       toUShort()
2016
2017       toInt()
2018
2019       toUInt()
2020
2021       toLong()
2022
2023       toULong()
2024
2025       toLongLong()
2026
2027       toULongLong()
2028
2029       toFloat()
2030
2031       toDouble() can handle numbers represented in various locales. These
2032       representations may use different characters for the decimal point,
2033       thousands group sepearator and even individual digits. QString's
2034       functions try to interpret the string according to the current locale.
2035       The current locale is determined from the system at application startup
2036       and can be changed by calling QLocale::setDefault(). If the string
2037       cannot be interpreted according to the current locale, this function
2038       falls back on the "C" locale.
2039
2040               bool ok;
2041               double d;
2042               QLocale::setDefault(QLocale::C);
2043               d = QString( "1234,56" ).toDouble(&ok); // ok == false
2044               d = QString( "1234.56" ).toDouble(&ok); // ok == true, d == 1234.56
2045               QLocale::setDefault(QLocale::German);
2046               d = QString( "1234,56" ).toDouble(&ok); // ok == true, d == 1234.56
2047               d = QString( "1234.56" ).toDouble(&ok); // ok == true, d == 1234.56
2048
2049       Due to the ambiguity between the decimal point and thousands group
2050       separator in various locales, these functions do not handle thousands
2051       group separators. If you need to convert such numbers, use the
2052       corresponding function in QLocale.
2053
2054               bool ok;
2055               QLocale::setDefault(QLocale::C);
2056               double d = QString( "1,234,567.89" ).toDouble(&ok); // ok == false
2057
2058       Warning: If the string contains trailing whitespace this function will
2059       fail, and set *ok to false if ok is not 0. Leading whitespace is
2060       ignored.
2061
2062       See also number(), QLocale::setDefault(), QLocale::toDouble(), and
2063       stripWhiteSpace().
2064

float QString::toFloat ( bool * ok = 0 ) const

2066       Returns the string converted to a float value.
2067
2068       Returns 0.0 if the conversion fails.
2069
2070       If ok is not 0: if a conversion error occurs, *ok is set to FALSE;
2071       otherwise *ok is set to TRUE.
2072
2073       For information on how string-to-number functions in QString handle
2074       localized input, see toDouble().
2075
2076       Warning: If the string contains trailing whitespace this function will
2077       fail, settings *ok to false if ok is not 0. Leading whitespace is
2078       ignored.
2079
2080       See also number().
2081

int QString::toInt ( bool * ok = 0, int base = 10 ) const

2083       Returns the string converted to an int using base base, which is 10 by
2084       default and must be between 2 and 36 or 0. If base is 0, the base is
2085       determined automatically using the following rules:
2086
2087       If the string begins with "0x", it is assumed to be hexadecimal;
2088
2089       If it begins with "0", it is assumed to be octal;
2090
2091       Otherwise it is assumed to be decimal.
2092
2093       Returns 0 if the conversion fails.
2094
2095       If ok is not 0: if a conversion error occurs, *ok is set to FALSE;
2096       otherwise *ok is set to TRUE.
2097
2098               QString str( "FF" );
2099               bool ok;
2100               int hex = str.toInt( &ok, 16 );     // hex == 255, ok == TRUE
2101               int dec = str.toInt( &ok, 10 );     // dec == 0, ok == FALSE
2102
2103       Leading and trailing whitespace is ignored by this function.
2104
2105       For information on how string-to-number functions in QString handle
2106       localized input, see toDouble().
2107
2108       See also number().
2109

long QString::toLong ( bool * ok = 0, int base = 10 ) const

2111       Returns the string converted to a long using base base, which is 10 by
2112       default and must be between 2 and 36 or 0. If base is 0, the base is
2113       determined automatically using the following rules:
2114
2115       If the string begins with "0x", it is assumed to be hexadecimal;
2116
2117       If it begins with "0", it is assumed to be octal;
2118
2119       Otherwise it is assumed to be decimal.
2120
2121       Returns 0 if the conversion fails.
2122
2123       If ok is not 0: if a conversion error occurs, *ok is set to FALSE;
2124       otherwise *ok is set to TRUE.
2125
2126       Leading and trailing whitespace is ignored by this function.
2127
2128       For information on how string-to-number functions in QString handle
2129       localized input, see toDouble().
2130
2131       See also number().
2132

Q_LLONG QString::toLongLong ( bool * ok = 0, int base = 10 ) const

2134       Returns the string converted to a long long using base base, which is
2135       10 by default and must be between 2 and 36 or 0. If base is 0, the base
2136       is determined automatically using the following rules:
2137
2138       If the string begins with "0x", it is assumed to be hexadecimal;
2139
2140       If it begins with "0", it is assumed to be octal;
2141
2142       Otherwise it is assumed to be decimal.
2143
2144       Returns 0 if the conversion fails.
2145
2146       If ok is not 0: if a conversion error occurs, *ok is set to FALSE;
2147       otherwise *ok is set to TRUE.
2148
2149       Leading and trailing whitespace is ignored by this function.
2150
2151       For information on how string-to-number functions in QString handle
2152       localized input, see toDouble().
2153
2154       See also number().
2155

short QString::toShort ( bool * ok = 0, int base = 10 ) const

2157       Returns the string converted to a short using base base, which is 10 by
2158       default and must be between 2 and 36 or 0. If base is 0, the base is
2159       determined automatically using the following rules:
2160
2161       If the string begins with "0x", it is assumed to be hexadecimal;
2162
2163       If it begins with "0", it is assumed to be octal;
2164
2165       Otherwise it is assumed to be decimal.
2166
2167       Returns 0 if the conversion fails.
2168
2169       If ok is not 0: if a conversion error occurs, *ok is set to FALSE;
2170       otherwise *ok is set to TRUE.
2171
2172       Leading and trailing whitespace is ignored by this function.
2173
2174       For information on how string-to-number functions in QString handle
2175       localized input, see toDouble().
2176
2177       See also number().
2178

uint QString::toUInt ( bool * ok = 0, int base = 10 ) const

2180       Returns the string converted to an unsigned int using base base, which
2181       is 10 by default and must be between 2 and 36 or 0. If base is 0, the
2182       base is determined automatically using the following rules:
2183
2184       If the string begins with "0x", it is assumed to be hexadecimal;
2185
2186       If it begins with "0", it is assumed to be octal;
2187
2188       Otherwise it is assumed to be decimal.
2189
2190       Returns 0 if the conversion fails.
2191
2192       If ok is not 0: if a conversion error occurs, *ok is set to FALSE;
2193       otherwise *ok is set to TRUE.
2194
2195       Leading and trailing whitespace is ignored by this function.
2196
2197       For information on how string-to-number functions in QString handle
2198       localized input, see toDouble().
2199
2200       See also number().
2201

ulong QString::toULong ( bool * ok = 0, int base = 10 ) const

2203       Returns the string converted to an unsigned long using base base, which
2204       is 10 by default and must be between 2 and 36 or 0. If base is 0, the
2205       base is determined automatically using the following rules:
2206
2207       If the string begins with "0x", it is assumed to be hexadecimal;
2208
2209       If it begins with "0", it is assumed to be octal;
2210
2211       Otherwise it is assumed to be decimal.
2212
2213       Returns 0 if the conversion fails.
2214
2215       If ok is not 0: if a conversion error occurs, *ok is set to FALSE;
2216       otherwise *ok is set to TRUE.
2217
2218       Leading and trailing whitespace is ignored by this function.
2219
2220       For information on how string-to-number functions in QString handle
2221       localized input, see toDouble().
2222
2223       See also number().
2224

Q_ULLONG QString::toULongLong ( bool * ok = 0, int base = 10 ) const

2226       Returns the string converted to an unsigned long long using base base,
2227       which is 10 by default and must be between 2 and 36 or 0. If base is 0,
2228       the base is determined automatically using the following rules:
2229
2230       If the string begins with "0x", it is assumed to be hexadecimal;
2231
2232       If it begins with "0", it is assumed to be octal;
2233
2234       Otherwise it is assumed to be decimal.
2235
2236       Returns 0 if the conversion fails.
2237
2238       If ok is not 0: if a conversion error occurs, *ok is set to FALSE;
2239       otherwise *ok is set to TRUE.
2240
2241       Leading and trailing whitespace is ignored by this function.
2242
2243       For information on how string-to-number functions in QString handle
2244       localized input, see toDouble().
2245
2246       See also number().
2247

ushort QString::toUShort ( bool * ok = 0, int base = 10 ) const

2249       Returns the string converted to an unsigned short using base base,
2250       which is 10 by default and must be between 2 and 36 or 0. If base is 0,
2251       the base is determined automatically using the following rules:
2252
2253       If the string begins with "0x", it is assumed to be hexadecimal;
2254
2255       If it begins with "0", it is assumed to be octal;
2256
2257       Otherwise it is assumed to be decimal.
2258
2259       Returns 0 if the conversion fails.
2260
2261       If ok is not 0: if a conversion error occurs, *ok is set to FALSE;
2262       otherwise *ok is set to TRUE.
2263
2264       Leading and trailing whitespace is ignored by this function.
2265
2266       For information on how string-to-number functions in QString handle
2267       localized input, see toDouble().
2268
2269       See also number().
2270

void QString::truncate ( uint newLen )

2272       If newLen is less than the length of the string, then the string is
2273       truncated at position newLen. Otherwise nothing happens.
2274
2275               QString s = "truncate me";
2276               s.truncate( 5 );            // s == "trunc"
2277
2278       See also setLength().
2279
2280       Example: network/mail/smtp.cpp.
2281

const unsigned short * QString::ucs2 () const

2283       Returns the QString as a zero terminated array of unsigned shorts if
2284       the string is not null; otherwise returns zero.
2285
2286       The result remains valid so long as one unmodified copy of the source
2287       string exists.
2288
2289       Example: dotnet/wrapper/lib/tools.cpp.
2290

const QChar * QString::unicode () const

2292       Returns the Unicode representation of the string. The result remains
2293       valid until the string is modified.
2294

QString QString::upper () const

2296       Returns an uppercase copy of the string.
2297
2298               QString string( "TeXt" );
2299               str = string.upper();     // t == "TEXT"
2300
2301       See also lower().
2302
2303       Examples:
2304

QCString QString::utf8 () const

2306       Returns the string encoded in UTF-8 format.
2307
2308       See QTextCodec for more diverse coding/decoding of Unicode strings.
2309
2310       See also fromUtf8(), ascii(), latin1(), and local8Bit().
2311
2312       Example: network/archivesearch/archivedialog.ui.h.
2313

bool operator!= ( const QString & s1, const QString & s2 )

2316       Returns TRUE if s1 is not equal to s2; otherwise returns FALSE. Note
2317       that a null string is not equal to a not-null empty string.
2318
2319       Equivalent to compare(s1, s2) != 0.
2320
2321       See also isNull() and isEmpty().
2322

bool operator!= ( const QString & s1, const char * s2 )

2324       This is an overloaded member function, provided for convenience. It
2325       behaves essentially like the above function.
2326
2327       Returns TRUE if s1 is not equal to s2; otherwise returns FALSE. Note
2328       that a null string is not equal to a not-null empty string.
2329
2330       Equivalent to compare(s1, s2) != 0.
2331
2332       See also isNull() and isEmpty().
2333

bool operator!= ( const char * s1, const QString & s2 )

2335       This is an overloaded member function, provided for convenience. It
2336       behaves essentially like the above function.
2337
2338       Returns TRUE if s1 is not equal to s2; otherwise returns FALSE. Note
2339       that a null string is not equal to a not-null empty string.
2340
2341       Equivalent to compare(s1, s2) != 0.
2342
2343       See also isNull() and isEmpty().
2344

const QString operator+ ( const QString & s1, const QString & s2 )

2346       Returns a string which is the result of concatenating the string s1 and
2347       the string s2.
2348
2349       Equivalent to s1.append(s2).
2350

const QString operator+ ( const QString & s1, const char * s2 )

2352       This is an overloaded member function, provided for convenience. It
2353       behaves essentially like the above function.
2354
2355       Returns a string which is the result of concatenating the string s1 and
2356       character s2.
2357
2358       Equivalent to s1.append(s2).
2359

const QString operator+ ( const char * s1, const QString & s2 )

2361       This is an overloaded member function, provided for convenience. It
2362       behaves essentially like the above function.
2363
2364       Returns a string which is the result of concatenating the character s1
2365       and string s2.
2366

const QString operator+ ( const QString & s, char c )

2368       This is an overloaded member function, provided for convenience. It
2369       behaves essentially like the above function.
2370
2371       Returns a string which is the result of concatenating the string s and
2372       character c.
2373
2374       Equivalent to s.append(c).
2375

const QString operator+ ( char c, const QString & s )

2377       This is an overloaded member function, provided for convenience. It
2378       behaves essentially like the above function.
2379
2380       Returns a string which is the result of concatenating the character c
2381       and string s.
2382
2383       Equivalent to s.prepend(c).
2384

bool operator< ( const QString & s1, const char * s2 )

2386       Returns TRUE if s1 is lexically less than s2; otherwise returns FALSE.
2387       The comparison is case sensitive.
2388
2389       Equivalent to compare(s1, s2) < 0.
2390

bool operator< ( const char * s1, const QString & s2 )

2392       This is an overloaded member function, provided for convenience. It
2393       behaves essentially like the above function.
2394
2395       Returns TRUE if s1 is lexically less than s2; otherwise returns FALSE.
2396       The comparison is case sensitive.
2397
2398       Equivalent to compare(s1, s2) < 0.
2399

QDataStream & operator<< ( QDataStream & s, const QString & str )

2401       Writes the string str to the stream s.
2402
2403       See also Format of the QDataStream operators
2404

bool operator<= ( const QString & s1, const char * s2 )

2406       Returns TRUE if s1 is lexically less than or equal to s2; otherwise
2407       returns FALSE. The comparison is case sensitive. Note that a null
2408       string is not equal to a not-null empty string.
2409
2410       Equivalent to compare(s1,s2) <= 0.
2411
2412       See also isNull() and isEmpty().
2413

bool operator<= ( const char * s1, const QString & s2 )

2415       This is an overloaded member function, provided for convenience. It
2416       behaves essentially like the above function.
2417
2418       Returns TRUE if s1 is lexically less than or equal to s2; otherwise
2419       returns FALSE. The comparison is case sensitive. Note that a null
2420       string is not equal to a not-null empty string.
2421
2422       Equivalent to compare(s1, s2) <= 0.
2423
2424       See also isNull() and isEmpty().
2425

bool operator== ( const QString & s1, const QString & s2 )

2427       Returns TRUE if s1 is equal to s2; otherwise returns FALSE. Note that a
2428       null string is not equal to a not-null empty string.
2429
2430       Equivalent to compare(s1, s2) == 0.
2431
2432       See also isNull() and isEmpty().
2433

bool operator== ( const QString & s1, const char * s2 )

2435       This is an overloaded member function, provided for convenience. It
2436       behaves essentially like the above function.
2437
2438       Returns TRUE if s1 is equal to s2; otherwise returns FALSE. Note that a
2439       null string is not equal to a not-null empty string.
2440
2441       Equivalent to compare(s1, s2) == 0.
2442
2443       See also isNull() and isEmpty().
2444

bool operator== ( const char * s1, const QString & s2 )

2446       This is an overloaded member function, provided for convenience. It
2447       behaves essentially like the above function.
2448
2449       Returns TRUE if s1 is equal to s2; otherwise returns FALSE. Note that a
2450       null string is not equal to a not-null empty string.
2451
2452       Equivalent to compare(s1, s2) == 0.
2453
2454       See also isNull() and isEmpty().
2455

bool operator> ( const QString & s1, const char * s2 )

2457       Returns TRUE if s1 is lexically greater than s2; otherwise returns
2458       FALSE. The comparison is case sensitive.
2459
2460       Equivalent to compare(s1, s2) > 0.
2461

bool operator> ( const char * s1, const QString & s2 )

2463       This is an overloaded member function, provided for convenience. It
2464       behaves essentially like the above function.
2465
2466       Returns TRUE if s1 is lexically greater than s2; otherwise returns
2467       FALSE. The comparison is case sensitive.
2468
2469       Equivalent to compare(s1, s2) > 0.
2470

bool operator>= ( const QString & s1, const char * s2 )

2472       Returns TRUE if s1 is lexically greater than or equal to s2; otherwise
2473       returns FALSE. The comparison is case sensitive. Note that a null
2474       string is not equal to a not-null empty string.
2475
2476       Equivalent to compare(s1, s2) >= 0.
2477
2478       See also isNull() and isEmpty().
2479

bool operator>= ( const char * s1, const QString & s2 )

2481       This is an overloaded member function, provided for convenience. It
2482       behaves essentially like the above function.
2483
2484       Returns TRUE if s1 is lexically greater than or equal to s2; otherwise
2485       returns FALSE. The comparison is case sensitive. Note that a null
2486       string is not equal to a not-null empty string.
2487
2488       Equivalent to compare(s1, s2) >= 0.
2489
2490       See also isNull() and isEmpty().
2491

QDataStream & operator>> ( QDataStream & s, QString & str )

2493       Reads a string from the stream s into string str.
2494
2495       See also Format of the QDataStream operators
2496
2497

SEE ALSO

2499       http://doc.trolltech.com/qstring.html
2500       http://www.trolltech.com/faq/tech.html
2501
2503       Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com.  See the
2504       license file included in the distribution for a complete license
2505       statement.
2506

AUTHOR

2508       Generated automatically from the source code.
2509

BUGS

2511       If you find a bug in Qt, please report it as described in
2512       http://doc.trolltech.com/bughowto.html.  Good bug reports help us to
2513       help you. Thank you.
2514
2515       The definitive Qt documentation is provided in HTML format; it is
2516       located at $QTDIR/doc/html and can be read using Qt Assistant or with a
2517       web browser. This man page is provided as a convenience for those users
2518       who prefer man pages, although this format is not officially supported
2519       by Trolltech.
2520
2521       If you find errors in this manual page, please report them to qt-
2522       bugs@trolltech.com.  Please include the name of the manual page
2523       (qstring.3qt) and the Qt version (3.3.8).
2524
2525
2526
2527Trolltech AS                    2 February 2007                   QString(3qt)
Impressum