Qt logo

QString Class Reference


The QString class provides an abstraction of Unicode text and the classic C zero-terminated char array (char*). More...

#include <qstring.h>

Inherited by QConstString.

List of all member functions.

Public Members

Static Public Members

Related Functions

(Note that these are not member functions.)

Detailed Description

The QString class provides an abstraction of Unicode text and the classic C zero-terminated char array (char*).

QString uses implicit sharing, and so it is very efficient and easy to use.

In all QString methods that take const char* parameters, the const char* is interpreted as a classic C-style 0-terminated ASCII string. It is legal for the const char* parameter to be 0. The results are undefined if the const char* string is not 0-terminated. Functions that copy classic C strings into a QString will not copy the terminating 0-character. The QChar array of the QString (as returned by unicode()) is not terminated by a null.

A QString that has not been assigned to anything is null, i.e. both the length and data pointer is 0. A QString that references the empty string ("", a single '\0' char) is empty. Both null and empty QStrings are legal parameters to the methods. Assigning const char * 0 to QString gives a null QString.

Note that if you find that you are mixing usage of QCString, QString, and QByteArray, this causes lots of unnecessary copying and might indicate that the true nature of the data you are dealing with is uncertain. If the data is NUL-terminates 8-bit data, use QCString; if it is unterminated (ie. contains NULs) 8-bit daya, use QByteArray; if it is text, use QString.

See also: Shared classes

Examples: qdir/qdir.cpp showimg/main.cpp tabdialog/tabdialog.cpp grapher/grapher.cpp xform/xform.cpp layout/layout.cpp i18n/main.cpp drawdemo/drawdemo.cpp popup/popup.cpp progress/progress.cpp qmag/qmag.cpp table/main.cpp forever/forever.cpp rot13/rot13.cpp desktop/desktop.cpp scrollview/scrollview.cpp movies/main.cpp picture/picture.cpp hello/main.cpp qbrowser/main.cpp


Member Function Documentation

QString::QString()

Constructs a null string.

See also: isNull().

QString::QString(QCharch)

Constructs a string containing the one character ch.

QString::QString(constQChar*unicode, uintlength)

Constructs a string that is a deep copy of the first length QChar in the array unicode.

See also: QString::make().

QString::QString(constQByteArray&ba)

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

QString::QString(constQString&s)

Constructs an implicitly-shared copy of s.

QString&QString::append(charch)

Appends ch to the string and returns a reference to the result. Equivalent to operator+=().

QString&QString::append(constQString&str)

Appends str to the string and returns a reference to the result. Equivalent to operator+=().

QStringQString::arg(QChara, intfieldwidth=0)const

Returns a string equal to this one, but with the first occurrence of %digit replaced by the character a.

See arg(const QString&,int) for more details.

QStringQString::arg(chara, intfieldwidth=0)const

Returns a string equal to this one, but with the first occurrence of %digit replaced by the character a.

See arg(const QString&,int) for more details.

QStringQString::arg(constQString&a, intfieldwidth=0)const

Returns a string equal to this one, but with the first occurrence of %digit replaced by the text a. This is particularly useful for translations, as it allows the order of the replacements to be controlled by the translator. For example:

    label.setText( tr("I have %1 to your %2").arg(mine).arg(yours) );

If there is no %digit pattern, a warning message (qWarning()) is printed and the text as appended with a space at the end of the string. This is error-recovery and should not be occur in correct code.

fieldwidth is the minimum amount of space the text will be padded to. A positive value produces right-aligned text, while a negative value produces left aligned text.

See also: QObject::tr().

QStringQString::arg(doublea, intfieldwidth=0, charfmt='g', intprec=-1)const

Returns a string equal to this one, but with the first occurrence of %digit replaced by the value a.

See arg(const QString&,int) for more details.

QStringQString::arg(inta, intfieldwidth=0, intbase=10)const

See QString::arg(long a, int fieldwidth, int base).

QStringQString::arg(longa, intfieldwidth=0, intbase=10)const

