The QString class provides an abstraction of the classic C zero-terminated char array (char*). More...
#include <qstring.h>
Inherits QByteArray.
QString inherits QByteArray, which is defined as QArray<char>.
Since QString is a QArray, it uses explicit sharing with a reference count.
Note that for the QString methods that take a const char * parameter the results are undefined if the QString is not zero-terminated. It is legal for the const char * parameter to be 0.
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.
See also: Shared classes
Examples: dclock/dclock.cpp forever/forever.cpp drawdemo/drawdemo.cpp picture/showpic.cpp qmag/qmag.cpp widgets/widgets.cpp
Constructs a shallow copy s.
See also: assign().
Constructs a string that is a deep copy of str.
Constructs a string with room for size characters, including the '\0'-terminator. Makes a null string if size == 0.
If size > 0, then the first and last characters in the string are initialized to '\0'. All other characters are uninitialized.
See also: resize() and isNull().
Constructs a null string.
See also: isNull().
Returns the string data.
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.
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().
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().
Returns a deep copy of this string.
See also: detach().
Fills the string with len bytes of value c, followed by a '\0'-terminator.
If len is negative, then the current string length is used.
Returns FALSE is len is nonnegative and there is no memory to resize the string, otherwise TRUE is returned.
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.
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.
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.
Finds the first occurrence of the character c, starting at position index and searching backwards.
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.
Finds the first occurrence of the regular expression rx, starting at position index and searching backwards.
The search will start from the end of the string if index is negative.
Returns the position of the next match (backwards), or -1 if rx was not found.
Finds the first occurrence of the string str, starting at position index and searching backwards.
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.
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 = "Yes";
s.insert( 3, '!'); // s == "Yes!"
See also: remove() and replace().
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"
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(), length() and size().
Returns TRUE if the string is null, i.e. if data() == 0. A null string is also an empty string.
Example:
QString a; // a.data() == 0, a.size() == 0, a.length() == 0
QString b == ""; // b.data() == "", b.size() == 1, b.length() == 0
a.isNull(); // TRUE, because a.data() == 0
a.isEmpty(); // TRUE, because a.length() == 0
b.isNull(); // FALSE, because b.data() == ""
b.isEmpty(); // TRUE, because b.length() == 0
See also: isEmpty(), length() and size().
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"
Returns a string of length width (plus '\0') 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().
Returns the length of the string, excluding the '\0'-terminator.
Equivalent to calling strlen(data()).
Null strings and empty strings have zero length.
See also: size(), isNull() and isEmpty().
Returns a new string that is the string converted to lower case.
Presently it only handles 7-bit ASCII, or whatever tolower() handles (if $LC_CTYPE is set, most UNIX systems do the Right Thing).
Example:
QString s("TeX");
QString t = s.lower(); // t == "tex"
See also: upper().
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"
Appends c to the string and returns a reference to the string.
Appends str to the string and returns a reference to the string.
Assigns a shallow copy of s to this string and returns a reference to this string.
Assigns a deep copy of str to this string and returns a reference to this string.
Prepend \s to the string. Equivalent to insert(0,s).
See also: insert().
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 = "neutrino";
s.remove( 1, 6 ); // s == "no"
See also: insert() and replace().
Replaces every occurrence of rx in the string with str. Returns a reference to the string.
Example:
QString s = "banana";
s.replace( QRegExp("a.*a"), "" ); // becomes "b"
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().
Extends or shrinks the string to len bytes, including the '\0'-terminator.
A \0-terminator is set at position len - 1 unless
len == 0.
Example:
QString s = "resize this string";
s.resize( 7 ); // s == "resize"
See also: truncate().
Examples: widgets/widgets.cpp
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"
Returns a string of length width (plus '\0') 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 right(width).
Example:
QString s("pie");
QString t = s.rightJustify(8, '.'); // t == ".....pie"
See also: leftJustify().
Sets the character at position index to c and expands the string if necessary.
Returns FALSE if this index was out of range and the string could not be expanded, otherwise TRUE.
Sets the string to the printed value of n.
Arguments:
Sets the string to the printed value of n.
Arguments:
Sets the string to the printed value of n and returns a reference to the string.
Sets the string to the printed value of n and returns a reference to the string.
Sets the string to the printed value of n and returns a reference to the string.
Sets the string to the printed unsigned value of n and returns a reference to the string.
Sets the string to the printed unsigned value of n and returns a reference to the string.
Sets the string to the printed unsigned value of n and returns a reference to the string.
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" ( const char *str)
Makes a deep copy of str NO" (