QString Class ReferenceThe QString class provides an abstraction of Unicode text and the classic C '\0'-terminated char array. More... All the functions in this class are reentrant when Qt is built with thread support. #include <qstring.h> Public Members
Static Public Members
Related Functions
Detailed DescriptionThe QString class provides an abstraction of Unicode text and the classic C '\0'-terminated char array.
QString uses implicit sharing, which makes it very efficient and easy to use. In all of the 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. If the const char * is not '\0'-terminated, the results are undefined. Functions that copy classic C strings into a QString will not copy the terminating '\0' character. The QChar array of the QString (as returned by unicode()) is generally not terminated by a '\0'. If you need to pass a QString to a function that requires a C '\0'-terminated string use latin1(). 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 '\0'-terminated 8-bit
data, use QCString; if it is unterminated (i.e. contains '\0's)
8-bit data, use QByteArray; if it is text, use QString.
Lists of strings are handled by the QStringList class. You can
split a string into a list of strings using QStringList::split(),
and join a list of strings into a single string with an optional
separator using QStringList::join(). You can obtain a list of
strings from a string list that contain a particular substring or
that match a particular regex using
QStringList::grep().
Note for C programmers
Due to C++'s type system and the fact that QString is implicitly shared, QStrings may be treated like ints or other simple base
types. For example:
The variable, result, is an auto variable allocated on the stack.
When return is called, because we're returning by value, The copy
constructor is called and a copy of the string is returned. (No
actual copying takes place thanks to the implicit sharing, see
below.)
Throughout Qt's source code you will encounter QString usages like
this:
The 'copying' of input to output is almost as fast as copying a
pointer because behind the scenes copying is achieved by
incrementing a reference count. QString (like all Qt's implicitly
shared classes) operates on a copy-on-write basis, only copying if
an instance is actually changed.
If you wish to create a deep copy of a QString without losing any
Unicode information then you should use QDeepCopy.
See also QChar, QCString, QByteArray, QConstString, Implicitly and Explicitly Shared Classes, Text Related Classes, and Non-GUI Classes.
Any of the last four values can be OR-ed together to form a flag.
See also section().
Constructs a null string, i.e. both the length and data pointer
are 0.
See also isNull().
If unicode and length are 0, then a null string is created.
If only unicode is 0, the string is empty but has length
characters of space preallocated: QString expands automatically
anyway, but this may speed up some cases a little. We recommend
using the plain constructor and setLength() for this purpose since
it will result in more readable code.
See also isNull() and setLength().
If str is 0, then a null string is created.
This is a cast constructor, but it is perfectly safe: converting a
Latin-1 const char * to QString preserves all the information. You
can disable this constructor by defining QT_NO_CAST_ASCII when
you compile your applications. You can also make QString objects
by using setLatin1(), fromLatin1(), fromLocal8Bit(), and
fromUtf8(). Or whatever encoding is appropriate for the 8-bit data
you have.
See also isNull().
This is the same as fromAscii(str).
Destroys the string and frees the string's data if this is the
last reference to the string.
Appends str to the string and returns a reference to the
result.
Equivalent to operator+=().
Example: dirview/dirview.cpp.
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Appends character ch to the string and returns a reference to
the result.
Equivalent to operator+=().
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Appends character ch to the string and returns a reference to
the result.
Equivalent to operator+=().
Appends str to the string and returns a reference to the result.
Equivalent to operator+=().
Appends str to the string and returns a reference to the result.
Equivalent to operator+=().
Appends str to the string and returns a reference to the result.
Equivalent to operator+=().
The fieldWidth value specifies the minimum amount of space that
a is padded to. A positive value will produce right-aligned
text, whereas a negative value will produce left-aligned text.
The following example shows how we could create a 'status' string
when processing a list of files:
It is generally fine to use filenames and numbers as we have done
in the example above. But note that using arg() to construct
natural language sentences does not usually translate well into
other languages because sentence structure and word order often
differ between languages.
If there is no place marker (%1, %2, etc.), a warning
message (qWarning()) is output and the result is undefined.
Example: walkthrough/dialogs/io.cpp.
The fieldWidth value specifies the minimum amount of space that
a is padded to. A positive value will produce a right-aligned
number, whereas a negative value will produce a left-aligned
number.
a is expressed in base base, which is 10 by default and must
be between 2 and 36.
a is expressed in base base, which is 10 by default and must
be between 2 and 36.
a is expressed in base base, which is 10 by default and must
be between 2 and 36.
a is expressed in base base, which is 10 by default and must
be between 2 and 36.
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
a is expressed in base base, which is 10 by default and must
be between 2 and 36.
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
a is expressed in base base, which is 10 by default and must
be between 2 and 36.
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
a is expressed in base base, which is 10 by default and must
be between 2 and 36.
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
a is expressed in base base, which is 10 by default and must
be between 2 and 36.
Argument a is formatted according to the fmt format specified,
which is 'g' by default and can be any of the following:
With 'e', 'E', and 'f', prec is the number of digits after the
decimal point. With 'g' and 'G', prec is the maximum number of
significant digits (trailing zeroes are omitted).
a is assumed to be in the Latin-1 character set.
This is the same as str.arg(a1).arg(a2), except that
the strings are replaced in one pass. This can make a difference
if a1 contains e.g. %1:
This is the same as calling str.arg(a1).arg(a2).arg(a3),
except that the strings are replaced in one pass.
This is the same as calling
str.arg(a1).arg(a2).arg(a3).arg(a4),
except that the strings are replaced in one pass.
If a codec has been set using QTextCodec::codecForCStrings(),
it is used to convert Unicode to 8-bit char. Otherwise, this function
does the same as latin1().
See also fromAscii(), latin1(), utf8(), and local8Bit().
Example: network/networkprotocol/nntp.cpp.
Returns the character at index i, or 0 if i is beyond the
length of the string.
If the QString is not const (i.e. const QString) or const& (i.e.
const QString &), then the non-const overload of at() will be used
instead.
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
The function returns a reference to the character at index i.
The resulting reference can then be assigned to, or used
immediately, but it will become invalid once further modifications
are made to the original string.
If i is beyond the length of the string then the string is
expanded with QChar::null.
Returns the number of characters this string can hold
in the allocated memory.
See also reserve() and squeeze().
Lexically compares s1 with s2 and returns an integer less
than, equal to, or greater than zero if s1 is less than, equal
to, or greater than s2.
The comparison is based exclusively on the numeric Unicode values
of the characters and is very fast, but is not what a human would
expect. Consider sorting user-interface strings with
QString::localeAwareCompare().
Lexically compares this string with s and returns an integer
less than, equal to, or greater than zero if it is less than, equal
to, or greater than s.
Applies possible ligatures to a QString. Useful when
composition-rich text requires rendering with glyph-poor fonts,
but it also makes compositions such as QChar(0x0041) ('A') and
QChar(0x0308) (Unicode accent diaresis), giving QChar(0x00c4)
(German A Umlaut).
Returns the QChar at index i by value.
Equivalent to at(i).
See also ref().
If cs is TRUE (the default), the search is case sensitive;
otherwise the search is case insensitive.
Examples: fileiconview/qfileiconview.cpp and mdi/application.cpp.
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Returns the number of times the string str occurs in the string.
If cs is TRUE (the default), the search is case sensitive;
otherwise the search is case insensitive.
Returns the number of times str occurs in the string.
If cs is TRUE (the default), the search is case sensitive;
otherwise the search is case insensitive.
This function counts overlapping strings, so in the example below,
there are two instances of "ana" in "bananas".
See also findRev().
Returns the number of times the regexp, rx, matches in the
string.
This function counts overlapping matches, so in the example below,
there are four instances of "ana" or "ama".
See also find() and findRev().
This function is obsolete. It is provided to keep old source working. We strongly advise against using it in new code.
In Qt 2.0 and later, all calls to this function are needless. Just
remove them.
This function is obsolete. It is provided to keep old source working. We strongly advise against using it in new code.
Returns a pointer to a '\0'-terminated classic C string.
In Qt 1.x, this returned a char* allowing direct manipulation of the
string as a sequence of bytes. In Qt 2.x where QString is a Unicode
string, char* conversion constructs a temporary string, and hence
direct character operations are meaningless.
If cs is TRUE (the default), the search is case sensitive;
otherwise the search is case insensitive.
See also startsWith().
Example: chart/main.cpp.
If len is negative (the default), the current string length is
used.
Returns the position of the first match of rx or -1 if no match
was found.
See also findRev(), replace(), and contains().
Example: network/mail/smtp.cpp.
Finds the first occurrence of the character c, starting at
position index. If index is -1, the search starts at the
last character; if -2, at the next to last character and so on.
(See findRev() for searching backwards.)
If cs is TRUE (the default), the search is case sensitive;
otherwise the search is case insensitive.
Returns the position of c or -1 if c could not be found.
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Find character c starting from position index.
If cs is TRUE (the default), the search is case sensitive;
otherwise the search is case insensitive.
Finds the first occurrence of the string str, starting at
position index. If index is -1, the search starts at the
last character, if it is -2, at the next to last character and so
on. (See findRev() for searching backwards.)
If cs is TRUE (the default), the search is case sensitive;
otherwise the search is case insensitive.
Returns the position of str or -1 if str could not be found.
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Equivalent to find(QString(str), index).
Equivalent to findRev(QString(str), index).
Finds the first occurrence of the character c, starting at
position index and searching backwards. If the index is -1, the
search starts at the last character, if it is -2, at the next to
last character and so on.
Returns the position of c or -1 if c could not be found.
If cs is TRUE (the default), the search is case sensitive;
otherwise the search is case insensitive.
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Find character c starting from position index and working
backwards.
If cs is TRUE (the default), the search is case sensitive;
otherwise the search is case insensitive.
Finds the first occurrence of the string str, starting at
position index and searching backwards. If the index is -1, the
search starts at the last character, if it is -2, at the next to
last character and so on.
Returns the position of str or -1 if str could not be found.
If cs is TRUE (the default), the search is case sensitive;
otherwise the search is case insensitive.
Finds the first match of the regexp rx, starting at position index and searching backwards. If the index is -1, the search
starts at the last character, if it is -2, at the next to last
character and so on. (See findRev() for searching backwards.)
Returns the position of the match or -1 if no match was found.
See also find().
If a codec has been set using QTextCodec::codecForCStrings(),
it is used to convert Unicode to 8-bit char. Otherwise, this function
does the same as fromLatin1().
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 8-bit ASCII text using this function.
See also fromAscii().
Examples: listbox/listbox.cpp and network/mail/smtp.cpp.
local8Bit is assumed to be encoded in a locale-specific format.
See QTextCodec for more diverse coding/decoding of Unicode strings.
Example: walkthrough/view/mainwindow.ui.h.
If str is 0, then a null string is created.
See also isNull().
See QTextCodec for more diverse coding/decoding of Unicode strings.
Example: fonts/simple-qfont-demo/viewer.cpp.
If index is beyond the end of the string, the string is
extended with spaces to length index and s is then appended
and returns a reference to the string.
See also remove() and replace().
Examples: themes/themes.cpp and xform/xform.cpp.
Inserts s into the string at position index and returns
a reference to the string.
Inserts s into the string at position index and returns
a reference to the string.
Inserts the first len characters in s into the string at
position index and returns a reference to the string.
Insert c into the string at 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.
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Insert character c at position index.
Returns TRUE if the string is empty, i.e. if length() == 0;
otherwise returns FALSE. Null strings are also empty.
See also isNull() and length().
Examples: addressbook/mainwindow.cpp, chart/chartform.cpp, network/networkprotocol/nntp.cpp, qmag/qmag.cpp, qwerty/qwerty.cpp, walkthrough/dialogs/todo.cpp, and walkthrough/mainwindow.ui.h.
Returns TRUE if the string is null; otherwise returns FALSE. A
null string is always empty.
See also isEmpty() and length().
Examples: i18n/main.cpp, network/ftpclient/ftpmainwindow.ui.h, and qdir/qdir.cpp.
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
source string exists.
See also fromLatin1(), ascii(), utf8(), and local8Bit().
Examples: fileiconview/qfileiconview.cpp and network/networkprotocol/nntp.cpp.
The whole string is returned if len exceeds the length of the
string.
See also right(), mid(), and isEmpty().
Example: themes/themes.cpp.
If truncate is FALSE and the length of the string is more than
width, then the returned string is a copy of the string.
If truncate is TRUE and the length of the string is more than
width, then any characters in a copy of the string after length
width are removed, and the copy is returned.
See also rightJustify().
Returns the length of the string.
Null strings and empty strings have zero length.
See also isNull() and isEmpty().
Examples: dirview/dirview.cpp, fileiconview/qfileiconview.cpp, network/networkprotocol/nntp.cpp, rot13/rot13.cpp, and themes/themes.cpp.
See QTextCodec for more diverse coding/decoding of Unicode
strings.
See also fromLocal8Bit(), ascii(), latin1(), and utf8().
Example: walkthrough/dialogs/todo.cpp.
Compares s1 with s2 and returns an integer less than, equal
to, or greater than zero if s1 is less than, equal to, or
greater than s2.
The comparison is performed in a locale- and also
platform-dependent manner. Use this function to present sorted
lists of strings to the user.
See also QString::compare() and QTextCodec::locale().
Compares this string with s.
See also upper().
Example: scribble/scribble.cpp.
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.
Examples: network/mail/smtp.cpp, qmag/qmag.cpp, and themes/themes.cpp.
See also setNum().
Examples: application/application.cpp, chart/chartform.cpp, fonts/simple-qfont-demo/viewer.cpp, helpviewer/helpwindow.cpp, mdi/application.cpp, and sql/overview/extract/main.cpp.
See also setNum().
See also setNum().
See also setNum().
See also setNum().
A convenience factory function that returns a string
representation of the number n to the base base, which is 10
by default and must be between 2 and 36.
See also setNum().
Argument n is formatted according to the f format specified,
which is g by default, and can be any of the following:
With 'e', 'E', and 'f', prec is the number of digits after the
decimal point. With 'g' and 'G', prec is the maximum number of
significant digits (trailing zeroes are omitted).
See also setNum().
Returns latin1(). Be sure to see the warnings documented in the
latin1() function. Note that for new code which you wish to be
strictly Unicode-clean, you can define the macro QT_NO_ASCII_CAST when compiling your code to hide this function so
that automatic casts are not done. This has the added advantage
that you catch the programming error described in operator!().
Returns ascii().
Returns TRUE if this is a null string; otherwise returns FALSE.
Note that if you say
It will call "operator const char*()", which is inefficent; you
may wish to define the macro QT_NO_ASCII_CAST when writing code
which you wish to remain Unicode-clean.
When you want the above semantics, use:
See also isEmpty().
Appends str to the string and returns a reference to the string.
Appends str to the string and returns a reference to the string.
Appends str to the string and returns a reference to the string.
Appends c to the string and returns a reference to the string.
Appends c to the string and returns a reference to the string.
Sets the string to contain just the single character c.
Assigns a shallow copy of s to this string and returns a
reference to this string. This is very fast because the string
isn't actually copied.
Assigns a deep copy of str, interpreted as a classic C string
to this string and returns a reference to this string.
If str is 0, then a null string is created.
See also isNull().
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Makes a deep copy of s and returns a reference to the deep
copy.
Assigns a deep copy of cstr, interpreted as a classic C
string, to this string. Returns a reference to this string.
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Sets the string to contain just the single character c.
Returns the character at index i, or QChar::null if i is
beyond the length of the string.
If the QString is not const (i.e., const QString) or const&
(i.e., const QString&), then the non-const overload of operator[]
will be used instead.
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
The function returns a reference to the character at index i.
The resulting reference can then be assigned to, or used
immediately, but it will become invalid once further modifications
are made to the original string.
If i is beyond the length of the string then the string is
expanded with QChar::nulls, so that the QCharRef references a
valid (null) character in 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 will detach itself because of QString's copy-on-write
semantics). You will get compilation errors if you try to use the
result as anything but a QChar.
Inserts s at the beginning of the string and returns a
reference to the string.
Equivalent to insert(0, s).
See also insert().
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Inserts ch at the beginning of the string and returns a
reference to the string.
Equivalent to insert(0, ch).
See also insert().
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Inserts ch at the beginning of the string and returns a
reference to the string.
Equivalent to insert(0, ch).
See also insert().
Inserts s at the beginning of the string and returns a reference to the string.
Equivalent to insert(0, s).
See also insert().
Inserts s at the beginning of the string and returns a reference to the string.
Equivalent to insert(0, s).
See also insert().
Inserts s at the beginning of the string and returns a reference to the string.
Equivalent to insert(0, s).
See also insert().
Returns the QChar at index i by reference, expanding the string
with QChar::null if necessary. The resulting reference can be
assigned to, or otherwise used immediately, but becomes invalid
once furher modifications are made to the string.
See also constref().
If index is beyond the length of the string, nothing happens.
If index is within the string, but index + len is beyond
the end of the string, the string is truncated at position index.
See also insert() and replace().
Removes every occurrence of str in the string. Returns a
reference to the string.
If cs is TRUE (the default), the search is case sensitive;
otherwise the search is case insensitive.
This is the same as replace(str, "", cs).
Removes every occurrence of the character c in the string.
Returns a reference to the string.
This is the same as replace(c, "").
Removes every occurrence of the character c in the string.
Returns a reference to the string.
This is the same as replace(c, "").
Removes every occurrence of str in the string. Returns a
reference to the string.
Removes every occurrence of the regular expression rx in the
string. Returns a reference to the string.
This is the same as replace(rx, "").
If index is beyond the length of the string, nothing is deleted
and s is appended at the end of the string. If index is
valid, but index + len is beyond the end of the string,
the string is truncated at position index, then s is
appended at the end.
See also insert() and remove().
Examples: listviews/listviews.cpp, network/networkprotocol/nntp.cpp, and qmag/qmag.cpp.
Replaces len characters with slen characters of QChar data
from s, starting at position index, and returns a reference
to the string.
See also insert() and remove().
This is the same as replace(index, len, QString(c)).
This is the same as replace(index, len, QChar(c)).
Replaces every occurrence of the character c in the string
with after. Returns a reference to the string.
If cs is TRUE (the default), the search is case sensitive;
otherwise the search is case insensitive.
Example:
Replaces every occurrence of the character c in the string
with after. Returns a reference to the string.
If cs is TRUE (the default), the search is case sensitive;
otherwise the search is case insensitive.
Replaces every occurrence of the string before in the string
with the string after. Returns a reference to the string.
If cs is TRUE (the default), the search is case sensitive;
otherwise the search is case insensitive.
Example:
Replaces every occurrence of the regexp rx in the string with
after. Returns a reference to the string. For example:
For regexps containing capturing
parentheses, occurrences of \1, \2, ...,
in after are replaced with rx.cap(1), cap(2), ...
See also find(), findRev(), and QRegExp::cap().
Replaces every occurrence of c1 with the char c2. Returns a
reference to the string.
This function is useful for code that needs to build up a long
string and wants to avoid repeated reallocation. In this example,
we want to add to the string until some condition is true, and
we're fairly sure that size is big enough:
If maxLen is an underestimate, the worst that will happen is
that the loop will slow down.
If it is not possible to allocate enough memory, the string
remains unchanged.
See also capacity(), squeeze(), and setLength().
If len is greater than the length of the string then the whole
string is returned.
See also left(), mid(), and isEmpty().
Example: fileiconview/qfileiconview.cpp.
If truncate is FALSE and the length of the string is more than
width, then the returned string is a copy of the string.
If truncate is TRUE and the length of the string is more than
width, then the resulting string is truncated at position width.
See also leftJustify().
This function returns a section of the string.
This string is treated as a sequence of fields separated by the
character, sep. The returned string consists of the fields from
position start to position end inclusive. If end is not
specified, all fields from position start to the end of the
string are included. Fields are numbered 0, 1, 2, etc., counting
from the left, and -1, -2, etc., counting from right to left.
The flags argument can be used to affect some aspects of the
function's behaviour, e.g. whether to be case sensitive, whether
to skip empty fields and how to deal with leading and trailing
separators; see SectionFlags.
If start or end is negative, we count fields from the right
of the string, the right-most field being -1, the one from
right-most field being -2, and so on.
See also QStringList::split().
Examples: chart/element.cpp and network/ftpclient/ftpmainwindow.ui.h.
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
This function returns a section of the string.
This string is treated as a sequence of fields separated by the
string, sep. The returned string consists of the fields from
position start to position end inclusive. If end is not
specified, all fields from position start to the end of the
string are included. Fields are numbered 0, 1, 2, etc., counting
from the left, and -1, -2, etc., counting from right to left.
The flags argument can be used to affect some aspects of the
function's behaviour, e.g. whether to be case sensitive, whether
to skip empty fields and how to deal with leading and trailing
separators; see SectionFlags.
If start or end is negative, we count fields from the right
of the string, the right-most field being -1, the one from
right-most field being -2, and so on.
See also QStringList::split().
This function returns a section of the string.
This string is treated as a sequence of fields separated by the
regular expression, reg. The returned string consists of the
fields from position start to position end inclusive. If end is not specified, all fields from position start to the end
of the string are included. Fields are numbered 0, 1, 2, etc., counting
from the left, and -1, -2, etc., counting from right to left.
The flags argument can be used to affect some aspects of the
function's behaviour, e.g. whether to be case sensitive, whether
to skip empty fields and how to deal with leading and trailing
separators; see SectionFlags.
If start or end is negative, we count fields from the right
of the string, the right-most field being -1, the one from
right-most field being -2, and so on.
Warning: Using this QRegExp version is much more expensive than
the overloaded string and character versions.
See also QStringList::split() and simplifyWhiteSpace().
If str is 0 a null string is created. If str is "", an empty
string is created.
See also isNull() and isEmpty().
Sets the character at position index to c and expands the
string if necessary, filling with spaces.
This method is redundant in Qt 3.x, because operator[] will expand
the string as necessary.
If str is 0 a null string is created. If str is "", an empty
string is created.
See also isNull() and isEmpty().
See also reserve() and truncate().
The base is 10 by default and must be between 2 and 36.
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Sets the string to the printed value of n in base base and
returns a reference to the string.
The base is 10 by default and must be between 2 and 36.
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Sets the string to the printed value of n in base base and
returns a reference to the string.
The base is 10 by default and must be between 2 and 36.
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Sets the string to the printed value of n in base base and
returns a reference to the string.
The base is 10 by default and must be between 2 and 36.
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Sets the string to the printed value of n in base base and
returns a reference to the string.
The base is 10 by default and must be between 2 and 36.
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Sets the string to the printed value of n in base base and
returns a reference to the string.
The base is 10 by default and must be between 2 and 36.
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Sets the string to the printed value of n, formatted in format
f with precision prec, and returns a reference to the
string.
The format f can be 'f', 'F', 'e', 'E', 'g' or 'G'. See arg() for an explanation of the formats.
Sets the string to the printed value of n, formatted in format
f with precision prec, and returns a reference to the
string.
The format f can be 'f', 'F', 'e', 'E', 'g' or 'G'. See arg() for an explanation of the formats.
See also setLatin1() and isNull().
If unicode_as_ushorts is 0, nothing is copied, but the string
is still resized to len. If len is zero, the string becomes
a null string.
See also setLatin1() and isNull().
Whitespace means any character for which QChar::isSpace() returns
TRUE. This includes Unicode characters with decimal values 9
(TAB), 10 (LF), 11 (VT), 12 (FF), 13 (CR), and 32 (Space).
See also stripWhiteSpace().
The %s escape sequence expects a utf8() encoded string. The format
string cformat is expected to be in latin1. If you need a
Unicode format string, use arg() instead. For typesafe string
building, with full Unicode support, you can use QTextOStream like
this:
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().
Examples: dclock/dclock.cpp, forever/forever.cpp, layout/layout.cpp, qmag/qmag.cpp, scrollview/scrollview.cpp, tooltip/tooltip.cpp, and xform/xform.cpp.
See also capacity() and reserve().
If cs is TRUE (the default), the search is case sensitive;
otherwise the search is case insensitive.
See also endsWith().
Whitespace means any character for which QChar::isSpace() returns
TRUE. This includes Unicode characters with decimal values 9
(TAB), 10 (LF), 11 (VT), 12 (FF), 13 (CR) and 32 (Space), and may
also include other Unicode characters.
See also simplifyWhiteSpace().
If ok is not 0: if a conversion error occurs, *ok is set to
FALSE; otherwise *ok is set to TRUE.
See also number().
If ok is not 0: if a conversion error occurs, *ok is set to
FALSE; otherwise *ok is set to TRUE.
See also number().
If ok is not 0: if a conversion error occurs, *ok is set to
FALSE; otherwise *ok is set to TRUE.
See also number().
If ok is not 0: if a conversion error occurs, *ok is set to
FALSE; otherwise *ok is set to TRUE.
See also number().
If ok is not 0: if a conversion error occurs, *ok is set to
FALSE; otherwise *ok is set to TRUE.
See also number().
If ok is not 0: if a conversion error occurs, *ok is set to
FALSE; otherwise *ok is set to TRUE.
If ok is not 0: if a conversion error occurs, *ok is set to
FALSE; otherwise *ok is set to TRUE.
See also number().
If ok is not 0: if a conversion error occurs, *ok is set to
FALSE; otherwise *ok is set to TRUE.
See also number().
If ok is not 0: if a conversion error occurs, *ok is set to
FALSE; otherwise *ok is set to TRUE.
See also number().
If ok is not 0: if a conversion error occurs, *ok is set to
FALSE; otherwise *ok is set to TRUE.
See also setLength().
Example: network/mail/smtp.cpp.
The result remains valid so long as one unmodified
copy of the source string exists.
Returns the Unicode representation of the string. The result
remains valid until the string is modified.
See also lower().
Examples: scribble/scribble.cpp and sql/overview/custom1/main.cpp.
See QTextCodec for more diverse coding/decoding of Unicode strings.
See also fromUtf8(), ascii(), latin1(), and local8Bit().
Example: network/archivesearch/archivedialog.ui.h.
Returns TRUE if s1 is not equal to s2; otherwise returns FALSE.
Note that a null string is not equal to a not-null empty string.
Equivalent to compare(s1, s2) != 0.
See also isNull() and isEmpty().
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Returns TRUE if s1 is not equal to s2; otherwise returns FALSE.
Note that a null string is not equal to a not-null empty string.
Equivalent to compare(s1, s2) != 0.
See also isNull() and isEmpty().
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Returns TRUE if s1 is not equal to s2; otherwise returns FALSE.
Note that a null string is not equal to a not-null empty string.
Equivalent to compare(s1, s2) != 0.
See also isNull() and isEmpty().
Returns a string which is the result of concatenating the string
s1 and the string s2.
Equivalent to s1.append(s2).
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Returns a string which is the result of concatenating the string
s1 and character s2.
Equivalent to s1.append(s2).
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Returns a string which is the result of concatenating the
character s1 and string s2.
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Returns a string which is the result of concatenating the string
s and character c.
Equivalent to s.append(c).
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Returns a string which is the result of concatenating the
character c and string s.
Equivalent to s.prepend(c).
Returns TRUE if s1 is lexically less than s2; otherwise returns FALSE.
The comparison is case sensitive.
Equivalent to compare(s1, s2) < 0.
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Returns TRUE if s1 is lexically less than s2; otherwise returns FALSE.
The comparison is case sensitive.
Equivalent to compare(s1, s2) < 0.
Writes the string str to the stream s.
See also Format of the QDataStream operators
Returns TRUE if s1 is lexically less than or equal to s2;
otherwise returns FALSE.
The comparison is case sensitive.
Note that a null string is not equal to a not-null empty string.
Equivalent to compare(s1,s2) <= 0.
See also isNull() and isEmpty().
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Returns TRUE if s1 is lexically less than or equal to s2;
otherwise returns FALSE.
The comparison is case sensitive.
Note that a null string is not equal to a not-null empty string.
Equivalent to compare(s1, s2) <= 0.
See also isNull() and isEmpty().
Returns TRUE if s1 is equal to s2; otherwise returns FALSE.
Note that a null string is not equal to a not-null empty string.
Equivalent to compare(s1, s2) != 0.
See also isNull() and isEmpty().
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Returns TRUE if s1 is equal to s2; otherwise returns FALSE.
Note that a null string is not equal to a not-null empty string.
Equivalent to compare(s1, s2) == 0.
See also isNull() and isEmpty().
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Returns TRUE if s1 is equal to s2; otherwise returns FALSE.
Note that a null string is not equal to a not-null empty string.
Equivalent to compare(s1, s2) == 0.
See also isNull() and isEmpty().
Returns TRUE if s1 is lexically greater than s2; otherwise
returns FALSE.
The comparison is case sensitive.
Equivalent to compare(s1, s2) > 0.
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Returns TRUE if s1 is lexically greater than s2; otherwise
returns FALSE.
The comparison is case sensitive.
Equivalent to compare(s1, s2) > 0.
Returns TRUE if s1 is lexically greater than or equal to s2;
otherwise returns FALSE.
The comparison is case sensitive.
Note that a null string is not equal to a not-null empty string.
Equivalent to compare(s1, s2) >= 0.
See also isNull() and isEmpty().
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Returns TRUE if s1 is lexically greater than or equal to s2;
otherwise returns FALSE.
The comparison is case sensitive.
Note that a null string is not equal to a not-null empty string.
Equivalent to compare(s1, s2) >= 0.
See also isNull() and isEmpty().
Reads a string from the stream s into string str.
See also Format of the QDataStream operators
This file is part of the Qt toolkit.
Copyright © 1995-2003
Trolltech. All Rights Reserved. |
Publicité
Best OfActualités les plus luesSemaine
Mois
Année
Le Qt Labs au hasardConstruire l'avenir : (ré-)introduction aux composants de Qt QuickLes Qt Labs sont les laboratoires des développeurs de Qt, où ils peuvent partager des impressions sur le framework, son utilisation, ce que pourrait être son futur. Lire l'article.
CommunautéRessources
Liens utilesContact
Qt dans le magazine |
Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. | Qt 3.2 | |
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD. | ||
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP ! |
Copyright © 2000-2012 - www.developpez.com