Returns a string equal to this one, but with the first occurrence of %digit replaced by the integer value in base base (defaults to decimal).

The value is converted to base notation (default is decimal). The base must be a value from 2 to 36.

See arg(const QString&,int) for more details.

QStringQString::arg(shorta, intfieldwidth=0, intbase=10)const

See QString::arg(long a, int fieldwidth, int base).

QStringQString::arg(uinta, intfieldwidth=0, intbase=10)const

See QString::arg(ulong a, int fieldwidth, int base).

QStringQString::arg(ulonga, intfieldwidth=0, intbase=10)const

Returns a string equal to this one, but with the first occurrence of %digit replaced by the unsigned integer value in base base (defaults to decimal).

The value is converted to base notation (default is decimal). The base must be a value from 2 to 36.

See arg(const QString&,int) for more details.

QStringQString::arg(ushorta, intfieldwidth=0, intbase=10)const

See QString::arg(ulong a, int fieldwidth, int base).

QCharQString::at(uint)const

Returns the character at i, or 0 if i is beyond the length of the string.

Note: If this QString is not const or const&, the non-const at() will be used instead, which will expand the string if i is beyond the length of the string.

QCharRefQString::at(uinti)

Returns a reference to the character at i, expanding the string with QChar::null if necessary. The resulting reference can then be assigned to, or otherwise used immediately, but becomes invalid once further modifications are made to the string.

QChar::DirectionQString::basicDirection()

This function returns the basic directionality of the string (QChar::DirR for right to left and QChar::DirL for left to right). Useful to find the right alignment.

intQString::compare(constQString&s)const

Compares this string to s, returning an integer less than, equal to, or greater than zero if it is, respectively, lexically less than, equal to, or greater than s.

intQString::compare(constQString&s1, constQString&s2) [static]

Compare s1 to s2 returning an integer less than, equal to, or greater than zero if s1 is, respectively, lexically less than, equal to, or greater than s2.

voidQString::compose()

Note that this function is not supported in Qt 2.0, and is merely for experimental and illustrative purposes. It is mainly of interest to those experimenting with Arabic and other composition-rich texts.

Applies possible ligatures to a QString, useful when composition-rich text requires rendering with glyph-poor fonts, but also makes compositions such as QChar(0x0041) ('A') and QChar(0x0308) (Unicode accent diaresis) giving QChar(0x00c4) (German A Umlaut).

QCharQString::constref(uinti)const

Equivalent to at(i), this returns the QChar at i by value.

See also: ref().

intQString::contains(QCharc, boolcs=TRUE)const

Returns the number of times the character c occurs in the string.

The match is case sensitive if cs is TRUE, or case insensitive if cs if FALSE.

intQString::contains(constQRegExp&rx)const

Counts the number of overlapping occurrences of rx in the string.

Example:

    QString s = "banana and panama";
    QRegExp r = QRegExp("a[nm]a", TRUE, FALSE);
    s.contains( r );                            // 4 matches

See also: find() and findRev().

intQString::contains(constQString&str, boolcs=TRUE)const

Returns the number of times str occurs in the string.

The match is case sensitive if cs is TRUE, or case insensitive if cs if FALSE.

This function counts overlapping substrings, for example, "banana" contains two occurrences of "ana".

See also: findRev().

intQString::contains(charc, boolcs=TRUE)const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

QStringQString::copy()const

This function is obsolete. It is provided to keep old programs working. We strongly advise against using it in new code.

Returns a deep copy of this string.

Doing this is redundant in Qt 2.x, since QString is implicitly shared, and so will automatically be deeply copied as necessary.

voidQString::fill(QCharc, intlen=-1)

Fills the string with len characters of value c.

If len is negative, the current string length is used.

intQString::find(QCharc, intindex=0, boolcs=TRUE)const

Finds the first occurrence of the character c, starting at position index.

The search is case sensitive if cs is TRUE, or case insensitive if cs is FALSE.

Returns the position of c, or -1 if c could not be found.

intQString::find(constQRegExp&rx, intindex=0)const

Finds the first occurrence of the regular expression rx, starting at position index.

Returns the position of the next match, or -1 if rx was not found.

intQString::find(constQString&str, intindex=0, boolcs=TRUE)const

Finds the first occurrence of the string str, starting at position index.

The search is case sensitive if cs is TRUE, or case insensitive if cs is FALSE.

Returns the position of str, or -1 if str could not be found.

intQString::find(charc, intindex=0, boolcs=TRUE)const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

intQString::findRev(QCharc, intindex=-1, boolcs=TRUE)const

Finds the first occurrence of the character c, starting at position index and searching backwards. If index is negative, the search starts at the end.

The search is case sensitive if cs is TRUE, or case insensitive if cs is FALSE.

Returns the position of c, or -1 if c could not be found.

intQString::findRev(constQRegExp&rx, intindex=-1)const

Finds the first occurrence of the regular expression rx, starting at position index and searching backwards. If index is negative, the search starts at the end of this string.

Returns the position of the next match (backwards), or -1 if rx was not found.

intQString::findRev(constQString&str, intindex=-1, boolcs=TRUE)const

Finds the first occurrence of the string str, starting at position index and searching backwards. If index is negative, the search starts at the end.

The search is case sensitive if cs is TRUE, or case insensitive if cs is FALSE.

Returns the position of str, or -1 if str could not be found.

intQString::findRev(charc, intindex=-1, boolcs=TRUE)const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

QStringQString::fromLatin1(constchar*chars, intlen=-1) [static]

Creates a QString from Latin1 text. This is the same as the QString(const char*) constructor, but you can make that constructor invisible if you compile with the define QT_NO_CAST_ASCII, in which case you can explicitly create a QString from Latin-1 text using this function.

QStringQString::fromLocal8Bit(constchar*local8Bit, intlen=-1) [static]

Returns the unicode string decoded from the first len bytes of local8Bit. If len is -1 (the default), the length of local8Bit is used. If trailing partial characters are in local8Bit, they are ignored.

local8Bit is assumed to be encoded in a locale-specific format.

See QTextCodec for more diverse coding/decoding of Unicode strings.

QStringQString::fromUtf8(constchar*utf8, intlen=-1) [static]

Returns the unicode string decoded from the first len bytes of utf8. If len is -1 (the default), the length of utf8 is used. If trailing partial characters are in utf8, they are ignored.

See QTextCodec for more diverse coding/decoding of Unicode strings.

QString&QString::insert(uintindex, QCharc)

Insert c into the string at (before) position index and returns a reference to the string.

If index is beyond the end of the string, the string is extended with spaces (ASCII 32) to length index and c is then appended.

Example:

    QString s = "Ys";
    s.insert( 1, 'e' );                         // s == "Yes"
    s.insert( 3, '!');                          // s == "Yes!"

See also: remove() and replace().

Examples: xform/xform.cpp

QString&QString::insert(uintindex, constQChar*s, uintlen)

Insert len units of QChar data from s into the string before position index.

QString&QString::insert(uintindex, constQString&s)

Insert s into the string before position index.

If index is beyond the end of the string, the string is extended with spaces (ASCII 32) to length index and s is then appended.

    QString s = "I like fish";
    s.insert( 2, "don't ");                     // s == "I don't like fish"
    s = "x";
    s.insert( 3, "yz" );                        // s == "x  yz"

QString&QString::insert(uintindex, charc)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

boolQString::isEmpty()const

Returns TRUE if the string is empty, i.e. if length() == 0. An empty string is not always a null string.

See example in isNull().

See also: isNull() and length().

Examples: qmag/qmag.cpp hello/main.cpp

boolQString::isNull()const

Returns TRUE if the string is null. A null string is also an empty string.

Example:

    QString a;          // a.unicode() == 0,  a.length() == 0
    QString b == "";    // b.unicode() == "", b.length() == 0
    a.isNull();         // TRUE, because a.unicode() == 0
    a.isEmpty();        // TRUE, because a.length() == 0
    b.isNull();         // FALSE, because b.unicode() != 0
    b.isEmpty();        // TRUE, because b.length() == 0

See also: isEmpty() and length().

Examples: qdir/qdir.cpp

constchar*QString::latin1()const

Returns a Latin-1 representation of the string. Note that the returned value is undefined if the string contains non-Latin-1 characters. If you want to convert strings into formats other than Unicode, see the QTextCodec classes.

This function is mainly useful for boot-strapping legacy code to use Unicode.

The result remains valid so long as one unmodified copy of the string exists.

See also: utf8() and local8Bit().

QStringQString::left(uintlen)const

Returns a substring that contains the len leftmost characters of the string.

The whole string is returned if len exceeds the length of the string.

Example:

    QString s = "Pineapple";
    QString t = s.left( 4 );                    // t == "Pine"

See also: right(), mid() and isEmpty().

QStringQString::leftJustify(uintwidth, QCharfill='', booltruncate=FALSE)const

Returns a string of length width that contains this string and padded by the fill character.

If the length of the string exceeds width and truncate is FALSE, then the returned string is a copy of the string. If the length of the string exceeds width and truncate is TRUE, then the returned string is a left(width).

Example:

    QString s("apple");
    QString t = s.leftJustify(8, '.');          // t == "apple..."

See also: rightJustify().

uintQString::length()const

Returns the length of the string.

Null strings and empty strings have zero length.

See also: isNull() and isEmpty().

QCStringQString::local8Bit()const

Returns the string encoded in a locale-specific format. On X11, this is the QTextCodec::codecForLocale(). On Windows, it is a system-defined encoding.

See QTextCodec for more diverse coding/decoding of Unicode strings.

See also: QString::fromLocal8Bit(), local8Bit() and utf8().

QStringQString::lower()const

Returns a new string that is the string converted to lower case.

Example:

    QString s("TeX");
    QString t = s.lower();                      // t == "tex"

See also: upper().

QStringQString::mid(uintindex, uintlen=0xffffffff)const

Returns a substring that contains the len characters of this string, starting at position index.

Returns a null string if the string is empty or index is out of range. Returns the whole string from index if index+len exceeds the length of the string.

Example:

    QString s = "Two pineapples";
    QString t = s.mid( 4, 4 );                  // t == "pine"

See also: left() and right().

Examples: qmag/qmag.cpp

QStringQString::number(doublen, charf='g', intprec=6) [static]

A convenience factory function that returns a string representation of the number n.

Arguments:

See also: setNum().

QStringQString::number(intn, intbase=10) [static]

A convenience factory function that returns a string representation of the number n.

See also: setNum().

QStringQString::number(longn, intbase=10) [static]

A convenience factory function that returns a string representation of the number n.

See also: setNum().

QStringQString::number(uintn, intbase=10) [static]

A convenience factory function that returns a string representation of the number n.

See also: setNum().

QStringQString::number(ulongn, intbase=10) [static]

A convenience factory function that returns a string representation of the number n.

See also: setNum().

boolQString::operator!()const

Returns TRUE if it is a null string, otherwise FALSE. Thus you can write:

  QString name = getName();
  if ( !name )
    name = "Rodney";

Note that if you say:

  QString name = getName();
  if ( name )
    doSomethingWith(name);

Then this will call operator const char*(), which will do what you want, but rather inefficiently - you may wish to define the macro QT_NO_ASCII_CAST when writing code which you wish to strictly remain Unicode-clean.

When you want the above semantics, use !isNull() or even !!:

  QString name = getName();
  if ( !!name )
    doSomethingWith(name);

QString&QString::operator+=(QCharc)

Appends c to the string and returns a reference to the string.

QString&QString::operator+=(charc)

Appends c to the string and returns a reference to the string.

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

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

QString&QString::operator=(constQCString&cs)

Assigns a deep copy of cs, interpretted a classic C string, to this string and returns a reference to this string.

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

Assigns a shallow copy of s to this string and returns a reference to this string.

QString&QString::operator=(QCharc)

Sets the string to contain just the single character c.

QString&QString::operator=(charc)

Sets the string to contain just the single character c.

QCharQString::operator[](int)const

Returns the character at i, or QChar::null if i is beyond the length of the string.

Note: If this QString is not const or const&, the non-const operator[] will be used instead, which will expand the string if i is beyond the length of the string.

QCharRefQString::operator[](int)

Returns an object that references the character at i. This reference can then be assigned to, or otherwise used immediately, but becomes invalid once further modifications are made to the string. The QCharRef internal class can be used much like a constant QChar, but if you assign to it, you change the original string (which enlarges and detaches itself). You will get compilation errors if you try to use the result as anything but a QChar.

QString&QString::prepend(constQString&s)

Prepend s to the string. Equivalent to insert(0,s).

See also: insert().

QString&QString::prepend(charch)

Prepends ch to the string and returns a reference to the result.

See also: insert().

QChar&QString::ref(uinti)

Returns the QChar at i by reference.

See also: constref().

QString&QString::remove(uintindex, uintlen)

Removes len characters starting at position index from the string and returns a reference to the string.

If index is too big, nothing happens. If index is valid, but len is too large, the rest of the string is removed.

    QString s = "Montreal";
    s.remove( 1, 4 );
    // s == "Meal"

See also: insert() and replace().

QString&QString::replace(constQRegExp&rx, constQString&str)

Replaces every occurrence of rx in the string with str. Returns a reference to the string.

Examples:

    QString s = "banana";
    s.replace( QRegExp("a.*a"), "" );           // becomes "b"

    QString s = "banana";
    s.replace( QRegExp("^[bn]a"), " " );        // becomes " nana"

    QString s = "banana";
    s.replace( QRegExp("^[bn]a"), "" );         // NOTE! becomes ""

QString&QString::replace(uintindex, uintlen, constQChar*s, uintslen)

Replaces len characters starting at position index by slen units ot QChar data from s, and returns a reference to the string.

See also: insert() and remove().

QString&QString::replace(uintindex, uintlen, constQString&s)

Replaces len characters starting at position index from the string with s, and returns a reference to the string.

If index is too big, nothing is deleted and s is inserted at the end of the string. If index is valid, but len is too large, str replaces the rest of the string.

    QString s = "Say yes!";
    s.replace( 4, 3, "NO" );                    // s == "Say NO!"

See also: insert() and remove().

Examples: qmag/qmag.cpp

QStringQString::right(uintlen)const

Returns a substring that contains the len rightmost characters of the string.

The whole string is returned if len exceeds the length of the string.

Example:

    QString s = "Pineapple";
    QString t = s.right( 5 );                   // t == "apple"

See also: left(), mid() and isEmpty().

QStringQString::rightJustify(uintwidth, QCharfill='', booltruncate=FALSE)const

Returns a string of length width that contains pad characters followed by the string.

If the length of the string exceeds width and truncate is FALSE, then the returned string is a copy of the string. If the length of the string exceeds width and truncate is TRUE, then the returned string is a left(width).

Example:

    QString s("pie");
    QString t = s.rightJustify(8, '.');         // t == ".....pie"

See also: leftJustify().

voidQString::setExpand(uintindex, QCharc)

This function is obsolete. It is provided to keep old programs working. We strongly advise against using it in new code.

Sets the character at position index to c and expands the string if necessary, filling with spaces.

This method is redundant in Qt 2.x, because operator[] will expand the string as necessary, if you are assigning a value.

QString&QString::setNum(doublen, charf='g', intprec=6)

Sets the string to the printed value of n.

Arguments:

Returns a reference to the string.

Examples: table/main.cpp

QString&QString::setNum(floatn, charf='g', intprec=6)

Sets the string to the printed value of n.

Arguments:

Returns a reference to the string.

QString&QString::setNum(intn, intbase=10)

Sets the string to the printed value of n and returns a reference to the string.

QString&QString::setNum(longn, intbase=10)

Sets the string to the printed value of n and returns a reference to the string.

The value is converted to base notation (default is decimal). The base must be a value from 2 to 36.

QString&QString::setNum(shortn, intbase=10)

Sets the string to the printed value of n and returns a reference to the string.

QString&QString::setNum(uintn, intbase=10)

Sets the string to the printed unsigned value of n and returns a reference to the string.

QString&QString::setNum(ulongn, intbase=10)

Sets the string to the printed unsigned value of n and returns a reference to the string.

The value is converted to base notation (default is decimal). The base must be a value from 2 to 36.

QString&QString::setNum(ushortn, intbase=10)

Sets the string to the printed unsigned value of n and returns a reference to the string.

QStringQString::simplifyWhiteSpace()const

Returns a new string that has white space removed from the start and the end, plus any sequence of internal white space replaced with a single space (ASCII 32).

White space means any character for which QChar::isSpace() returns TRUE. This includes ASCII characters 9 (TAB), 10 (LF), 11 (VT), 12 (FF), 13 (CR), and 32 (Space).

    QString s = "  lots\t of\nwhite    space ";
    QString t = s.simplifyWhiteSpace();         // t == "lots of white space"

See also: stripWhiteSpace().

QString&QString::sprintf(constchar*cformat, ...)

Safely builds a formatted string from a format string and an arbitrary list of arguments. The format string supports all the escape sequences of printf() in the standard C library.

The %s escape sequence expects a UTF-8 encoded string. For typesafe string building, with full Unicode support, you can use QTextOStream like this:

    QString str;
    QString s = ...;
    int x = ...;
    QTextOStream(&str) << s << " : " << x;

For translations, especially if the strings contains more than one escape sequence, you should consider using the arg() function instead. This allows the order of the replacements to be controlled by the translator, and has Unicode support.

See also: arg(const and QString&,int).

Examples: xform/xform.cpp layout/layout.cpp drawdemo/drawdemo.cpp popup/popup.cpp progress/progress.cpp qmag/qmag.cpp forever/forever.cpp scrollview/scrollview.cpp movies/main.cpp picture/picture.cpp

QStringQString::stripWhiteSpace()const

Returns a new string that has white space removed from the start and the end.

White space means any character for which QChar::isSpace() returns TRUE. This includes ASCII characters 9 (TAB), 10 (LF), 11 (VT), 12 (FF), 13 (CR), and 32 (Space).

Example:

    QString s = " space ";
    QString t = s.stripWhiteSpace();            // t == "space"

See also: simplifyWhiteSpace().

doubleQString::toDouble(bool*ok=0)const

Returns the string converted to a double value.

If ok is non-null, *ok is set to TRUE if there are no conceivable errors, and FALSE if the string is not a number at all, or if it has trailing garbage.

floatQString::toFloat(bool*ok=0)const

Returns the string converted to a float value.

If ok is non-null, *ok is set to TRUE if there are no conceivable errors, and FALSE if the string is not a number at all, or if it has trailing garbage.

intQString::toInt(bool*ok=0, intbase=10)const

Returns the string converted to a int value.

If ok is non-null, *ok is set to TRUE if there are no conceivable errors, and FALSE if the string is not a number at all, or if it has trailing garbage.

longQString::toLong(bool*ok=0, intbase=10)const

Returns the string converted to a long value.

If ok is non-null, *ok is set to TRUE if there are no conceivable errors, and FALSE if the string is not a number at all, or if it has trailing garbage.

shortQString::toShort(bool*ok=0, intbase=10)const

Returns the string converted to a short value.

If ok is non-null, *ok is set to TRUE if there are no conceivable errors, and FALSE if the string is not a number at all, or if it has trailing garbage.

uintQString::toUInt(bool*ok=0, intbase=10)const

Returns the string converted to an unsigned int value.

If ok is non-null, *ok is set to TRUE if there are no conceivable errors, and FALSE if the string is not a number at all, or if it has trailing garbage.

ulongQString::toULong(bool*ok=0, intbase=10)const

Returns the string converted to an unsigned long value.

If ok is non-null, *ok is set to TRUE if there are no conceivable errors, and FALSE if the string is not a number at all, or if it has trailing garbage.

ushortQString::toUShort(bool*ok=0, intbase=10)const

Returns the string converted to an unsigned short value.

If ok is non-null, *ok is set to TRUE if there are no conceivable errors, and FALSE if the string is not a number at all, or if it has trailing garbage.

voidQString::truncate(uintnewLen)

Truncates the string at position newLen. If newLen is less than the current length, this is equivalent to setLength( newLen ). Otherwise, nothing happens.

Example:

    QString s = "truncate this string";
    s.truncate( 5 );                            // s == "trunc"

In Qt 1.x, it was possible to "truncate" a string to a longer length. This is no longer possible.

See also: setLength().

constQChar*QString::unicode()const

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

QStringQString::upper()const

Returns a new string that is the string converted to upper case.

Example:

    QString s("TeX");
    QString t = s.upper();                      // t == "TEX"

See also: lower().

QCStringQString::utf8()const

Returns the string encoded in UTF8 format.

See QTextCodec for more diverse coding/decoding of Unicode strings.

See also: QString::fromUtf8() and local8Bit().

QStringQString::visual(intindex=0, intlen=-1)

This function returns the QString ordered visually. Useful for painting the string or when transforming to a visually ordered encoding.


Related Functions

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

Reads a string from the stream.

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

Returns the concatenated string of s1 and s2.

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

Returns TRUE if s1 is alphabetically less than or equal to s2, otherwise FALSE.

Equivalent to strcmp(s1,s2) <= 0

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

Returns the concatenated string of s1 and s2.

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

Returns the concatenated string of s1 and s2.

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

Writes a string to the stream.

Output format: [length (Q_UINT32) data...].

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

Returns TRUE if the two strings are equal, or FALSE if they are different. A null string is different from an empty, non-null string.

Equivalent to strcmp(s1,s2) == 0

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

Returns TRUE if the two strings are different, or FALSE if they are equal.

Equivalent to strcmp(s1,s2) != 0

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

Returns TRUE if the two strings are different, or FALSE if they are equal.

Equivalent to strcmp(s1,s2) != 0

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

Returns TRUE if s1 is alphabetically less than s2, otherwise FALSE.

Equivalent to strcmp(s1,s2) < 0

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

Returns TRUE if s1 is alphabetically greater than or equal to s2, otherwise FALSE.

Equivalent to strcmp(s1,s2) >= 0

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

Returns the concatenated string of c and s.

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

Returns TRUE if s1 is alphabetically less than or equal to s2, otherwise FALSE.

Equivalent to strcmp(s1,s2) <= 0

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

Returns the concatenated string of s and c.

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

Returns TRUE if s1 is alphabetically greater than s2, otherwise FALSE.

Equivalent to strcmp(s1,s2) > 0

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

Returns TRUE if s1 is alphabetically less than s2, otherwise FALSE.

Equivalent to strcmp(s1,s2) < 0

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

Returns TRUE if the two strings are different, or FALSE if they are equal.

Equivalent to strcmp(s1,s2) != 0

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

Returns TRUE if the two strings are equal, or FALSE if they are different.

Equivalent to strcmp(s1,s2) == 0

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

Returns TRUE if the two strings are equal, or FALSE if they are different.

Equivalent to strcmp(s1,s2) == 0

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

Returns TRUE if s1 is alphabetically greater than s2, otherwise FALSE.

Equivalent to strcmp(s1,s2) > 0

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

Returns TRUE if s1 is alphabetically greater than or equal to s2, otherwise FALSE.

Equivalent to strcmp(s1,s2) >= 0


Search the documentation, FAQ, qt-interest archive and more (uses www.troll.no):


This file is part of the Qt toolkit, copyright © 1995-99 Troll Tech, all rights reserved.


Copyright 1999 Troll TechTrademarks
Qt version 2.0.2