Qt 4.8
Classes | Public Types | Public Functions | Static Public Functions | Static Public Variables | Private Functions | Static Private Functions | Properties | Static Private Attributes | Friends | Related Functions | List of all members
QString Class Reference

The QString class provides a Unicode character string. More...

#include <qstring.h>

Inheritance diagram for QString:
QDBusObjectPath QDBusSignature QProcEnvKey QSettingsIniKey QSettingsKey

Classes

struct  Data
 
struct  Null
 

Public Types

typedef const QCharconst_iterator
 The QString::const_iterator typedef provides an STL-style const iterator for QString. More...
 
typedef const QCharconst_reference
 The QString::const_reference typedef provides an STL-style const reference for QString. More...
 
typedef const_iterator ConstIterator
 Qt-style synonym for QString::const_iterator. More...
 
typedef DataDataPtr
 
typedef QChariterator
 The QString::iterator typedef provides an STL-style non-const iterator for QString. More...
 
typedef iterator Iterator
 Qt-style synonym for QString::iterator. More...
 
enum  NormalizationForm { NormalizationForm_D, NormalizationForm_C, NormalizationForm_KD, NormalizationForm_KC }
 This enum describes the various normalized forms of Unicode text. More...
 
typedef QCharreference
 The QString::const_reference typedef provides an STL-style reference for QString. More...
 
enum  SectionFlag {
  SectionDefault = 0x00, SectionSkipEmpty = 0x01, SectionIncludeLeadingSep = 0x02, SectionIncludeTrailingSep = 0x04,
  SectionCaseInsensitiveSeps = 0x08
}
 This enum specifies flags that can be used to affect various aspects of the section() function's behavior with respect to separators and empty fields. More...
 
enum  SplitBehavior { KeepEmptyParts, SkipEmptyParts }
 This enum specifies how the split() function should behave with respect to empty strings. More...
 
typedef QChar value_type
 The QString::const_reference typedef provides an STL-style value type for QString. More...
 

Public Functions

QStringappend (QChar c)
 
QStringappend (const QString &s)
 Appends the string str onto the end of this string. More...
 
QStringappend (const QStringRef &s)
 Appends the given string reference to this string and returns the result. More...
 
QStringappend (const QLatin1String &s)
 
QT_ASCII_CAST_WARN QStringappend (const char *s)
 
QT_ASCII_CAST_WARN QStringappend (const QByteArray &s)
 
QString arg (qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
 
QString arg (qulonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
 
QString arg (long a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
 
QString arg (ulong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
 
QString arg (int a, int fieldWidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
 
QString arg (uint a, int fieldWidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
 
QString arg (short a, int fieldWidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
 fieldWidth specifies the minimum amount of space that a is padded to and filled with the character fillChar. More...
 
QString arg (ushort a, int fieldWidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
 
QString arg (double a, int fieldWidth=0, char fmt='g', int prec=-1, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
 
QString arg (char a, int fieldWidth=0, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
 
QString arg (QChar a, int fieldWidth=0, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
 
QString arg (const QString &a, int fieldWidth=0, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
 Returns a copy of this string with the lowest numbered place marker replaced by string a, i.e., %1, %2, ..., %99. More...
 
QString arg (const QString &a1, const QString &a2) const Q_REQUIRED_RESULT
 
QString arg (const QString &a1, const QString &a2, const QString &a3) const Q_REQUIRED_RESULT
 
QString arg (const QString &a1, const QString &a2, const QString &a3, const QString &a4) const Q_REQUIRED_RESULT
 
QString arg (const QString &a1, const QString &a2, const QString &a3, const QString &a4, const QString &a5) const Q_REQUIRED_RESULT
 
QString arg (const QString &a1, const QString &a2, const QString &a3, const QString &a4, const QString &a5, const QString &a6) const Q_REQUIRED_RESULT
 
QString arg (const QString &a1, const QString &a2, const QString &a3, const QString &a4, const QString &a5, const QString &a6, const QString &a7) const Q_REQUIRED_RESULT
 
QString arg (const QString &a1, const QString &a2, const QString &a3, const QString &a4, const QString &a5, const QString &a6, const QString &a7, const QString &a8) const Q_REQUIRED_RESULT
 
QString arg (const QString &a1, const QString &a2, const QString &a3, const QString &a4, const QString &a5, const QString &a6, const QString &a7, const QString &a8, const QString &a9) const Q_REQUIRED_RESULT
 
const QChar at (int i) const
 Returns the character at the given index position in the string. More...
 
iterator begin ()
 Returns an STL-style iterator pointing to the first character in the string. More...
 
const_iterator begin () const
 
int capacity () const
 Returns the maximum number of characters that can be stored in the string without forcing a reallocation. More...
 
void chop (int n)
 Removes n characters from the end of the string. More...
 
void clear ()
 Clears the contents of the string and makes it empty. More...
 
int compare (const QString &s) const
 
int compare (const QString &s, Qt::CaseSensitivity cs) const
 
int compare (const QLatin1String &other, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
 
int compare (const QStringRef &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
 
const_iterator constBegin () const
 Returns a const STL-style iterator pointing to the first character in the string. More...
 
const QCharconstData () const
 Returns a pointer to the data stored in the QString. More...
 
const_iterator constEnd () const
 Returns a const STL-style iterator pointing to the imaginary item after the last item in the list. More...
 
QBool contains (QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
 
QBool contains (const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
 Returns true if this string contains an occurrence of the string str; otherwise returns false. More...
 
QBool contains (const QStringRef &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
 Returns true if this string contains an occurrence of the string reference str; otherwise returns false. More...
 
QBool contains (const QRegExp &rx) const
 
QBool contains (QRegExp &rx) const
 
int count () const
 
int count (QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
 
int count (const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
 Returns the number of (potentially overlapping) occurrences of the string str in this string. More...
 
int count (const QStringRef &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
 
int count (const QRegExp &) const
 
QChardata ()
 Returns a pointer to the data stored in the QString. More...
 
const QChardata () const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
DataPtrdata_ptr ()
 
void detach ()
 
iterator end ()
 Returns an STL-style iterator pointing to the imaginary character after the last character in the string. More...
 
const_iterator end () const
 
bool endsWith (const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
 Returns true if the string ends with s; otherwise returns false. More...
 
bool endsWith (const QStringRef &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
 
bool endsWith (const QLatin1String &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
 
bool endsWith (const QChar &c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
 
QStringfill (QChar c, int size=-1)
 Sets every character in the string to character ch. More...
 
int indexOf (QChar c, int from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
 
int indexOf (const QString &s, int from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
 Returns the index position of the first occurrence of the string str in this string, searching forward from index position from. More...
 
int indexOf (const QLatin1String &s, int from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
 Returns the index position of the first occurrence of the string str in this string, searching forward from index position from. More...
 
int indexOf (const QStringRef &s, int from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
 
int indexOf (const QRegExp &, int from=0) const
 
int indexOf (QRegExp &, int from=0) const
 
QStringinsert (int i, QChar c)
 
QStringinsert (int i, const QChar *uc, int len)
 
QStringinsert (int i, const QString &s)
 Inserts the string str at the given index position and returns a reference to this string. More...
 
QStringinsert (int i, const QLatin1String &s)
 
bool isDetached () const
 
bool isEmpty () const
 Returns true if the string has no characters; otherwise returns false. More...
 
bool isNull () const
 Returns true if this string is null; otherwise returns false. More...
 
bool isRightToLeft () const
 Returns true if the string is read right to left. More...
 
bool isSharedWith (const QString &other) const
 
bool isSimpleText () const
 
int lastIndexOf (QChar c, int from=-1, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
 
int lastIndexOf (const QString &s, int from=-1, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
 Returns the index position of the last occurrence of the string str in this string, searching backward from index position from. More...
 
int lastIndexOf (const QLatin1String &s, int from=-1, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
 
int lastIndexOf (const QStringRef &s, int from=-1, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
 
int lastIndexOf (const QRegExp &, int from=-1) const
 
int lastIndexOf (QRegExp &, int from=-1) const
 
QString left (int n) const Q_REQUIRED_RESULT
 Returns a substring that contains the n leftmost characters of the string. More...
 
QString leftJustified (int width, QChar fill=QLatin1Char(' '), bool trunc=false) const Q_REQUIRED_RESULT
 Returns a string of size width that contains this string padded by the fill character. More...
 
QStringRef leftRef (int n) const Q_REQUIRED_RESULT
 Returns a substring reference to the n leftmost characters of the string. More...
 
int length () const
 Returns the number of characters in this string. More...
 
int localeAwareCompare (const QString &s) const
 
int localeAwareCompare (const QStringRef &s) const
 
QString mid (int position, int n=-1) const Q_REQUIRED_RESULT
 Returns a string that contains n characters of this string, starting at the specified position index. More...
 
QStringRef midRef (int position, int n=-1) const Q_REQUIRED_RESULT
 Returns a substring reference to n characters of this string, starting at the specified position. More...
 
QString normalized (NormalizationForm mode) const Q_REQUIRED_RESULT
 Returns the string in the given Unicode normalization mode. More...
 
QString normalized (NormalizationForm mode, QChar::UnicodeVersion version) const Q_REQUIRED_RESULT
 Returns the string in the given Unicode normalization mode, according to the given version of the Unicode standard. More...
 
bool operator!= (const QString &s) const
 Returns true if this string is not equal to string other; otherwise returns false. More...
 
bool operator!= (const QLatin1String &s) const
 
QT_ASCII_CAST_WARN bool operator!= (const char *s) const
 
QT_ASCII_CAST_WARN bool operator!= (const QByteArray &s) const
 
QStringoperator+= (QChar c)
 
QStringoperator+= (QChar::SpecialCharacter c)
 
QStringoperator+= (const QString &s)
 Appends the string other onto the end of this string and returns a reference to this string. More...
 
QStringoperator+= (const QStringRef &s)
 
QStringoperator+= (const QLatin1String &s)
 
QT_ASCII_CAST_WARN QStringoperator+= (const char *s)
 
QT_ASCII_CAST_WARN QStringoperator+= (const QByteArray &s)
 
QT_ASCII_CAST_WARN QStringoperator+= (char c)
 
bool operator< (const QString &s) const
 Returns true if this string is lexically less than string other; otherwise returns false. More...
 
bool operator< (const QLatin1String &s) const
 
QT_ASCII_CAST_WARN bool operator< (const char *s) const
 
QT_ASCII_CAST_WARN bool operator< (const QByteArray &s) const
 
bool operator<= (const QString &s) const
 Returns true if this string is lexically less than or equal to string other; otherwise returns false. More...
 
bool operator<= (const QLatin1String &s) const
 
QT_ASCII_CAST_WARN bool operator<= (const char *s2) const
 
QT_ASCII_CAST_WARN bool operator<= (const QByteArray &s) const
 
QStringoperator= (QChar c)
 
QStringoperator= (const QString &)
 Assigns other to this string and returns a reference to this string. More...
 
QStringoperator= (const QLatin1String &)
 
QT_ASCII_CAST_WARN QStringoperator= (const char *ch)
 
QT_ASCII_CAST_WARN QStringoperator= (const QByteArray &a)
 
QT_ASCII_CAST_WARN QStringoperator= (char c)
 
QStringoperator= (const Null &)
 
bool operator== (const QString &s) const
 Returns true if string other is equal to this string; otherwise returns false. More...
 
bool operator== (const QLatin1String &s) const
 
QT_ASCII_CAST_WARN bool operator== (const char *s) const
 
QT_ASCII_CAST_WARN bool operator== (const QByteArray &s) const
 
bool operator> (const QString &s) const
 Returns true if this string is lexically greater than string other; otherwise returns false. More...
 
bool operator> (const QLatin1String &s) const
 
QT_ASCII_CAST_WARN bool operator> (const char *s2) const
 
QT_ASCII_CAST_WARN bool operator> (const QByteArray &s) const
 
bool operator>= (const QString &s) const
 Returns true if this string is lexically greater than or equal to string other; otherwise returns false. More...
 
bool operator>= (const QLatin1String &s) const
 
QT_ASCII_CAST_WARN bool operator>= (const char *s2) const
 
QT_ASCII_CAST_WARN bool operator>= (const QByteArray &s) const
 
const QChar operator[] (int i) const
 
QCharRef operator[] (int i)
 Returns the character at the specified position in the string as a modifiable reference. More...
 
const QChar operator[] (uint i) const
 
QCharRef operator[] (uint i)
 
QStringprepend (QChar c)
 
QStringprepend (const QString &s)
 Prepends the string str to the beginning of this string and returns a reference to this string. More...
 
QStringprepend (const QLatin1String &s)
 
QT_ASCII_CAST_WARN QStringprepend (const char *s)
 
QT_ASCII_CAST_WARN QStringprepend (const QByteArray &s)
 
void push_back (QChar c)
 Appends the given ch character onto the end of this string. More...
 
void push_back (const QString &s)
 This function is provided for STL compatibility, appending the given other string onto the end of this string. More...
 
void push_front (QChar c)
 Prepends the given ch character to the beginning of this string. More...
 
void push_front (const QString &s)
 This function is provided for STL compatibility, prepending the given other string to the beginning of this string. More...
 
 QString ()
 Constructs a null string. More...
 
 QString (const QChar *unicode, int size)
 Constructs a string initialized with the first size characters of the QChar array unicode. More...
 
 QString (const QChar *unicode)
 Constructs a string initialized with the characters of the QChar array unicode, which must be terminated with a 0. More...
 
 QString (QChar c)
 Constructs a string of size 1 containing the character ch. More...
 
 QString (int size, QChar c)
 Constructs a string of the given size with every character set to ch. More...
 
 QString (const QLatin1String &latin1)
 Constructs a copy of the Latin-1 string str. More...
 
 QString (const QString &)
 Constructs a copy of other. More...
 
QT_ASCII_CAST_WARN_CONSTRUCTOR QString (const char *ch)
 Constructs a string initialized with the 8-bit string str. More...
 
QT_ASCII_CAST_WARN_CONSTRUCTOR QString (const QByteArray &a)
 Constructs a string initialized with the byte array ba. More...
 
 QString (const Null &)
 
 QString (int size, Qt::Initialization)
 Constructs a string of the given size without initializing the characters. More...
 
QStringremove (int i, int len)
 Removes n characters from the string, starting at the given position index, and returns a reference to the string. More...
 
QStringremove (QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive)
 Removes every occurrence of the character ch in this string, and returns a reference to this string. More...
 
QStringremove (const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive)
 Removes every occurrence of the given str string in this string, and returns a reference to this string. More...
 
QStringremove (const QRegExp &rx)
 Removes every occurrence of the regular expression rx in the string, and returns a reference to the string. More...
 
QString repeated (int times) const
 Returns a copy of this string repeated the specified number of times. More...
 
QStringreplace (int i, int len, QChar after)
 
QStringreplace (int i, int len, const QChar *s, int slen)
 
QStringreplace (int i, int len, const QString &after)
 Replaces n characters beginning at index position with the string after and returns a reference to this string. More...
 
QStringreplace (QChar before, QChar after, Qt::CaseSensitivity cs=Qt::CaseSensitive)
 
QStringreplace (const QChar *before, int blen, const QChar *after, int alen, Qt::CaseSensitivity cs=Qt::CaseSensitive)
 
QStringreplace (const QLatin1String &before, const QLatin1String &after, Qt::CaseSensitivity cs=Qt::CaseSensitive)
 
QStringreplace (const QLatin1String &before, const QString &after, Qt::CaseSensitivity cs=Qt::CaseSensitive)
 
QStringreplace (const QString &before, const QLatin1String &after, Qt::CaseSensitivity cs=Qt::CaseSensitive)
 
QStringreplace (const QString &before, const QString &after, Qt::CaseSensitivity cs=Qt::CaseSensitive)
 
QStringreplace (QChar c, const QString &after, Qt::CaseSensitivity cs=Qt::CaseSensitive)
 
QStringreplace (QChar c, const QLatin1String &after, Qt::CaseSensitivity cs=Qt::CaseSensitive)
 
QStringreplace (const QRegExp &rx, const QString &after)
 
void reserve (int size)
 Attempts to allocate memory for at least size characters. More...
 
void resize (int size)
 Sets the size of the string to size characters. More...
 
QString right (int n) const Q_REQUIRED_RESULT
 Returns a substring that contains the n rightmost characters of the string. More...
 
QString rightJustified (int width, QChar fill=QLatin1Char(' '), bool trunc=false) const Q_REQUIRED_RESULT
 Returns a string of size() width that contains the fill character followed by the string. More...
 
QStringRef rightRef (int n) const Q_REQUIRED_RESULT
 Returns a substring reference to the n rightmost characters of the string. More...
 
QString section (QChar sep, int start, int end=-1, SectionFlags flags=SectionDefault) const
 This function returns a section of the string. More...
 
QString section (const QString &in_sep, int start, int end=-1, SectionFlags flags=SectionDefault) const
 
QString section (const QRegExp &reg, int start, int end=-1, SectionFlags flags=SectionDefault) const
 
QStringsetNum (short, int base=10)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
QStringsetNum (ushort, int base=10)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
QStringsetNum (int, int base=10)
 Sets the string to the printed value of n in the specified base, and returns a reference to the string. More...
 
QStringsetNum (uint, int base=10)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
QStringsetNum (long, int base=10)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
QStringsetNum (ulong, int base=10)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
QStringsetNum (qlonglong, int base=10)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
QStringsetNum (qulonglong, int base=10)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
QStringsetNum (float, char f='g', int prec=6)
 Sets the string to the printed value of n, formatted according to the given format and precision, and returns a reference to the string. More...
 
QStringsetNum (double, char f='g', int prec=6)
 Sets the string to the printed value of n, formatted according to the given format and precision, and returns a reference to the string. More...
 
QStringsetRawData (const QChar *unicode, int size)
 Resets the QString to use the first size Unicode characters in the array unicode. More...
 
QStringsetUnicode (const QChar *unicode, int size)
 Resizes the string to size characters and copies unicode into the string. More...
 
QStringsetUtf16 (const ushort *utf16, int size)
 Resizes the string to size characters and copies unicode into the string. More...
 
QString simplified () const Q_REQUIRED_RESULT
 Returns a string that has whitespace removed from the start and the end, and that has each sequence of internal whitespace replaced with a single space. More...
 
int size () const
 Returns the number of characters in this string. More...
 
QStringList split (const QString &sep, SplitBehavior behavior=KeepEmptyParts, Qt::CaseSensitivity cs=Qt::CaseSensitive) const Q_REQUIRED_RESULT
 Splits the string into substrings wherever sep occurs, and returns the list of those strings. More...
 
QStringList split (const QChar &sep, SplitBehavior behavior=KeepEmptyParts, Qt::CaseSensitivity cs=Qt::CaseSensitive) const Q_REQUIRED_RESULT
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
QStringList split (const QRegExp &sep, SplitBehavior behavior=KeepEmptyParts) const Q_REQUIRED_RESULT
 Splits the string into substrings wherever the regular expression rx matches, and returns the list of those strings. More...
 
QStringsprintf (const char *format,...)
 Safely builds a formatted string from the format string cformat and an arbitrary list of arguments. More...
 
void squeeze ()
 Releases any memory not required to store the character data. More...
 
bool startsWith (const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
 Returns true if the string starts with s; otherwise returns false. More...
 
bool startsWith (const QStringRef &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
 Returns true if the string starts with the string reference s; otherwise returns false. More...
 
bool startsWith (const QLatin1String &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
 
bool startsWith (const QChar &c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
 
void swap (QString &other)
 Swaps string other with this string. More...
 
QByteArray toAscii () const Q_REQUIRED_RESULT
 Returns an 8-bit representation of the string as a QByteArray. More...
 
QString toCaseFolded () const Q_REQUIRED_RESULT
 Returns the case folded equivalent of the string. More...
 
double toDouble (bool *ok=0) const
 Returns the string converted to a double value. More...
 
float toFloat (bool *ok=0) const
 
int toInt (bool *ok=0, int base=10) const
 Returns the string converted to an int using base base, which is 10 by default and must be between 2 and 36, or 0. More...
 
QByteArray toLatin1 () const Q_REQUIRED_RESULT
 Returns a Latin-1 representation of the string as a QByteArray. More...
 
QByteArray toLocal8Bit () const Q_REQUIRED_RESULT
 Returns the local 8-bit representation of the string as a QByteArray. More...
 
long toLong (bool *ok=0, int base=10) const
 Returns the string converted to a long using base base, which is 10 by default and must be between 2 and 36, or 0. More...
 
qlonglong toLongLong (bool *ok=0, int base=10) const
 Returns the string converted to a long long using base base, which is 10 by default and must be between 2 and 36, or 0. More...
 
QString toLower () const Q_REQUIRED_RESULT
 Returns a lowercase copy of the string. More...
 
short toShort (bool *ok=0, int base=10) const
 Returns the string converted to a short using base base, which is 10 by default and must be between 2 and 36, or 0. More...
 
std::string toStdString () const
 Returns a std::string object with the data contained in this QString. More...
 
std::wstring toStdWString () const
 Returns a std::wstring object with the data contained in this QString. More...
 
QVector< uinttoUcs4 () const Q_REQUIRED_RESULT
 Returns a UCS-4/UTF-32 representation of the string as a QVector<uint>. More...
 
uint toUInt (bool *ok=0, int base=10) const
 Returns the string converted to an unsigned int using base base, which is 10 by default and must be between 2 and 36, or 0. More...
 
ulong toULong (bool *ok=0, int base=10) const
 Returns the string converted to an unsigned long using base base, which is 10 by default and must be between 2 and 36, or 0. More...
 
qulonglong toULongLong (bool *ok=0, int base=10) const
 Returns the string converted to an unsigned long long using base base, which is 10 by default and must be between 2 and 36, or 0. More...
 
QString toUpper () const Q_REQUIRED_RESULT
 Returns an uppercase copy of the string. More...
 
ushort toUShort (bool *ok=0, int base=10) const
 Returns the string converted to an unsigned short using base base, which is 10 by default and must be between 2 and 36, or 0. More...
 
QByteArray toUtf8 () const Q_REQUIRED_RESULT
 Returns a UTF-8 representation of the string as a QByteArray. More...
 
int toWCharArray (wchar_t *array) const
 Fills the array with the data contained in this QString object. More...
 
QString trimmed () const Q_REQUIRED_RESULT
 Returns a string that has whitespace removed from the start and the end. More...
 
void truncate (int pos)
 Truncates the string at the given position index. More...
 
const QCharunicode () const
 Returns a '\0'-terminated Unicode representation of the string. More...
 
const ushortutf16 () const
 Returns the QString as a '\0\'-terminated array of unsigned shorts. More...
 
QStringvsprintf (const char *format, va_list ap)
 Equivalent method to sprintf(), but takes a va_list ap instead a list of variable arguments. More...
 
 ~QString ()
 Destroys the string. More...
 

Static Public Functions

static int compare (const QString &s1, const QString &s2)
 
static int compare (const QString &s1, const QString &s2, Qt::CaseSensitivity cs)
 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. More...
 
static int compare (const QString &s1, const QLatin1String &s2, Qt::CaseSensitivity cs=Qt::CaseSensitive)
 
static int compare (const QLatin1String &s1, const QString &s2, Qt::CaseSensitivity cs=Qt::CaseSensitive)
 
static int compare (const QString &s1, const QStringRef &s2, Qt::CaseSensitivity=Qt::CaseSensitive)
 
static QString fromAscii (const char *, int size=-1)
 Returns a QString initialized with the first size characters from the string str. More...
 
static QString fromLatin1 (const char *, int size=-1)
 Returns a QString initialized with the first size characters of the Latin-1 string str. More...
 
static QString fromLocal8Bit (const char *, int size=-1)
 Returns a QString initialized with the first size characters of the 8-bit string str. More...
 
static QString fromRawData (const QChar *, int size)
 Constructs a QString that uses the first size Unicode characters in the array unicode. More...
 
static QString fromStdString (const std::string &s)
 Returns a copy of the str string. More...
 
static QString fromStdWString (const std::wstring &s)
 Returns a copy of the str string. More...
 
static QString fromUcs4 (const uint *, int size=-1)
 Returns a QString initialized with the first size characters of the Unicode string unicode (ISO-10646-UCS-4 encoded). More...
 
static QString fromUtf16 (const ushort *, int size=-1)
 Returns a QString initialized with the first size characters of the Unicode string unicode (ISO-10646-UTF-16 encoded). More...
 
static QString fromUtf8 (const char *, int size=-1)
 Returns a QString initialized with the first size bytes of the UTF-8 string str. More...
 
static QString fromWCharArray (const wchar_t *, int size=-1)
 Returns a copy of the string, where the encoding of string depends on the size of wchar. More...
 
static int localeAwareCompare (const QString &s1, const QString &s2)
 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. More...
 
static int localeAwareCompare (const QString &s1, const QStringRef &s2)
 
static QString number (int, int base=10)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
static QString number (uint, int base=10)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
static QString number (long, int base=10)
 Returns a string equivalent of the number n according to the specified base. More...
 
static QString number (ulong, int base=10)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
static QString number (qlonglong, int base=10)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
static QString number (qulonglong, int base=10)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
static QString number (double, char f='g', int prec=6)
 Returns a string equivalent of the number n, formatted according to the specified format and precision. More...
 

Static Public Variables

static const Null null = { }
 

Private Functions

void expand (int i)
 
QString multiArg (int numArgs, const QString **args) const
 
 QString (Data *dd, int)
 
void realloc ()
 
void realloc (int alloc)
 
void replace_helper (uint *indices, int nIndices, int blen, const QChar *after, int alen)
 
void updateProperties () const
 

Static Private Functions

static int compare_helper (const QChar *data1, int length1, const QChar *data2, int length2, Qt::CaseSensitivity cs=Qt::CaseSensitive)
 
static int compare_helper (const QChar *data1, int length1, QLatin1String s2, Qt::CaseSensitivity cs=Qt::CaseSensitive)
 
static void free (Data *)
 
static DatafromAscii_helper (const char *str, int size=-1)
 
static DatafromLatin1_helper (const char *str, int size=-1)
 
static int grow (int)
 
static int localeAwareCompare_helper (const QChar *data1, int length1, const QChar *data2, int length2)
 

Properties

Datad
 

Static Private Attributes

static QTextCodeccodecForCStrings
 
static Data shared_empty
 
static Data shared_null
 

Friends

struct QAbstractConcatenable
 
class QCFString
 
class QCharRef
 
bool qStringComparisonHelper (const QString &s1, const char *s2)
 
bool qStringComparisonHelper (const QStringRef &s1, const char *s2)
 
class QStringRef
 
class QTextCodec
 

Related Functions

(Note that these are not member functions.)

bool operator!= (const char *s1, const QString &s2)
 
const QString operator+ (const QString &s1, const QString &s2)
 Returns a string which is the result of concatenating s1 and s2. More...
 
const QString operator+ (const QString &s1, const char *s2)
 
const QString operator+ (const char *s1, const QString &s2)
 
const QString operator+ (const QString &s, char ch)
 Returns a string which is the result of concatenating the string s and the character ch. More...
 
const QString operator+ (char ch, const QString &s)
 Returns a string which is the result of concatenating the character ch and the string s. More...
 
bool operator< (const char *s1, const QString &s2)
 
QDataStreamoperator<< (QDataStream &stream, const QString &string)
 Writes the given string to the specified stream. More...
 
bool operator<= (const char *s1, const QString &s2)
 
bool operator==operator== (const char *s1, const QString &s2)()
 
bool operator> (const char *s1, const QString &s2)
 
bool operator>= (const char *s1, const QString &s2)
 
QDataStreamoperator>> (QDataStream &stream, QString &string)
 Reads a string from the specified stream into the given string. More...
 

Detailed Description

The QString class provides a Unicode character string.

Note
This class or function is reentrant.

QString stores a string of 16-bit QChar, where each QChar corresponds one Unicode 4.0 character. (Unicode characters with code values above 65535 are stored using surrogate pairs, i.e., two consecutive QChar.)

Unicode is an international standard that supports most of the writing systems in use today. It is a superset of US-ASCII (ANSI X3.4-1986) and Latin-1 (ISO 8859-1), and all the US-ASCII/Latin-1 characters are available at the same code positions.

Behind the scenes, QString uses implicit sharing (copy-on-write) to reduce memory usage and to avoid the needless copying of data. This also helps reduce the inherent overhead of storing 16-bit characters instead of 8-bit characters.

In addition to QString, Qt also provides the QByteArray class to store raw bytes and traditional 8-bit '\0'-terminated strings. For most purposes, QString is the class you want to use. It is used throughout the Qt API, and the Unicode support ensures that your applications will be easy to translate if you want to expand your application's market at some point. The two main cases where QByteArray is appropriate are when you need to store raw binary data, and when memory conservation is critical (e.g., with Qt for Embedded Linux).

Initializing a String

One way to initialize a QString is simply to pass a const char to its constructor. For example, the following code creates a QString of size 5 containing the data "Hello":

QString str = "Hello";

QString converts the const char * data into Unicode using the fromAscii() function. By default, fromAscii() treats character above 128 as Latin-1 characters, but this can be changed by calling QTextCodec::setCodecForCStrings().

In all of the QString functions that take const char * parameters, the const char * is interpreted as a classic C-style '\0'-terminated string. It is legal for the const char parameter to be 0.

You can also provide string data as an array of QChar:

static const QChar data[4] = { 0x0055, 0x006e, 0x10e3, 0x03a3 };
QString str(data, 4);

QString makes a deep copy of the QChar data, so you can modify it later without experiencing side effects. (If for performance reasons you don't want to take a deep copy of the character data, use QString::fromRawData() instead.)

Another approach is to set the size of the string using resize() and to initialize the data character per character. QString uses 0-based indexes, just like C++ arrays. To access the character at a particular index position, you can use operator[]() . On non-const strings, operator[]() returns a reference to a character that can be used on the left side of an assignment. For example:

QString str;
str.resize(4);
str[0] = QChar('U');
str[1] = QChar('n');

For read-only access, an alternative syntax is to use the at() function:

}
void Widget::atFunction()
{

The at() function can be faster than operator[]() , because it never causes a deep copy to occur. Alternatively, use the left(), right(), or mid() functions to extract several characters at a time.

A QString can embed '\0' characters (QChar::Null). The size() function always returns the size of the whole string, including embedded '\0' characters.

After a call to the resize() function, newly allocated characters have undefined values. To set all the characters in the string to a particular value, use the fill() function.

QString provides dozens of overloads designed to simplify string usage. For example, if you want to compare a QString with a string literal, you can write code like this and it will work as expected:

QString str(data, 4);
}
void Widget::characterReference()
{
QString str;
str.resize(4);
str[0] = QChar('U');
str[1] = QChar('n');
str[2] = QChar(0x10e3);
str[3] = QChar(0x03a3);
}
void Widget::atFunction()
{
QString str;
for (int i = 0; i < str.size(); ++i) {
if (str.at(i) >= QChar('a') && str.at(i) <= QChar('f'))
qDebug() << "Found character in range [a-f]";
}
}
void Widget::stringLiteral()
{

You can also pass string literals to functions that take QStrings as arguments, invoking the QString(const char *) constructor. Similarly, you can pass a QString to a function that takes a const char * argument using the qPrintable() macro which returns the given QString as a const char *. This is equivalent to calling <QString>.toLocal8Bit().constData().

Manipulating String Data

QString provides the following basic functions for modifying the character data: append(), prepend(), insert(), replace(), and remove(). For example:

QString str = "and";
str.prepend("rock "); // str == "rock and"
str.append(" roll"); // str == "rock and roll"
str.replace(5, 3, "&"); // str == "rock & roll"

If you are building a QString gradually and know in advance approximately how many characters the QString will contain, you can call reserve(), asking QString to preallocate a certain amount of memory. You can also call capacity() to find out how much memory QString actually allocated.

The replace() and remove() functions' first two arguments are the position from which to start erasing and the number of characters that should be erased. If you want to replace all occurrences of a particular substring with another, use one of the two-parameter replace() overloads.

A frequent requirement is to remove whitespace characters from a string ('\n', '\t', ' ', etc.). If you want to remove whitespace from both ends of a QString, use the trimmed() function. If you want to remove whitespace from both ends and replace multiple consecutive whitespaces with a single space character within the string, use simplified().

If you want to find all occurrences of a particular character or substring in a QString, use the indexOf() or lastIndexOf() functions. The former searches forward starting from a given index position, the latter searches backward. Both return the index position of the character or substring if they find it; otherwise, they return -1. For example, here's a typical loop that finds all occurrences of a particular substring:

QString str = "We must be <b>bold</b>, very <b>bold</b>";
int j = 0;
while ((j = str.indexOf("<b>", j)) != -1) {
qDebug() << "Found <b> tag at index position" << j;
++j;
}

QString provides many functions for converting numbers into strings and strings into numbers. See the arg() functions, the setNum() functions, the number() static functions, and the toInt(), toDouble(), and similar functions.

To get an upper- or lowercase version of a string use toUpper() or toLower().

Lists of strings are handled by the QStringList class. You can split a string into a list of strings using the split() function, 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 QRegExp using the QStringList::filter() function.

Querying String Data

If you want to see if a QString starts or ends with a particular substring use startsWith() or endsWith(). If you simply want to check whether a QString contains a particular character or substring, use the contains() function. If you want to find out how many times a particular character or substring occurs in the string, use count().

QStrings can be compared using overloaded operators such as operator<() , operator<=() , operator==() , operator>=() , and so on. Note that the comparison is based exclusively on the numeric Unicode values of the characters. It is very fast, but is not what a human would expect; the QString::localeAwareCompare() function is a better choice for sorting user-interface strings.

To obtain a pointer to the actual character data, call data() or constData(). These functions return a pointer to the beginning of the QChar data. The pointer is guaranteed to remain valid until a non-const function is called on the QString.

Converting Between 8-Bit Strings and Unicode Strings

QString provides the following four functions that return a const char * version of the string as QByteArray: toAscii(), toLatin1(), toUtf8(), and toLocal8Bit().

To convert from one of these encodings, QString provides fromAscii(), fromLatin1(), fromUtf8(), and fromLocal8Bit(). Other encodings are supported through the QTextCodec class.

As mentioned above, QString provides a lot of functions and operators that make it easy to interoperate with const char * strings. But this functionality is a double-edged sword: It makes QString more convenient to use if all strings are US-ASCII or Latin-1, but there is always the risk that an implicit conversion from or to const char * is done using the wrong 8-bit encoding. To minimize these risks, you can turn off these implicit conversions by defining the following two preprocessor symbols:

One way to define these preprocessor symbols globally for your application is to add the following entry to your qmake Project Files{qmake project file}:

DEFINES += QT_NO_CAST_FROM_ASCII \
QT_NO_CAST_TO_ASCII

You then need to explicitly call fromAscii(), fromLatin1(), fromUtf8(), or fromLocal8Bit() to construct a QString from an 8-bit string, or use the lightweight QLatin1String class, for example:

QString url = QLatin1String("http://www.unicode.org/");

Similarly, you must call toAscii(), toLatin1(), toUtf8(), or toLocal8Bit() explicitly to convert the QString to an 8-bit string. (Other encodings are supported through the QTextCodec class.)

%

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 basic types. For example:

QString Widget::boolToString(bool b)
{
QString result;
if (b)
result = "True";
else
result = "False";
return result;
}

The result variable, is a normal variable allocated on the stack. When return is called, and 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.

Distinction Between Null and Empty Strings

For historical reasons, QString distinguishes between a null string and an empty string. A null string is a string that is initialized using QString's default constructor or by passing (const char *)0 to the constructor. An empty string is any string with size 0. A null string is always empty, but an empty string isn't necessarily null:

QString().isNull(); // returns true
QString().isEmpty(); // returns true
QString("").isNull(); // returns false
QString("").isEmpty(); // returns true
QString("abc").isNull(); // returns false
QString("abc").isEmpty(); // returns false

All functions except isNull() treat null strings the same as empty strings. For example, toAscii().constData() returns a pointer to a '\0' character for a null string (not a null pointer), and QString() compares equal to QString(""). We recommend that you always use the isEmpty() function and avoid isNull().

Argument Formats

In member functions where an argument format can be specified (e.g., arg(), number()), the argument format can be one of the following:

Format Meaning
e format as [-]9.9e[+|-]999
E format as [-]9.9E[+|-]999
f format as [-]9.9
g use e or f format, whichever is the most concise
G use E or f format, whichever is the most concise

A precision is also specified with the argument format. For the 'e', 'E', and 'f' formats, the precision represents the number of digits after the decimal point. For the 'g' and 'G' formats, the precision represents the maximum number of significant digits (trailing zeroes are omitted).

More Efficient String Construction

Using the QString '+' operator, it is easy to construct a complex string from multiple substrings. You will often write code like this:

QString foo;
QString type = "long";
foo->setText(QLatin1String("vector<") + type + QLatin1String(">::iterator"));
if (foo.startsWith("(" + type + ") 0x"))
...

There is nothing wrong with either of these string constructions, but there are a few hidden inefficiencies. Beginning with Qt 4.6, you can eliminate them.

First, multiple uses of the '+' operator usually means multiple memory allocations. When concatenating n substrings, where n > 2, there can be as many as n - 1 calls to the memory allocator.

Second, QLatin1String does not store its length internally but calls qstrlen() when it needs to know its length.

In 4.6, an internal template class QStringBuilder has been added along with a few helper functions. This class is marked internal and does not appear in the documentation, because you aren't meant to instantiate it in your code. Its use will be automatic, as described below. The class is found in {src/corelib/tools/qstringbuilder.cpp} if you want to have a look at it.

QStringBuilder uses expression templates and reimplements the '' operator so that when you use '' for string concatenation instead of '+', multiple substring concatenations will be postponed until the final result is about to be assigned to a QString. At this point, the amount of memory required for the final result is known. The memory allocator is then called once to get the required space, and the substrings are copied into it one by one.

QLatin1Literal is a second internal class that can replace QLatin1String, which can't be changed for compatibility reasons. QLatin1Literal stores its length, thereby saving time when QStringBuilder computes the amount of memory required for the final string.

Additional efficiency is gained by inlining and reduced reference counting (the QString created from a QStringBuilder typically has a ref count of 1, whereas QString::append() needs an extra test).

There are three ways you can access this improved method of string construction. The straightforward way is to include QStringBuilder wherever you want to use it, and use the '' operator instead of '+' when concatenating strings:

#include <QStringBuilder>
QString hello("hello");
QStringRef el(&hello, 2, 3);
QLatin1String world("world");
QString message = hello % el % world % QChar('!');

A more global approach which is the most convenient but not entirely source compatible, is to this define in your .pro file:

DEFINES *= QT_USE_QSTRINGBUILDER

and the '+' will automatically be performed as the QStringBuilder '' everywhere.

See also
fromRawData(), QChar, QLatin1String, QByteArray, QStringRef

Definition at line 83 of file qstring.h.

Typedefs

◆ const_iterator

The QString::const_iterator typedef provides an STL-style const iterator for QString.

See also
QString::iterator

Definition at line 467 of file qstring.h.

◆ const_reference

The QString::const_reference typedef provides an STL-style const reference for QString.

Since
4.8

Definition at line 478 of file qstring.h.

◆ ConstIterator

Qt-style synonym for QString::const_iterator.

Definition at line 469 of file qstring.h.

◆ DataPtr

Warning
This function is not part of the public interface.

Definition at line 649 of file qstring.h.

◆ iterator

The QString::iterator typedef provides an STL-style non-const iterator for QString.

See also
QString::const_iterator

Definition at line 466 of file qstring.h.

◆ Iterator

Qt-style synonym for QString::iterator.

Definition at line 468 of file qstring.h.

◆ reference

The QString::const_reference typedef provides an STL-style reference for QString.

Since
4.8

Definition at line 479 of file qstring.h.

◆ value_type

The QString::const_reference typedef provides an STL-style value type for QString.

Since
4.8

Definition at line 480 of file qstring.h.

Enumerations

◆ NormalizationForm

This enum describes the various normalized forms of Unicode text.

  • NormalizationForm_D Canonical Decomposition
  • NormalizationForm_C Canonical Decomposition followed by Canonical Composition
  • NormalizationForm_KD Compatibility Decomposition
  • NormalizationForm_KC Compatibility Decomposition followed by Canonical Composition
See also
normalized(), {http://www.unicode.org/reports/tr15/}{Unicode Standard Annex #15}
Enumerator
NormalizationForm_D 
NormalizationForm_C 
NormalizationForm_KD 
NormalizationForm_KC 

Definition at line 309 of file qstring.h.

◆ SectionFlag

This enum specifies flags that can be used to affect various aspects of the section() function's behavior with respect to separators and empty fields.

  • SectionDefault Empty fields are counted, leading and trailing separators are not included, and the separator is compared case sensitively.
  • SectionSkipEmpty Treat empty fields as if they don't exist, i.e. they are not considered as far as start and end are concerned.
  • SectionIncludeLeadingSep Include the leading separator (if any) in the result string.
  • SectionIncludeTrailingSep Include the trailing separator (if any) in the result string.
  • SectionCaseInsensitiveSeps Compare the separator case-insensitively.
See also
section()
Enumerator
SectionDefault 
SectionSkipEmpty 
SectionIncludeLeadingSep 
SectionIncludeTrailingSep 
SectionCaseInsensitiveSeps 

Definition at line 212 of file qstring.h.

◆ SplitBehavior

This enum specifies how the split() function should behave with respect to empty strings.

  • KeepEmptyParts If a field is empty, keep it in the result.
  • SkipEmptyParts If a field is empty, don't include it in the result.
See also
split()
Enumerator
KeepEmptyParts 
SkipEmptyParts 

Definition at line 299 of file qstring.h.

Constructors and Destructors

◆ QString() [1/12]

QString::QString ( )
inline

Constructs a null string.

Null strings are also empty.

See also
isEmpty()

Definition at line 879 of file qstring.h.

Referenced by clear(), fromAscii(), fromLatin1(), fromLocal8Bit(), fromRawData(), fromStdWString(), fromUcs4(), fromUtf16(), fromUtf8(), left(), mid(), operator=(), QSettingsKey::originalKeyPosition(), repeated(), right(), section(), simplified(), QStringRef::toString(), and trimmed().

879 : d(&shared_null) { d->ref.ref(); }
QBasicAtomicInt ref
Definition: qstring.h:604
static Data shared_null
Definition: qstring.h:616
Data * d
Definition: qstring.h:618

◆ QString() [2/12]

QString::QString ( const QChar unicode,
int  size 
)

Constructs a string initialized with the first size characters of the QChar array unicode.

QString makes a deep copy of the string data. The unicode data is copied as is and the Byte Order Mark is preserved if present.

Definition at line 1118 of file qstring.cpp.

1119 {
1120  if (!unicode) {
1121  d = &shared_null;
1122  d->ref.ref();
1123  } else if (size <= 0) {
1124  d = &shared_empty;
1125  d->ref.ref();
1126  } else {
1127  d = (Data*) qMalloc(sizeof(Data)+size*sizeof(QChar));
1128  Q_CHECK_PTR(d);
1129  d->ref = 1;
1130  d->alloc = d->size = size;
1131  d->clean = d->asciiCache = d->simpletext = d->righttoleft = d->capacity = 0;
1132  d->data = d->array;
1133  memcpy(d->array, unicode, size * sizeof(QChar));
1134  d->array[size] = '\0';
1135  }
1136 }
ushort capacity
Definition: qstring.h:611
ushort clean
Definition: qstring.h:607
Q_CORE_EXPORT void * qMalloc(size_t size)
Definition: qmalloc.cpp:53
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
QBasicAtomicInt ref
Definition: qstring.h:604
static Data shared_null
Definition: qstring.h:616
int size() const
Returns the number of characters in this string.
Definition: qstring.h:102
Data * d
Definition: qstring.h:618
ushort * data
Definition: qstring.h:606
#define Q_CHECK_PTR(p)
Definition: qglobal.h:1853
ushort array[1]
Definition: qstring.h:614
ushort righttoleft
Definition: qstring.h:609
ushort simpletext
Definition: qstring.h:608
ushort asciiCache
Definition: qstring.h:610
static Data shared_empty
Definition: qstring.h:617

◆ QString() [3/12]

QString::QString ( const QChar unicode)
explicit

Constructs a string initialized with the characters of the QChar array unicode, which must be terminated with a 0.

Since
4.7

QString makes a deep copy of the string data. The unicode data is copied as is and the Byte Order Mark is preserved if present.

Definition at line 1150 of file qstring.cpp.

1151 {
1152  if (!unicode) {
1153  d = &shared_null;
1154  d->ref.ref();
1155  } else {
1156  int size = 0;
1157  while (unicode[size] != 0)
1158  ++size;
1159  if (!size) {
1160  d = &shared_empty;
1161  d->ref.ref();
1162  } else {
1163  d = (Data*) qMalloc(sizeof(Data)+size*sizeof(QChar));
1164  Q_CHECK_PTR(d);
1165  d->ref = 1;
1166  d->alloc = d->size = size;
1167  d->clean = d->asciiCache = d->simpletext = d->righttoleft = d->capacity = 0;
1168  d->data = d->array;
1169  memcpy(d->array, unicode, size * sizeof(QChar));
1170  d->array[size] = '\0';
1171  }
1172  }
1173 }
ushort capacity
Definition: qstring.h:611
ushort clean
Definition: qstring.h:607
Q_CORE_EXPORT void * qMalloc(size_t size)
Definition: qmalloc.cpp:53
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
QBasicAtomicInt ref
Definition: qstring.h:604
static Data shared_null
Definition: qstring.h:616
int size() const
Returns the number of characters in this string.
Definition: qstring.h:102
Data * d
Definition: qstring.h:618
ushort * data
Definition: qstring.h:606
#define Q_CHECK_PTR(p)
Definition: qglobal.h:1853
ushort array[1]
Definition: qstring.h:614
ushort righttoleft
Definition: qstring.h:609
ushort simpletext
Definition: qstring.h:608
ushort asciiCache
Definition: qstring.h:610
static Data shared_empty
Definition: qstring.h:617

◆ QString() [4/12]

QString::QString ( QChar  c)

Constructs a string of size 1 containing the character ch.

Definition at line 1236 of file qstring.cpp.

1237 {
1238  void *buf = qMalloc(sizeof(Data) + sizeof(QChar));
1239  Q_CHECK_PTR(buf);
1240  d = reinterpret_cast<Data *>(buf);
1241  d->ref = 1;
1242  d->alloc = d->size = 1;
1243  d->clean = d->asciiCache = d->simpletext = d->righttoleft = d->capacity = 0;
1244  d->data = d->array;
1245  d->array[0] = ch.unicode();
1246  d->array[1] = '\0';
1247 }
ushort capacity
Definition: qstring.h:611
ushort clean
Definition: qstring.h:607
Q_CORE_EXPORT void * qMalloc(size_t size)
Definition: qmalloc.cpp:53
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
QBasicAtomicInt ref
Definition: qstring.h:604
Data * d
Definition: qstring.h:618
ushort * data
Definition: qstring.h:606
#define Q_CHECK_PTR(p)
Definition: qglobal.h:1853
ushort array[1]
Definition: qstring.h:614
ushort righttoleft
Definition: qstring.h:609
ushort simpletext
Definition: qstring.h:608
ushort asciiCache
Definition: qstring.h:610

◆ QString() [5/12]

QString::QString ( int  size,
QChar  ch 
)

Constructs a string of the given size with every character set to ch.

See also
fill()

Definition at line 1182 of file qstring.cpp.

1183 {
1184  if (size <= 0) {
1185  d = &shared_empty;
1186  d->ref.ref();
1187  } else {
1188  d = (Data*) qMalloc(sizeof(Data)+size*sizeof(QChar));
1189  Q_CHECK_PTR(d);
1190  d->ref = 1;
1191  d->alloc = d->size = size;
1192  d->clean = d->asciiCache = d->simpletext = d->righttoleft = d->capacity = 0;
1193  d->data = d->array;
1194  d->array[size] = '\0';
1195  ushort *i = d->array + size;
1196  ushort *b = d->array;
1197  const ushort value = ch.unicode();
1198  while (i != b)
1199  *--i = value;
1200  }
1201 }
ushort unicode() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qchar.h:251
ushort capacity
Definition: qstring.h:611
ushort clean
Definition: qstring.h:607
Q_CORE_EXPORT void * qMalloc(size_t size)
Definition: qmalloc.cpp:53
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
QBasicAtomicInt ref
Definition: qstring.h:604
int size() const
Returns the number of characters in this string.
Definition: qstring.h:102
Data * d
Definition: qstring.h:618
ushort * data
Definition: qstring.h:606
#define Q_CHECK_PTR(p)
Definition: qglobal.h:1853
unsigned short ushort
Definition: qglobal.h:995
ushort array[1]
Definition: qstring.h:614
ushort righttoleft
Definition: qstring.h:609
ushort simpletext
Definition: qstring.h:608
ushort asciiCache
Definition: qstring.h:610
static Data shared_empty
Definition: qstring.h:617

◆ QString() [6/12]

QString::QString ( const QLatin1String str)
inline

Constructs a copy of the Latin-1 string str.

See also
fromLatin1()

Definition at line 694 of file qstring.h.

694  : d(fromLatin1_helper(aLatin1.latin1()))
695 { }
Data * d
Definition: qstring.h:618
static Data * fromLatin1_helper(const char *str, int size=-1)
Definition: qstring.cpp:4104

◆ QString() [7/12]

QString::QString ( const QString other)
inline

Constructs a copy of other.

This operation takes constant time, because QString is implicitly shared. This makes returning a QString from a function very fast. If a shared instance is modified, it will be copied (copy-on-write), and that takes linear time.

See also
operator=()

Definition at line 725 of file qstring.h.

725  : d(other.d)
726 { Q_ASSERT(&other != this); d->ref.ref(); }
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
QBasicAtomicInt ref
Definition: qstring.h:604
Data * d
Definition: qstring.h:618

◆ ~QString()

QString::~QString ( )
inline

Destroys the string.

Definition at line 880 of file qstring.h.

880 { if (!d->ref.deref()) free(d); }
QBasicAtomicInt ref
Definition: qstring.h:604
static void free(Data *)
Definition: qstring.cpp:1311
Data * d
Definition: qstring.h:618

◆ QString() [8/12]

QString::QString ( const char *  str)
inline

Constructs a string initialized with the 8-bit string str.

The given const char pointer is converted to Unicode using the fromAscii() function.

You can disable this constructor by defining QT_NO_CAST_FROM_ASCII when you compile your applications. This can be useful if you want to ensure that all user-visible strings go through QObject::tr(), for example.

See also
fromAscii(), fromLatin1(), fromLocal8Bit(), fromUtf8()

Definition at line 419 of file qstring.h.

419  : d(fromAscii_helper(ch))
420  {}
static Data * fromAscii_helper(const char *str, int size=-1)
Definition: qstring.cpp:4155
Data * d
Definition: qstring.h:618

◆ QString() [9/12]

QString::QString ( const QByteArray ba)
inline

Constructs a string initialized with the byte array ba.

The given byte array is converted to Unicode using fromAscii(). Stops copying at the first 0 character, otherwise copies the entire byte array.

You can disable this constructor by defining QT_NO_CAST_FROM_ASCII when you compile your applications. This can be useful if you want to ensure that all user-visible strings go through QObject::tr(), for example.

See also
fromAscii(), fromLatin1(), fromLocal8Bit(), fromUtf8()

Definition at line 421 of file qstring.h.

422  : d(fromAscii_helper(a.constData(), qstrnlen(a.constData(), a.size())))
423  {}
long ASN1_INTEGER_get ASN1_INTEGER * a
static Data * fromAscii_helper(const char *str, int size=-1)
Definition: qstring.cpp:4155
Data * d
Definition: qstring.h:618
uint qstrnlen(const char *str, uint maxlen)
Definition: qbytearray.h:82

◆ QString() [10/12]

QString::QString ( const Null )
inline
Warning
This function is not part of the public interface.

Definition at line 503 of file qstring.h.

503 : d(&shared_null) { d->ref.ref(); }
QBasicAtomicInt ref
Definition: qstring.h:604
static Data shared_null
Definition: qstring.h:616
Data * d
Definition: qstring.h:618

◆ QString() [11/12]

QString::QString ( int  size,
Qt::Initialization   
)

Constructs a string of the given size without initializing the characters.

Warning
This function is not part of the public interface.

This is only used in QStringBuilder::toString().

Definition at line 1212 of file qstring.cpp.

1213 {
1214  d = (Data*) qMalloc(sizeof(Data)+size*sizeof(QChar));
1215  Q_CHECK_PTR(d);
1216  d->ref = 1;
1217  d->alloc = d->size = size;
1218  d->clean = d->asciiCache = d->simpletext = d->righttoleft = d->capacity = 0;
1219  d->data = d->array;
1220  d->array[size] = '\0';
1221 }
ushort capacity
Definition: qstring.h:611
ushort clean
Definition: qstring.h:607
Q_CORE_EXPORT void * qMalloc(size_t size)
Definition: qmalloc.cpp:53
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
QBasicAtomicInt ref
Definition: qstring.h:604
int size() const
Returns the number of characters in this string.
Definition: qstring.h:102
Data * d
Definition: qstring.h:618
ushort * data
Definition: qstring.h:606
#define Q_CHECK_PTR(p)
Definition: qglobal.h:1853
ushort array[1]
Definition: qstring.h:614
ushort righttoleft
Definition: qstring.h:609
ushort simpletext
Definition: qstring.h:608
ushort asciiCache
Definition: qstring.h:610

◆ QString() [12/12]

QString::QString ( Data dd,
int   
)
inlineprivate

Definition at line 619 of file qstring.h.

619 : d(dd) {}
Data * d
Definition: qstring.h:618

Functions

◆ append() [1/6]

QString & QString::append ( QChar  c)

Definition at line 1777 of file qstring.cpp.

Referenced by _q_escapeIdentifier(), QScriptDebuggerLocalsWidgetPrivate::_q_onCompletionTaskFinished(), QScriptDebuggerConsoleWidgetPrivate::_q_onCompletionTaskFinished(), QPrintPreviewDialogPrivate::_q_print(), QFileSystemEngine::absoluteName(), QZipWriter::addDirectory(), QScriptDebuggerLocalsModelPrivate::addTopLevelObject(), QByteArray::append(), QCoreApplication::applicationFilePath(), QPatternist::XQueryTokenizer::attributeAsRaw(), QAccessibleTextWidget::attributes(), QDeclarativeCompiler::buildDynamicMeta(), QScript::callQtMethod(), QPatternist::ColorOutput::colorify(), QPatternist::ColoringMessageHandler::colorifyDescription(), comify(), QMultiScreen::connect(), QScriptDebuggerConsole::consumeInput(), QWindowsLocalCodec::convertToUnicode(), QWindowsLocalCodec::convertToUnicodeCharByChar(), QScriptDebuggerConsolePrivate::createJob(), QAbstractFileEngineIterator::currentFilePath(), QScriptDebuggerLocalsModel::data(), QScriptBreakpointsModel::data(), QLocalePrivate::dateTimeToString(), decimalForm(), QSqlTableModel::deleteRowFromTable(), QSvgText::draw(), QRegExp::escape(), QPatternist::ColorOutputPrivate::escapeCode(), QDB2Driver::escapeIdentifier(), QIBaseDriver::escapeIdentifier(), QOCIDriver::escapeIdentifier(), QSQLite2Driver::escapeIdentifier(), QTDSDriver::escapeIdentifier(), QMYSQLDriver::escapeIdentifier(), QPSQLDriver::escapeIdentifier(), QODBCDriver::escapeIdentifier(), QPatternist::CodepointsToStringFN::evaluateSingleton(), exponentForm(), extractEncodingDecl(), QDeclarativeScriptParser::extractMetaData(), QFileSystemModelPrivate::filePath(), QTextBrowserPrivate::findFile(), fixedCharData(), fixedXmlName(), QTest::formatResult(), QTDSDriver::formatValue(), QMYSQLDriver::formatValue(), QScript::functionConnect(), QScript::functionPrint(), QBBSystemLocaleData::getCorrectFormat(), QSslSocketBackendPrivate::getErrorsFromOpenSsl(), QScriptCompleteScriptsJob::handleResponse(), QDeclarativeXMLHttpRequest::headers(), QScriptEngine::importExtension(), QScriptDebuggerLocalsModel::init(), init_platform(), initializeDb(), QTextDocumentPrivate::insert(), QTextDocumentPrivate::insertBlock(), isDirPath(), QSystemLibrary::load(), QFSFileEnginePrivate::longFileName(), QSharedMemoryPrivate::makePlatformSafeKey(), QScriptDebuggerConsoleWidget::message(), QScriptDebugOutputWidget::message(), QScriptErrorLogWidget::message(), QScriptStdMessageHandler::message(), QXlibMime::mimeAtomForFormat(), QFileSystemEngine::nativeAbsoluteFilePath(), QScriptEnginePrivate::newRegExp(), QPatternist::TokenRevealer::nextToken(), QPatternist::XQueryTokenizer::nextToken(), QFileSystemModelPrivate::node(), QPatternist::XQueryTokenizer::normalizeEOL(), QDBusXmlParser::objectTree(), QPSQLDriver::open(), QTemporaryFileEngine::open(), QSqlRelationalTableModel::orderByClause(), QSqlTableModel::orderByClause(), QDeclarativeStyledTextPrivate::parse(), QScriptXmlParser::parse(), parseCSStoXMLAttrs(), QPatternist::PatternPlatform::parseFlags(), QCss::Parser::parseFunction(), parseStopNode(), QTextHtmlParserNode::parseStyleAttribute(), QDeclarativeStyledTextPrivate::parseTag(), QSvgIconEnginePrivate::pmcKey(), QPSQLResult::prepare(), QApplicationPrivate::process_cmdline(), QTextStreamPrivate::putString(), qAppendWhereClause(), qCreateParamString(), QFileSystemIterator::QFileSystemIterator(), qGetTableInfo(), qIsEffectiveTLD(), qQuote(), QScriptDebuggerBackendPrivate::qsassert(), qt_readEscapedFormatString(), qws_dataDir(), qws_fontCacheDir(), readSourceFile(), QSqlRelationalTableModelPrivate::relationField(), QDeclarativeXMLHttpRequest::requestFromUrl(), QGLTextureGlyphCache::resizeTextureData(), QDeclarativeCompiledBindingsPrivate::run(), QSqlRelationalTableModel::selectStatement(), QSqlTableModel::selectStatement(), QPatternist::AbstractDuration::serializeMSeconds(), QPatternist::AbstractDateTime::serializeMSeconds(), QDeclarativeEngineDebugService::setMethodBody(), QUndoAction::setPrefixedText(), QGtkStylePrivate::setupGtkFileChooser(), QFileSystemEngine::slowCanonicalized(), QSettingsPrivate::splitArgs(), QFSCompleter::splitPath(), QSqlDriver::sqlStatement(), QPatternist::YearMonthDuration::stringValue(), QPatternist::Duration::stringValue(), QPatternist::DayTimeDuration::stringValue(), QConfFileSettingsPrivate::syncConfFile(), QPatternist::XsdInstanceReader::text(), QPatternist::XQueryTokenizer::tokenizeStringLiteral(), QProcessEnvironmentPrivate::toList(), QScriptContext::toString(), QHostAddress::toString(), QScriptDebuggerBackendPrivate::trace(), QSqlTableModel::updateRowInTable(), QSpinBoxValidator::validate(), vsprintf(), QXmlStreamWriterPrivate::write(), QXmlStreamWriterPrivate::writeEscaped(), QX11Data::xdndMimeAtomForFormat(), and QPatternist::AbstractDateTime::zoneOffsetToString().

1778 {
1779  if (d->ref != 1 || d->size + 1 > d->alloc)
1780  realloc(grow(d->size + 1));
1781  d->data[d->size++] = ch.unicode();
1782  d->data[d->size] = '\0';
1783  return *this;
1784 }
void realloc()
Definition: qstring.cpp:1472
QBasicAtomicInt ref
Definition: qstring.h:604
Data * d
Definition: qstring.h:618
ushort * data
Definition: qstring.h:606
static int grow(int)
Definition: qstring.cpp:822

◆ append() [2/6]

QString & QString::append ( const QString str)

Appends the string str onto the end of this string.

Example:

QString x = "free";
QString y = "dom";
x.append(y);
// x == "freedom"

This is the same as using the insert() function:

x.insert(x.size(), y);

The append() function is typically very fast (constant time), because QString preallocates extra space at the end of the string data so it can grow without reallocating the entire string each time.

See also
operator+=(), prepend(), insert()

Definition at line 1701 of file qstring.cpp.

1702 {
1703  if (str.d != &shared_null) {
1704  if (d == &shared_null) {
1705  operator=(str);
1706  } else {
1707  if (d->ref != 1 || d->size + str.d->size > d->alloc)
1708  realloc(grow(d->size + str.d->size));
1709  memcpy(d->data + d->size, str.d->data, str.d->size * sizeof(QChar));
1710  d->size += str.d->size;
1711  d->data[d->size] = '\0';
1712  }
1713  }
1714  return *this;
1715 }
void realloc()
Definition: qstring.cpp:1472
QString & operator=(QChar c)
Definition: qstring.cpp:1582
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
QBasicAtomicInt ref
Definition: qstring.h:604
static Data shared_null
Definition: qstring.h:616
Data * d
Definition: qstring.h:618
ushort * data
Definition: qstring.h:606
static int grow(int)
Definition: qstring.cpp:822

◆ append() [3/6]

QString & QString::append ( const QStringRef reference)

Appends the given string reference to this string and returns the result.

Since
4.4

Definition at line 9017 of file qstring.cpp.

9018 {
9019  if (str.string() == this) {
9020  str.appendTo(this);
9021  } else if (str.string()) {
9022  int oldSize = size();
9023  resize(oldSize + str.size());
9024  memcpy(data() + oldSize, str.unicode(), str.size() * sizeof(QChar));
9025  }
9026  return *this;
9027 }
ushort unicode() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qchar.h:251
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
QChar * data()
Returns a pointer to the data stored in the QString.
Definition: qstring.h:710
int size() const
Returns the number of characters in this string.
Definition: qstring.h:102
void resize(int size)
Sets the size of the string to size characters.
Definition: qstring.cpp:1353

◆ append() [4/6]

QString & QString::append ( const QLatin1String s)

Definition at line 1725 of file qstring.cpp.

1726 {
1727  const uchar *s = (const uchar *)str.latin1();
1728  if (s) {
1729  int len = qstrlen((char *)s);
1730  if (d->ref != 1 || d->size + len > d->alloc)
1731  realloc(grow(d->size + len));
1732  ushort *i = d->data + d->size;
1733  while ((*i++ = *s++))
1734  ;
1735  d->size += len;
1736  }
1737  return *this;
1738 }
void realloc()
Definition: qstring.cpp:1472
QBasicAtomicInt ref
Definition: qstring.h:604
unsigned char uchar
Definition: qglobal.h:994
const char * latin1() const
Returns the Latin-1 string stored in this object.
Definition: qstring.h:661
Data * d
Definition: qstring.h:618
ushort * data
Definition: qstring.h:606
uint qstrlen(const char *str)
Definition: qbytearray.h:79
unsigned short ushort
Definition: qglobal.h:995
static int grow(int)
Definition: qstring.cpp:822

◆ append() [5/6]

QT_ASCII_CAST_WARN QString& QString::append ( const char *  s)
inline

Definition at line 436 of file qstring.h.

437  { return append(QString::fromAscii(s)); }
static QString fromAscii(const char *, int size=-1)
Returns a QString initialized with the first size characters from the string str. ...
Definition: qstring.cpp:4276
QString & append(QChar c)
Definition: qstring.cpp:1777

◆ append() [6/6]

QT_ASCII_CAST_WARN QString& QString::append ( const QByteArray s)
inline

Definition at line 438 of file qstring.h.

439  { return append(QString::fromAscii(s.constData(), qstrnlen(s.constData(), s.size()))); }
static QString fromAscii(const char *, int size=-1)
Returns a QString initialized with the first size characters from the string str. ...
Definition: qstring.cpp:4276
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
QString & append(QChar c)
Definition: qstring.cpp:1777
uint qstrnlen(const char *str, uint maxlen)
Definition: qbytearray.h:82
int size() const
Returns the number of bytes in this byte array.
Definition: qbytearray.h:402

◆ arg() [1/20]

QString QString::arg ( qlonglong  a,
int  fieldwidth = 0,
int  base = 10,
const QChar fillChar = QLatin1Char(' ') 
) const

Definition at line 7186 of file qstring.cpp.

Referenced by QFileDialogPrivate::_q_goToDirectory(), QFtpPrivate::_q_piError(), QMessageBox::aboutQt(), QFileDialog::accept(), QDeclarativeImportsPrivate::add(), QGraphicsAnchorLayoutPrivate::addAnchor_helper(), QLocalServerPrivate::addListener(), RequestAnalyzer::analyze(), QDeclarativeXmlListModelPrivate::append_role(), QPSQLDriverPrivate::appendTables(), arg(), QSharedMemoryPrivate::attach(), QAccessibleTextWidget::attributes(), buildMatchRule(), QDeclarativeObjectMethodScriptClass::callPrecise(), QScript::callQtMethod(), QPatternist::XsdTypeChecker::checkConstrainingFacetsQName(), QUnixPrintWidgetPrivate::checkFields(), checkHRESULT(), QDBusPendingCallPrivate::checkReceivedSignature(), QCoreApplicationPrivate::checkReceiverThread(), QBenchmarkValgrindUtils::cleanup(), QGraphicsWidget::close(), QDeclarativeGestureAreaParser::compile(), QDeclarativeConnectionsParser::compile(), QVNCScreen::connect(), QMultiScreen::connect(), QTransformedScreen::connect(), QDeclarativeConnections::connectSignals(), QFile::copy(), QSharedMemory::create(), QSharedMemoryPrivate::create(), QPatternist::XsdSchemaParserContext::createAnonymousName(), createArrayBuffer(), createPixmapDataSync(), QDeclarativeAbstractAnimationPrivate::createProperty(), QLocale::createSeparatedList(), createSequence(), QOutputStrategy::createUniqueImageName(), QScriptDebuggerStackModel::data(), QScriptDebuggerScriptsModel::data(), QScriptBreakpointsModel::data(), QGraphicsSceneBspTree::debug(), QScriptDebuggerPrivate::debuggerEvent(), decodeMSG(), QScript::QObjectDelegate::deleteProperty(), derivedTermValid(), QPatternist::Expression::description(), QSharedMemoryPrivate::detach(), divZeroInvalid(), QWindowsXPStylePrivate::drawBackgroundThruNativeBuffer(), QMacStylePrivate::drawCombobox(), QWindowsVistaStyle::drawControl(), QGtkStyle::drawControl(), QWindowsVistaStyle::drawPrimitive(), QMacStylePrivate::drawTableHeader(), QGridLayoutRowInfo::dump(), QGraphicsAnchorLayoutPrivate::dumpGraph(), QSimplex::dumpMatrix(), dumpRecursive(), QPdfEnginePrivate::embedFont(), QKeySequencePrivate::encodeString(), QPatternist::ReplaceFN::errorAtEnd(), QHttpNetworkConnectionPrivate::errorDetail(), QWorkspace::eventFilter(), QPSQLResult::exec(), QScript::QMetaObjectWrapperObject::execute(), QDeclarativeImportedNamespace::find(), QDeclarativeImportsPrivate::find(), QDBusMetaObjectGenerator::findType(), QHttpThreadDelegate::finishedSlot(), QMinimalWindowSurface::flush(), fromScriptValue(), QNetworkAccessFtpBackend::ftpDone(), QScript::functionConnect(), QScript::functionDisconnect(), QSvgPaintEnginePrivate::generateGradientName(), generateInterfaceXml(), generateSubObjectXml(), QNativeWifiEngine::getInterfaceFromId(), QBenchmarkValgrindUtils::getNewestFileName(), QScript::QObjectDelegate::getOwnPropertyDescriptor(), QScript::QObjectDelegate::getOwnPropertySlot(), QFileIconProviderPrivate::getWinIcon(), QSystemSemaphorePrivate::handle(), QSharedMemoryPrivate::handle(), QDBusConnectionPrivate::handleObjectCall(), idivZeroInvalid(), QDeclarativeImportsPrivate::importExtension(), QDeclarativeImportDatabase::importPlugin(), QLocalSocketPrivate::init(), QPrintPreviewDialogPrivate::init(), init_platform(), QSharedMemoryPrivate::initKey(), QDeclarativeListModel::insert(), QDeclarativeDebugServer::instance(), QXmlSimpleReaderPrivate::isExpandedEntityValueTooLarge(), QLibraryPrivate::isPlugin(), QPatternist::CastingPlatform< UntypedAtomicConverter, true >::issueCastError(), QPatternist::XsdSchemaHelper::isValidAttributeUsesExtension(), QPatternist::XsdSchemaHelper::isValidAttributeUsesRestriction(), QPatternist::XsdTypeChecker::isValidString(), jump(), QPlatformIntegrationFactory::keys(), QLocalServer::listen(), QLibraryPrivate::load_sys(), QSystemTrayIconSys::locateSystemTray(), QSharedMemory::lock(), modZeroInvalid(), QTest::mouseEvent(), multiArg(), QPatternist::NCNameConstructor::nameIsXML(), QNetworkAccessCacheBackend::open(), QNetworkAccessFileBackend::open(), QAudioDeviceInfoInternal::open(), QOCIDriver::open(), QAudioInputPrivate::open(), QAudioOutputPrivate::open(), operator<<(), QBenchmarkValgrindUtils::outFileBase(), ParallelAnchorData::ParallelAnchorData(), QDateTimeParser::parse(), QScriptDebuggerAgent::positionChange(), QPSQLResult::prepare(), QHttpNetworkConnectionPrivate::prepareRequest(), QMYSQLDriver::primaryIndex(), QPSQLDriver::primaryIndex(), QDeclarativePixmapReader::processJob(), QDBusAbstractInterfacePrivate::property(), QDeclarativePropertyChangesPrivate::property(), QScript::QObjectDelegate::put(), qax_docuFromName(), QSvgPaintEngine::qbrushToSvg(), qDBusGenerateMetaObjectXml(), qDBusIntrospectObject(), qDBusReplyFill(), qExtractSecurityPolicyFromString(), qMakeError(), QNetworkReplyDataImpl::QNetworkReplyDataImpl(), QNetworkReplyFileImpl::QNetworkReplyFileImpl(), QScript::qobjectProtoFuncToString(), QScriptDebuggerBackendPrivate::qsassert(), qt_eval_string(), QApplicationPrivate::qt_mac_apply_settings(), qt_mac_menu_merge_text(), qt_parse_pattern(), qt_parsePrinterDesc(), qt_parsePrintersConf(), qTdsErrHandler(), qTdsMsgHandler(), QDeclarativeXmlListModel::queryError(), rasterFallbackWarn(), QAudioInputPrivate::read(), MetaObjectGenerator::readClassInfo(), readImage(), QNetworkAccessFileBackend::readMoreFromFile(), QOCIDriver::record(), QTDSDriver::record(), QPSQLDriver::record(), QDeclarativeListModel::remove(), replacePercentN(), QGraphicsAnchorLayoutPrivate::replaceVertex(), QSslSocketPrivate::resetDefaultCiphers(), QLibraryPrivate::resolve_sys(), QDeclarativeCompiledBindingsPrivate::run(), QSvgPaintEngine::saveGradientStops(), QScript::Lexer::scanRegExp(), QDeclarativeJS::Lexer::scanRegExp(), QPatternist::XsdValidatingInstanceReader::selectNodeSets(), QSqlRelationalTableModel::selectStatement(), QDBusConnectionPrivate::sendError(), SequentialAnchorData::SequentialAnchorData(), Graph< AnchorVertex, AnchorData >::serializeToDot(), QDeclarativeListModel::set(), QLocalServerPrivate::setError(), QStateMachinePrivate::setError(), QSocks5SocketEnginePrivate::setErrorState(), QSystemSemaphorePrivate::setErrorString(), QLocalSocketPrivate::setErrorString(), QSharedMemoryPrivate::setErrorString(), QMdiSubWindowPrivate::setNewWindowTitle(), QUndoAction::setPrefixedText(), QDeclarativeListModel::setProperty(), AVMediaObject::setSource(), QDirModelPrivate::size(), QFileSystemModelPrivate::size(), standardLibraryErrorString(), QXmlStreamReaderPrivate::startDocument(), QSvgHandler::startElement(), QScript::stringProtoFuncArg(), QHttpThreadDelegate::synchronousFinishedSlot(), QSQLiteDriver::tables(), QAudioDeviceInfoInternal::testSettings(), QAccessibleItemRow::text(), QLocale::toCurrencyString(), QTextHtmlExporter::toHtml(), QBenchmarkContext::toString(), AnchorVertex::toString(), QDate::toString(), QSimplexConstraint::toString(), QHttpResponseHeader::toString(), AnchorData::toString(), QHttpRequestHeader::toString(), QTime::toString(), GraphPath::toString(), translate_color(), translate_dashPattern(), QSharedMemoryPrivate::tryLocker(), QPatternist::XSLTTokenizer::unexpectedContent(), QLibraryPrivate::unload_sys(), QSharedMemory::unlock(), QDeclarativeBinding::update(), QFactoryLoader::updateDir(), QNetworkAccessFileBackend::uploadReadyReadSlot(), QPatternist::XsdValidatingInstanceReader::validate(), QPatternist::MaintainingReader< XSLTTokenLookup >::validateElement(), QScript::variantProtoFuncToString(), vsprintf(), QIBaseResultPrivate::writeArray(), QTextOdfWriter::writeCharacterFormat(), QTextOdfWriter::writeListFormat(), QPatternist::CardinalityVerifier::wrongCardinality(), QPatternist::TypeChecker::wrongType(), and QApplicationPrivate::x11_apply_settings().

7187 {
7188  ArgEscapeData d = findArgEscapes(*this);
7189 
7190  if (d.occurrences == 0) {
7191  qWarning() << "QString::arg: Argument missing:" << *this << ',' << a;
7192  return *this;
7193  }
7194 
7195  unsigned flags = QLocalePrivate::NoFlags;
7196  if (fillChar == QLatin1Char('0'))
7198 
7199  QString arg;
7200  if (d.occurrences > d.locale_occurrences)
7201  arg = QLocale::c().d()->longLongToString(a, -1, base, fieldWidth, flags);
7202 
7203  QString locale_arg;
7204  if (d.locale_occurrences > 0) {
7205  QLocale locale;
7208  locale_arg = locale.d()->longLongToString(a, -1, base, fieldWidth, flags);
7209  }
7210 
7211  return replaceArgEscapes(*this, d, fieldWidth, arg, locale_arg, fillChar);
7212 }
long ASN1_INTEGER_get ASN1_INTEGER * a
The QString class provides a Unicode character string.
Definition: qstring.h:83
static const uint base
Definition: qurl.cpp:268
NumberOptions numberOptions() const
Returns the options related to number conversions for this QLocale instance.
Definition: qlocale.cpp:802
static QString longLongToString(const QChar zero, const QChar group, const QChar plus, const QChar minus, qint64 l, int precision, int base, int width, unsigned flags)
Definition: qlocale.cpp:2775
Q_CORE_EXPORT void qWarning(const char *,...)
static QString replaceArgEscapes(const QString &s, const ArgEscapeData &d, int field_width, const QString &arg, const QString &larg, const QChar &fillChar=QLatin1Char(' '))
Definition: qstring.cpp:6839
int locale_occurrences
Definition: qstring.cpp:6775
Data * d
Definition: qstring.h:618
const QLocalePrivate * d() const
Definition: qlocale.cpp:761
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
Definition: qstring.cpp:7186
static QLocale c()
Returns a QLocale object initialized to the "C" locale.
Definition: qlocale.h:773
static ArgEscapeData findArgEscapes(const QString &s)
Definition: qstring.cpp:6780
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ arg() [2/20]

QString QString::arg ( qulonglong  a,
int  fieldwidth = 0,
int  base = 10,
const QChar fillChar = QLatin1Char(' ') 
) const

Definition at line 7233 of file qstring.cpp.

7234 {
7235  ArgEscapeData d = findArgEscapes(*this);
7236 
7237  if (d.occurrences == 0) {
7238  qWarning() << "QString::arg: Argument missing:" << *this << ',' << a;
7239  return *this;
7240  }
7241 
7242  unsigned flags = QLocalePrivate::NoFlags;
7243  if (fillChar == QLatin1Char('0'))
7245 
7246  QString arg;
7247  if (d.occurrences > d.locale_occurrences)
7248  arg = QLocale::c().d()->unsLongLongToString(a, -1, base, fieldWidth, flags);
7249 
7250  QString locale_arg;
7251  if (d.locale_occurrences > 0) {
7252  QLocale locale;
7255  locale_arg = locale.d()->unsLongLongToString(a, -1, base, fieldWidth, flags);
7256  }
7257 
7258  return replaceArgEscapes(*this, d, fieldWidth, arg, locale_arg, fillChar);
7259 }
long ASN1_INTEGER_get ASN1_INTEGER * a
The QString class provides a Unicode character string.
Definition: qstring.h:83
static const uint base
Definition: qurl.cpp:268
NumberOptions numberOptions() const
Returns the options related to number conversions for this QLocale instance.
Definition: qlocale.cpp:802
static QString unsLongLongToString(const QChar zero, const QChar group, const QChar plus, quint64 l, int precision, int base, int width, unsigned flags)
Definition: qlocale.cpp:2870
Q_CORE_EXPORT void qWarning(const char *,...)
static QString replaceArgEscapes(const QString &s, const ArgEscapeData &d, int field_width, const QString &arg, const QString &larg, const QChar &fillChar=QLatin1Char(' '))
Definition: qstring.cpp:6839
int locale_occurrences
Definition: qstring.cpp:6775
Data * d
Definition: qstring.h:618
const QLocalePrivate * d() const
Definition: qlocale.cpp:761
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
Definition: qstring.cpp:7186
static QLocale c()
Returns a QLocale object initialized to the "C" locale.
Definition: qlocale.h:773
static ArgEscapeData findArgEscapes(const QString &s)
Definition: qstring.cpp:6780
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ arg() [3/20]

QString QString::arg ( long  a,
int  fieldwidth = 0,
int  base = 10,
const QChar fillChar = QLatin1Char(' ') 
) const
inline

Definition at line 747 of file qstring.h.

748 { return arg(qlonglong(a), fieldWidth, base, fillChar); }
long ASN1_INTEGER_get ASN1_INTEGER * a
static const uint base
Definition: qurl.cpp:268
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
Definition: qstring.cpp:7186
qint64 qlonglong
Definition: qglobal.h:951

◆ arg() [4/20]

QString QString::arg ( ulong  a,
int  fieldwidth = 0,
int  base = 10,
const QChar fillChar = QLatin1Char(' ') 
) const
inline

Definition at line 749 of file qstring.h.

750 { return arg(qulonglong(a), fieldWidth, base, fillChar); }
long ASN1_INTEGER_get ASN1_INTEGER * a
static const uint base
Definition: qurl.cpp:268
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
Definition: qstring.cpp:7186
quint64 qulonglong
Definition: qglobal.h:952

◆ arg() [5/20]

QString QString::arg ( int  a,
int  fieldWidth = 0,
int  base = 10,
const QChar fillChar = QLatin1Char(' ') 
) const
inline

Definition at line 743 of file qstring.h.

744 { return arg(qlonglong(a), fieldWidth, base, fillChar); }
long ASN1_INTEGER_get ASN1_INTEGER * a
static const uint base
Definition: qurl.cpp:268
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
Definition: qstring.cpp:7186
qint64 qlonglong
Definition: qglobal.h:951

◆ arg() [6/20]

QString QString::arg ( uint  a,
int  fieldWidth = 0,
int  base = 10,
const QChar fillChar = QLatin1Char(' ') 
) const
inline

Definition at line 745 of file qstring.h.

746 { return arg(qulonglong(a), fieldWidth, base, fillChar); }
long ASN1_INTEGER_get ASN1_INTEGER * a
static const uint base
Definition: qurl.cpp:268
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
Definition: qstring.cpp:7186
quint64 qulonglong
Definition: qglobal.h:952

◆ arg() [7/20]

QString QString::arg ( short  a,
int  fieldWidth = 0,
int  base = 10,
const QChar fillChar = QLatin1Char(' ') 
) const
inline

fieldWidth specifies the minimum amount of space that a is padded to and filled with the character fillChar.

A positive value produces right-aligned text; a negative value produces left-aligned text.

The base must be between 2 and 36, with 8 giving octal, 10 decimal, and 16 hexadecimal numbers.

If fillChar is '0' (the number 0, ASCII 48), the locale's zero is used. For negative numbers, zero padding might appear before the minus sign.

Definition at line 751 of file qstring.h.

752 { return arg(qlonglong(a), fieldWidth, base, fillChar); }
long ASN1_INTEGER_get ASN1_INTEGER * a
static const uint base
Definition: qurl.cpp:268
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
Definition: qstring.cpp:7186
qint64 qlonglong
Definition: qglobal.h:951

◆ arg() [8/20]

QString QString::arg ( ushort  a,
int  fieldWidth = 0,
int  base = 10,
const QChar fillChar = QLatin1Char(' ') 
) const
inline

Definition at line 753 of file qstring.h.

754 { return arg(qulonglong(a), fieldWidth, base, fillChar); }
long ASN1_INTEGER_get ASN1_INTEGER * a
static const uint base
Definition: qurl.cpp:268
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
Definition: qstring.cpp:7186
quint64 qulonglong
Definition: qglobal.h:952

◆ arg() [9/20]

QString QString::arg ( double  a,
int  fieldWidth = 0,
char  fmt = 'g',
int  prec = -1,
const QChar fillChar = QLatin1Char(' ') 
) const

Definition at line 7357 of file qstring.cpp.

7358 {
7359  ArgEscapeData d = findArgEscapes(*this);
7360 
7361  if (d.occurrences == 0) {
7362  qWarning("QString::arg: Argument missing: %s, %g", toLocal8Bit().data(), a);
7363  return *this;
7364  }
7365 
7366  unsigned flags = QLocalePrivate::NoFlags;
7367  if (fillChar == QLatin1Char('0'))
7369 
7370  if (qIsUpper(fmt))
7371  flags |= QLocalePrivate::CapitalEorX;
7372  fmt = qToLower(fmt);
7373 
7375  switch (fmt) {
7376  case 'f':
7378  break;
7379  case 'e':
7381  break;
7382  case 'g':
7384  break;
7385  default:
7386 #if defined(QT_CHECK_RANGE)
7387  qWarning("QString::arg: Invalid format char '%c'", fmt);
7388 #endif
7389  break;
7390  }
7391 
7392  QString arg;
7393  if (d.occurrences > d.locale_occurrences)
7394  arg = QLocale::c().d()->doubleToString(a, prec, form, fieldWidth, flags);
7395 
7396  QString locale_arg;
7397  if (d.locale_occurrences > 0) {
7398  QLocale locale;
7399 
7402  locale_arg = locale.d()->doubleToString(a, prec, form, fieldWidth, flags);
7403  }
7404 
7405  return replaceArgEscapes(*this, d, fieldWidth, arg, locale_arg, fillChar);
7406 }
long ASN1_INTEGER_get ASN1_INTEGER * a
The QString class provides a Unicode character string.
Definition: qstring.h:83
QChar * data()
Returns a pointer to the data stored in the QString.
Definition: qstring.h:710
NumberOptions numberOptions() const
Returns the options related to number conversions for this QLocale instance.
Definition: qlocale.cpp:802
static QString doubleToString(const QChar zero, const QChar plus, const QChar minus, const QChar exponent, const QChar group, const QChar decimal, double d, int precision, DoubleForm form, int width, unsigned flags)
Definition: qlocale.cpp:2613
Q_CORE_EXPORT void qWarning(const char *,...)
static QString replaceArgEscapes(const QString &s, const ArgEscapeData &d, int field_width, const QString &arg, const QString &larg, const QChar &fillChar=QLatin1Char(' '))
Definition: qstring.cpp:6839
QByteArray toLocal8Bit() const Q_REQUIRED_RESULT
Returns the local 8-bit representation of the string as a QByteArray.
Definition: qstring.cpp:4049
int locale_occurrences
Definition: qstring.cpp:6775
Data * d
Definition: qstring.h:618
const QLocalePrivate * d() const
Definition: qlocale.cpp:761
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
Definition: qstring.cpp:7186
static QLocale c()
Returns a QLocale object initialized to the "C" locale.
Definition: qlocale.h:773
static ArgEscapeData findArgEscapes(const QString &s)
Definition: qstring.cpp:6780
bool qIsUpper(char ch)
Definition: qstring.cpp:362
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
char qToLower(char ch)
Definition: qstring.cpp:372

◆ arg() [10/20]

QString QString::arg ( char  a,
int  fieldWidth = 0,
const QChar fillChar = QLatin1Char(' ') 
) const

Definition at line 7322 of file qstring.cpp.

7323 {
7324  QString c;
7325  c += QLatin1Char(a);
7326  return arg(c, fieldWidth, fillChar);
7327 }
unsigned char c[8]
Definition: qnumeric_p.h:62
long ASN1_INTEGER_get ASN1_INTEGER * a
The QString class provides a Unicode character string.
Definition: qstring.h:83
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
Definition: qstring.cpp:7186
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ arg() [11/20]

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

Definition at line 7307 of file qstring.cpp.

7308 {
7309  QString c;
7310  c += a;
7311  return arg(c, fieldWidth, fillChar);
7312 }
unsigned char c[8]
Definition: qnumeric_p.h:62
long ASN1_INTEGER_get ASN1_INTEGER * a
The QString class provides a Unicode character string.
Definition: qstring.h:83
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
Definition: qstring.cpp:7186

◆ arg() [12/20]

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

Returns a copy of this string with the lowest numbered place marker replaced by string a, i.e., %1, %2, ..., %99.

fieldWidth specifies the minimum amount of space that argument a shall occupy. If a requires less space than fieldWidth, it is padded to fieldWidth with character fillChar. A positive fieldWidth produces right-aligned text. A negative fieldWidth produces left-aligned text.

This example shows how we might create a status string for reporting progress while processing a list of files:

QString i; // current file's number
QString total; // number of files to process
QString fileName; // current file's name
QString status = QString("Processing file %1 of %2: %3")
.arg(i).arg(total).arg(fileName);

First, arg(i) replaces %1. Then arg(total) replaces %2. Finally, arg(fileName) replaces %3.

One advantage of using arg() over sprintf() is that the order of the numbered place markers can change, if the application's strings are translated into other languages, but each arg() will still replace the lowest numbered unreplaced place marker, no matter where it appears. Also, if place marker i appears more than once in the string, the arg() replaces all of them.

If there is no unreplaced place marker remaining, a warning message is output and the result is undefined. Place marker numbers must be in the range 1 to 99.

Definition at line 6962 of file qstring.cpp.

6963 {
6964  ArgEscapeData d = findArgEscapes(*this);
6965 
6966  if (d.occurrences == 0) {
6967  qWarning("QString::arg: Argument missing: %s, %s", toLocal8Bit().data(),
6968  a.toLocal8Bit().data());
6969  return *this;
6970  }
6971  return replaceArgEscapes(*this, d, fieldWidth, a, a, fillChar);
6972 }
char * data()
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:429
QChar * data()
Returns a pointer to the data stored in the QString.
Definition: qstring.h:710
Q_CORE_EXPORT void qWarning(const char *,...)
static QString replaceArgEscapes(const QString &s, const ArgEscapeData &d, int field_width, const QString &arg, const QString &larg, const QChar &fillChar=QLatin1Char(' '))
Definition: qstring.cpp:6839
QByteArray toLocal8Bit() const Q_REQUIRED_RESULT
Returns the local 8-bit representation of the string as a QByteArray.
Definition: qstring.cpp:4049
Data * d
Definition: qstring.h:618
static ArgEscapeData findArgEscapes(const QString &s)
Definition: qstring.cpp:6780

◆ arg() [13/20]

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

Definition at line 755 of file qstring.h.

756 { const QString *args[2] = { &a1, &a2 }; return multiArg(2, args); }
The QString class provides a Unicode character string.
Definition: qstring.h:83
QString multiArg(int numArgs, const QString **args) const
Definition: qstring.cpp:7434

◆ arg() [14/20]

QString QString::arg ( const QString a1,
const QString a2,
const QString a3 
) const
inline

Definition at line 757 of file qstring.h.

758 { const QString *args[3] = { &a1, &a2, &a3 }; return multiArg(3, args); }
The QString class provides a Unicode character string.
Definition: qstring.h:83
QString multiArg(int numArgs, const QString **args) const
Definition: qstring.cpp:7434

◆ arg() [15/20]

QString QString::arg ( const QString a1,
const QString a2,
const QString a3,
const QString a4 
) const
inline

Definition at line 759 of file qstring.h.

761 { const QString *args[4] = { &a1, &a2, &a3, &a4 }; return multiArg(4, args); }
The QString class provides a Unicode character string.
Definition: qstring.h:83
QString multiArg(int numArgs, const QString **args) const
Definition: qstring.cpp:7434

◆ arg() [16/20]

QString QString::arg ( const QString a1,
const QString a2,
const QString a3,
const QString a4,
const QString a5 
) const
inline

Definition at line 762 of file qstring.h.

764 { const QString *args[5] = { &a1, &a2, &a3, &a4, &a5 }; return multiArg(5, args); }
The QString class provides a Unicode character string.
Definition: qstring.h:83
QString multiArg(int numArgs, const QString **args) const
Definition: qstring.cpp:7434

◆ arg() [17/20]

QString QString::arg ( const QString a1,
const QString a2,
const QString a3,
const QString a4,
const QString a5,
const QString a6 
) const
inline

Definition at line 765 of file qstring.h.

767 { const QString *args[6] = { &a1, &a2, &a3, &a4, &a5, &a6 }; return multiArg(6, args); }
The QString class provides a Unicode character string.
Definition: qstring.h:83
QString multiArg(int numArgs, const QString **args) const
Definition: qstring.cpp:7434

◆ arg() [18/20]

QString QString::arg ( const QString a1,
const QString a2,
const QString a3,
const QString a4,
const QString a5,
const QString a6,
const QString a7 
) const
inline

Definition at line 768 of file qstring.h.

771 { const QString *args[7] = { &a1, &a2, &a3, &a4, &a5, &a6, &a7 }; return multiArg(7, args); }
The QString class provides a Unicode character string.
Definition: qstring.h:83
QString multiArg(int numArgs, const QString **args) const
Definition: qstring.cpp:7434

◆ arg() [19/20]

QString QString::arg ( const QString a1,
const QString a2,
const QString a3,
const QString a4,
const QString a5,
const QString a6,
const QString a7,
const QString a8 
) const
inline

Definition at line 772 of file qstring.h.

775 { const QString *args[8] = { &a1, &a2, &a3, &a4, &a5, &a6, &a7, &a8 }; return multiArg(8, args); }
The QString class provides a Unicode character string.
Definition: qstring.h:83
QString multiArg(int numArgs, const QString **args) const
Definition: qstring.cpp:7434

◆ arg() [20/20]

QString QString::arg ( const QString a1,
const QString a2,
const QString a3,
const QString a4,
const QString a5,
const QString a6,
const QString a7,
const QString a8,
const QString a9 
) const
inline

Definition at line 776 of file qstring.h.

779 { const QString *args[9] = { &a1, &a2, &a3, &a4, &a5, &a6, &a7, &a8, &a9 }; return multiArg(9, args); }
The QString class provides a Unicode character string.
Definition: qstring.h:83
QString multiArg(int numArgs, const QString **args) const
Definition: qstring.cpp:7434

◆ at()

const QChar QString::at ( int  position) const
inline

Returns the character at the given index position in the string.

The position must be a valid index position in the string (i.e., 0 <= position < size()).

See also
operator[]()

Definition at line 698 of file qstring.h.

Referenced by QFileSystemModelPrivate::_q_fileSystemChanged(), _q_parseUnixDir(), QAbstractSocketPrivate::_q_startConnecting(), QDeclarativeTypeLoader::absoluteFilePath(), QNSOpenSavePanelDelegate::acceptableExtensionsForSave, QSvgIconEngine::addFile(), QPixmapIconEngine::addFile(), QDir::addResourceSearchPath(), QPatternist::XQueryTokenizer::aheadEquals(), QTextHtmlImporter::appendNodeText(), QCoreApplication::applicationFilePath(), QTextHtmlParser::applyAttributes(), QUnixPrintWidgetPrivate::applyPrinterProperties(), QKeySequence::assign(), QStringRef::at(), QTextEngine::atSpace(), QPatternist::DerivedString< TypeToken >::attributeNormalize(), QTextEngine::atWordSeparator(), QLineControl::backspace(), QFileSystemEntry::baseName(), QDeclarativeCompiler::buildDynamicMeta(), canonicalOrderHelper(), QDeclarativeCompiler::checkDynamicMeta(), QDeclarativeCompiler::checkValidId(), QDirModelPrivate::children(), QDir::cleanPath(), QLocalePrivate::codeToScript(), comify(), QDeclarativeConnectionsParser::compile(), QFileSystemEntry::completeBaseName(), QScriptCompletionTaskPrivate::completeScriptExpression(), composeHelper(), QVFbScreen::connect(), QScriptEnginePrivate::convertValue(), QCalendarDateValidator::countRepeat(), countRepeat(), QPatternist::XQueryTokenizer::current(), QPSQLResult::data(), QLocalePrivate::dateTimeToString(), QPatternist::CompressedWhitespace::decompress(), QTextCursor::deletePreviousChar(), QStyledItemDelegate::displayText(), driveSpec(), QAxBase::dynamicCallHelper(), QTextEngine::elidedText(), QTextHtmlExporter::emitBlock(), encodeText(), Qt::escape(), QRegExp::escape(), QPatternist::escape(), QScriptDebuggerCodeView::event(), extractEncodingDecl(), QDeclarativeScriptParser::extractMetaData(), QXmlStreamReaderPrivate::fastScanContentCharList(), QFileSystemEntry::fileName(), QFileSystemEngine::fillMetaData(), QDeclarativeImportedNamespace::find(), QDateTimeParser::findAmPm(), QDateTimeParser::findDay(), findGraphicsFactory(), findGroupFactory(), findInBlock(), QDateTimeParser::findMonth(), findObject(), findStyleFactoryMethod(), findStyleUtilFactoryMethod(), findUtilFactory(), fixedCharData(), fixedXmlName(), fmtDateTime(), QTest::formatResult(), QSqlDriver::formatValue(), QChar::fromAscii(), QPatternist::NamePool::fromClarkName(), fromHex(), QUrl::fromLocalFile(), QDateTime::fromString(), QXmlStreamReaderPrivate::getChar(), QXmlStreamReaderPrivate::getChar_helper(), getFmtString(), QSystemLocalePrivate::getLocaleInfo_qchar(), getMessage(), getNextChar(), QMacInputContext::globalEventProcessor(), QLineControl::hasAcceptableInput(), QTextHtmlParserNode::hasOnlyWhitespace(), QTextHtmlParser::hasPrefix(), hasUnquotedAP(), hasValidSignal(), QScriptSyntaxHighlighter::highlightBlock(), QScriptSyntaxHighlighter::highlightWord(), QDirModel::index(), iniChopTrailingSpaces(), QSettingsPrivate::iniEscapedKey(), QSettingsPrivate::iniEscapedString(), QDeclarativePropertyPrivate::initProperty(), QTextDocumentPrivate::insert_block(), QTextDocumentPrivate::insert_string(), QTextCursor::insertText(), QPatternist::XSLTTokenizer::insideTemplate(), QLineControl::internalDelete(), QLineControl::internalInsert(), QFileSystemEntry::isAbsolute(), isDirPath(), QFileSystemEntry::isDriveRoot(), QPatternist::LangFN::isLangMatch(), isLineSeparatorBlockAfterTable(), QUrl::isParentOf(), QXmlUtils::isPublicID(), QDateTimeEditPrivate::isSeparatorKey(), isSignalPropertyName(), isSupportedSvgFeature(), QPatternist::DerivedString< TypeToken >::isValidName(), QPatternist::DerivedString< TypeToken >::isValidNMTOKEN(), QTest::keyClicks(), QTextControlPrivate::keyPressEvent(), QMenu::keyPressEvent(), QTextEdit::keyPressEvent(), QStringRef::lastIndexOf(), QPatternist::ProcessingInstructionConstructor::leftTrimmed(), QCoreApplication::libraryPaths(), QTranslator::load(), longestCommonPrefix(), QFSFileEnginePrivate::longFileName(), macToQtFormat(), mapToLowerCase(), Qt::mightBeRichText(), QKeySequence::mnemonic(), QTextDocumentPrivate::move(), QTextCursorPrivate::movePosition(), QDeclarativeProperty::name(), QFileSystemEngine::nativeAbsoluteFilePath(), QTextHtmlParser::newNode(), QCssScanner_Generated::next(), QPatternist::ToCodepointsIterator::next(), QTextLineItemIterator::next(), QPatternist::XQueryTokenizer::nextToken(), QFileSystemModelPrivate::node(), QSettingsPrivate::normalizedKey(), QPatternist::XQueryTokenizer::normalizeEOL(), QTextFrame::iterator::operator++(), QTextFrame::iterator::operator--(), operator<<(), QDeclarativeDirParser::parse(), QHttpHeader::parse(), QXmlStreamReaderPrivate::parse(), parseCombinedArgString(), QSvgHandler::parseCSStoXMLAttrs(), QTextHtmlParser::parseEntity(), QPatternist::PatternPlatform::parseFlags(), QDateTimeParser::parseFormat(), QLineControl::parseInputMask(), QDeclarativeBindingCompilerPrivate::parseName(), QDateTimeParser::parseSection(), QFileSystemEntry::path(), QPatternist::XQueryTokenizer::peekAhead(), QXmlStreamReaderPrivate::peekChar(), QPatternist::XQueryTokenizer::peekForColonColon(), QKeyMapper::possibleKeys(), QSqlResult::prepare(), QCss::Scanner::preprocess(), QLineControl::processKeyEvent(), QFtpPI::processReply(), QTextHtmlImporter::processSpecialNodes(), QXmlStreamReaderPrivate::putReplacement(), QXmlStreamReaderPrivate::putReplacementInAttributeValue(), QTextStreamPrivate::putString(), QXmlStreamReaderPrivate::putString(), QXmlStreamReaderPrivate::putStringLiteral(), QChar::QChar(), qDBusGenerateMetaObjectXml(), qDBusInterfaceFromMetaObject(), QDeclarative_isFileCaseCorrect(), QDeclarativeImportDatabase::QDeclarativeImportDatabase(), QScript::qobjectProtoFuncFindChild(), qReplacePlaceholderMarkers(), qt_accAmpIndex(), qt_accHotKey(), qt_create_commandline(), qt_format_text(), qt_mac_removeMnemonics(), qt_readEscapedFormatString(), qt_repeatCount(), qt_set_x11_resources(), qt_splitLocaleName(), qt_string_normalize(), qt_strippedText(), readSymLink(), QPSQLDriver::record(), QFactoryLoader::refreshAll(), QTextDocumentPrivate::remove_block(), QTextDocumentPrivate::remove_string(), QCoreApplication::removeLibraryPath(), QLineControl::removeSelectedText(), QItemDelegatePrivate::replaceNewLine(), replacePercentN(), QDirModelPrivate::restorePersistentIndexes(), rotateSlashesDotsAndMiddots(), QTextDocumentPrivate::scan_frames(), QDeclarativeViewSection::sectionString(), QFileDialog::selectFile(), QLineEdit::selectionStart(), QCoreApplication::setApplicationVersion(), QUrlPrivate::setAuthority(), QCalendarDateValidator::setFormat(), QDirPrivate::setPath(), QGtkStylePrivate::setupGtkFileChooser(), QFileSystemEngine::slowCanonicalized(), QSettingsPrivate::splitArgs(), QProcessPrivate::startProcess(), stringContainsNullChar(), QSettingsPrivate::stringListToVariantList(), QScript::stringProtoFuncArg(), QPatternist::AbstractFloat< isDouble >::stringValue(), timeFormatContainsAP(), QPatternist::Tokenizer::tokenToString(), QUrl::toLocalFile(), QUrl::toString(), totalDigitsForDecimal(), QFontEngineXLFD::toUnicode(), translateKeyEventInternal(), tryDriveUNCFallback(), typeNameToXml(), QTextDocumentPrivate::unite(), unquote(), QDeclarativeListViewPrivate::updateCurrentSection(), QLineControl::updateDisplayText(), QKeyMapperPrivate::updateKeyMap(), QLocalePrivate::updateSystemPrivate(), QDateTimeEditPrivate::validateAndInterpret(), QLocalePrivate::validateChars(), QSystemLocalePrivate::winToQtFormat(), QXmlSerializer::writeEscaped(), QXmlStreamWriterPrivate::writeEscaped(), QXmlSerializer::writeEscapedAttribute(), and xpmHash().

699 { Q_ASSERT(uint(i) < uint(size())); return d->data[i]; }
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
int size() const
Returns the number of characters in this string.
Definition: qstring.h:102
unsigned int uint
Definition: qglobal.h:996
Data * d
Definition: qstring.h:618
ushort * data
Definition: qstring.h:606

◆ begin() [1/2]

QString::iterator QString::begin ( )
inline

Returns an STL-style iterator pointing to the first character in the string.

See also
constBegin(), end()

Definition at line 888 of file qstring.h.

Referenced by containsProhibitedOuptut().

889 { detach(); return reinterpret_cast<QChar*>(d->data); }
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
void detach()
Definition: qstring.h:714
Data * d
Definition: qstring.h:618
ushort * data
Definition: qstring.h:606

◆ begin() [2/2]

QString::const_iterator QString::begin ( ) const
inline

Definition at line 890 of file qstring.h.

891 { return reinterpret_cast<const QChar*>(d->data); }
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
Data * d
Definition: qstring.h:618
ushort * data
Definition: qstring.h:606

◆ capacity()

int QString::capacity ( ) const
inline

Returns the maximum number of characters that can be stored in the string without forcing a reallocation.

The sole purpose of this function is to provide a means of fine tuning QString's memory usage. In general, you will rarely ever need to call this function. If you want to know how many characters are in the string, call size().

See also
reserve(), squeeze()

Definition at line 727 of file qstring.h.

Referenced by QOCIResultPrivate::bindValue(), QTextDocumentPrivate::compressPieceTable(), QODBCResult::exec(), and qt_ACE_do().

728 { return d->alloc; }
Data * d
Definition: qstring.h:618

◆ chop()

void QString::chop ( int  n)

Removes n characters from the end of the string.

If n is greater than size(), the result is an empty string.

Example:

QString str("LOGOUT\r\n");
str.chop(2);
// str == "LOGOUT"

If you want to remove characters from the beginning of the string, use remove() instead.

See also
truncate(), resize(), remove()

Definition at line 4623 of file qstring.cpp.

Referenced by QDeclarativeImportsPrivate::add(), QWindowsFileSystemWatcherEngine::addPaths(), argToString(), buildMatchRule(), QDirModelPrivate::children(), QDir::cleanPath(), QFileSystemEngine::createDirectory(), QPSQLResult::data(), elliditide(), QTextHtmlExporter::emitCharFormatStyle(), QTextHtmlExporter::emitFragment(), QTextHtmlExporter::emitFrameStyle(), QTest::formatResult(), QDateTime::fromString(), getFindData(), QFileSystemEngine::getLinkTarget(), QSQLite2ResultPrivate::init(), intValueHelper(), isDirPath(), jump(), QCss::ValueExtractor::lengthValue(), QCompletionEngine::matchHint(), QDirModelPrivate::name(), QPatternist::TokenRevealer::nextToken(), QFileSystemModelPrivate::node(), QXmlStreamReaderPrivate::parse(), parseAnimateColorNode(), parseAnimateTransformNode(), QCss::Parser::parseFunction(), parseIp6(), parseLength(), QCss::Parser::parseTerm(), QTextDocumentPrivate::plainText(), qt_parsePrintcap(), qt_parseQconfig(), QWizardField::QWizardField(), QFtpPI::readyRead(), QCss::Declaration::realValue(), removeOptionalQuotes(), QWindowsFileSystemWatcherEngine::removePaths(), QDeclarativeImportsPrivate::resolvedUri(), QPluginLoader::setFileName(), setFontSizeFromValue(), setWidthAttribute(), QSqlDriver::sqlStatement(), QSqlDriver::stripDelimitersImplementation(), QDB2Driver::tables(), QIBaseDriver::tables(), QUrl::toString(), translate_dashPattern(), QFileInfoGatherer::translateDriveName(), QCss::Parser::unquotedLexem(), and variantToString().

4624 {
4625  if (n > 0)
4626  resize(d->size - n);
4627 }
Data * d
Definition: qstring.h:618
void resize(int size)
Sets the size of the string to size characters.
Definition: qstring.cpp:1353

◆ clear()

void QString::clear ( )
inline

Clears the contents of the string and makes it empty.

See also
resize(), isEmpty()

Definition at line 723 of file qstring.h.

Referenced by QUnixPrintWidgetPrivate::_q_btnBrowseClicked(), QScriptDebuggerConsoleWidgetPrivate::_q_onCompletionTaskFinished(), QPixmapIconEngine::addPixmap(), Maemo::IcdPrivate::addrinfo(), QTextHtmlImporter::appendNodeText(), QNetworkAccessAuthenticationManager::cacheProxyCredentials(), QUrlPrivate::canonicalHost(), QProcessPrivate::Channel::Channel(), QDBusObjectPath::check(), QDBusSignature::check(), QScript::SyntaxChecker::checkSyntax(), QSqlTableModelPrivate::clear(), QXmlStreamStringRef::clear(), QFileInfoPrivate::clear(), QTextDocumentPrivate::clear(), QResourcePrivate::clear(), QUrlPrivate::clear(), QRegExpEngineKey::clear(), QAbstractSpinBoxPrivate::clearCache(), QNetworkSessionPrivateImpl::clearConfiguration(), QLabelPrivate::clearContents(), QFtpDTP::clearError(), QFtpPI::clearPendingCommands(), Maemo::IcdPrivate::clearState(), QDBusConnectionPrivate::closeConnection(), QPdfBaseEnginePrivate::closePrintDevice(), QWinInputContext::composition(), QIcdEngine::connectionStateSignalsSlot(), QNativeWifiEngine::connectToId(), QTextStreamPrivate::consume(), QDomImplementation::createDocumentType(), QDBusMetaObject::createMetaObject(), QAxBase::dynamicCallHelper(), QWinInputContext::endComposition(), QDomHandler::endEntity(), fbname(), QTextStreamPrivate::flushWriteBuffer(), fmtDateTime(), QXmlInputSource::fromRawData(), QXmlStreamReaderPrivate::getChar_helper(), getIBaseError(), QLocalSocketPrivate::init(), QDomDocumentTypePrivate::init(), QXmlSimpleReaderPrivate::init(), QXmlStreamReaderPrivate::init(), QCss::Parser::init(), QSharedMemoryPrivate::initKey(), QSettingsPrivate::iniUnescapedStringList(), QSqlDatabasePrivate::invalidateDb(), QLibraryPrivate::isPlugin(), QLibraryPrivate::load_sys(), QWhatsThat::mouseReleaseEvent(), QTextHtmlParser::newNode(), StringSplitter::next(), QDeclarativeXmlListModelPrivate::notifyQueryStarted(), QProcessPrivate::Channel::operator=(), QTextStream::operator>>(), operator>>(), QScriptParser::parse(), QUrlPrivate::parse(), QXmlStreamReaderPrivate::parse(), parseCombinedArgString(), QXmlSimpleReaderPrivate::parseDoctype(), QCss::Parser::parseElementName(), QXmlStreamReaderPrivate::parseError(), QXmlSimpleReaderPrivate::parseExternalID(), parseFontName(), QAuthenticatorPrivate::parseHttpResponse(), parseIp6(), QProcessPrivate::Channel::pipeFrom(), QProcessPrivate::Channel::pipeTo(), QTextStream::pos(), QPSQLResult::prepare(), QDBusConnectionPrivate::prepareHook(), QXmlNamespaceSupport::processName(), qDeallocatePreparedStmt(), qExtractSecurityPolicyFromString(), qGetStringData(), qt_fillFontDef(), QFileDialogPrivate::qt_mac_filedialog_event_proc(), qt_parseQconfig(), qt_split_namespace(), qt_win_get_save_file_name(), QPatternist::XSLTTokenizer::queueTextConstructor(), QConfFileSettingsPrivate::readIniFile(), QMdiSubWindowPrivate::removeBaseWidget(), QWinInputContext::reset(), QTextStreamPrivate::resetReadBuffer(), QLibraryPrivate::resolve_sys(), QUrl::resolved(), Maemo::IcdPrivate::scan(), QFileDialogPrivate::selectFile_sys(), QUrlPrivate::setAuthority(), QDeclarativeJS::Lexer::setCode(), QDBusConnectionPrivate::setConnection(), QUrl::setEncodedFragment(), QUrl::setEncodedPassword(), QUrl::setEncodedPath(), QUrlPrivate::setEncodedUserInfo(), QUrl::setEncodedUserName(), QFilePrivate::setError(), QFont::setFamily(), QLibrary::setLoadHints(), QFont::setStyleHint(), QUrlPrivate::setUserInfo(), QSettingsPrivate::splitArgs(), QFSCompleter::splitPath(), QCompleter::splitPath(), QSqlDriver::sqlStatement(), QFtpPI::startNextCmd(), Maemo::IcdPrivate::state(), Maemo::IcdPrivate::statistics(), QSQLiteDriver::tables(), QLibraryPrivate::unload_sys(), QAuthenticatorPrivate::updateCredentials(), and QNetworkSessionPrivateImpl::updateState().

724 { if (!isNull()) *this = QString(); }
bool isNull() const
Returns true if this string is null; otherwise returns false.
Definition: qstring.h:505
QString()
Constructs a null string.
Definition: qstring.h:879

◆ compare() [1/9]

int QString::compare ( const QString s) const

Definition at line 5037 of file qstring.cpp.

Referenced by QFileSystemModelPrivate::_q_fileSystemChanged(), QStringRef::at(), QFontDatabase::bold(), QUnsortedModelEngine::buildIndices(), QFileSystemModelPrivate::caseInsensitiveLessThan(), QPatternist::StringComparator::compare(), QPatternist::CaseInsensitiveStringComparator::compare(), compare(), QLineControl::complete(), QVNCScreen::connect(), QTransformedScreen::connect(), QHttpNetworkConnectionPrivate::copyCredentials(), QTsLibPlugin::create(), QLinuxInputKbdDriver::create(), QLinuxTPMouseDriver::create(), QLinuxInputPlugin::create(), QNetworkAccessFileBackendFactory::create(), QNetworkAccessFtpBackendFactory::create(), declarations(), QFontDatabasePrivate::family(), QSortedModelEngine::filter(), findEncoding(), findObject(), QFontDatabase::font(), QtFontFamily::foundry(), QAudioOutputPrivate::freeBlocks(), QAudioInputPrivate::freeBlocks(), getFontWeight(), QStyleSheetStyle::hasStyleRule(), QTextHtmlParserNode::initializeProperties(), QFontDatabase::isBitmapScalable(), isCacheable(), QPatternist::LangFN::isLangMatch(), QUrl::isLocalFile(), QFontDatabase::isSmoothlyScalable(), QExtendedInformation::isSymLink(), QFontDatabase::italic(), QSortFilterProxyModel::lessThan(), loadFromDatabase(), QTextDocument::loadResource(), QAbstractItemModel::match(), QFileSystemModelPrivate::naturalCompare(), QFileSystemModelPrivate::nodeCaseInsensitiveLessThan(), QSvgStyleSelector::nodeNameEquals(), QAudioDeviceInfoInternal::open(), QAudioInputPrivate::open(), QAudioOutputPrivate::open(), QDirSortItemComparator::operator()(), QFileSystemModelPrivate::QFileSystemNode::operator<(), QStandardItem::operator<(), operator<(), QFileInfo::operator==(), QProcEnvKey::operator==(), QFileSystemModelPrivate::QFileSystemNode::operator==(), QDir::operator==(), QFileSystemModelPrivate::QFileSystemNode::operator>(), QXmlStreamReaderPrivate::parse(), parseBrushValue(), parseColorValue(), QFontDatabase::pointSizes(), qMatchCapStr(), QtPrivate::QStringList_contains(), QTsLibMouseHandler::QTsLibMouseHandler(), QCss::Declaration::rectValue(), registerFont(), QCoreApplication::removeLibraryPath(), QSqlRelationalTableModel::selectStatement(), QPrinter::setOutputFileName(), QFontDatabase::smoothSizes(), QSortedModelEngine::sortOrder(), QFontDatabase::styles(), QAudioDeviceInfoInternal::testSettings(), QDBusConnection::unregisterObject(), QDeclarativeEnginePrivate::urlToLocalFileOrQrc(), QPatternist::NCNameConstructor::validateTargetName(), and QFontDatabase::weight().

5038 {
5039  return ucstrcmp(constData(), length(), other.constData(), other.length());
5040 }
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
static int ucstrcmp(const QChar *a, int alen, const QChar *b, int blen)
Definition: qstring.cpp:211
const QChar * constData() const
Returns a pointer to the data stored in the QString.
Definition: qstring.h:712

◆ compare() [2/9]

int QString::compare ( const QString s,
Qt::CaseSensitivity  cs 
) const

Definition at line 5048 of file qstring.cpp.

5049 {
5050  if (cs == Qt::CaseSensitive)
5051  return ucstrcmp(constData(), length(), other.constData(), other.length());
5052  return ucstricmp(d->data, d->data + d->size, other.d->data, other.d->data + other.d->size);
5053 }
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
static int ucstricmp(const ushort *a, const ushort *ae, const ushort *b, const ushort *be)
Definition: qstring.cpp:141
Data * d
Definition: qstring.h:618
ushort * data
Definition: qstring.h:606
static int ucstrcmp(const QChar *a, int alen, const QChar *b, int blen)
Definition: qstring.cpp:211
const QChar * constData() const
Returns a pointer to the data stored in the QString.
Definition: qstring.h:712

◆ compare() [3/9]

int QString::compare ( const QLatin1String other,
Qt::CaseSensitivity  cs = Qt::CaseSensitive 
) const

Definition at line 5075 of file qstring.cpp.

5076 {
5077  return compare_helper(unicode(), length(), other, cs);
5078 }
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
static int compare_helper(const QChar *data1, int length1, const QChar *data2, int length2, Qt::CaseSensitivity cs=Qt::CaseSensitive)
Definition: qstring.cpp:5059
const QChar * unicode() const
Returns a &#39;\0&#39;-terminated Unicode representation of the string.
Definition: qstring.h:706

◆ compare() [4/9]

static int QString::compare ( const QString s1,
const QString s2 
)
inlinestatic

Definition at line 350 of file qstring.h.

351  { return s1.compare(s2); }
int compare(const QString &s) const
Definition: qstring.cpp:5037

◆ compare() [5/9]

int QString::compare ( const QString s1,
const QString s2,
Qt::CaseSensitivity  cs 
)
inlinestatic

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.

Since
4.2

If cs is Qt::CaseSensitive, the comparison is case sensitive; otherwise the comparison is case insensitive.

Case sensitive 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-visible strings with localeAwareCompare().

int x = QString::compare("aUtO", "AuTo", Qt::CaseInsensitive); // x == 0
int y = QString::compare("auto", "Car", Qt::CaseSensitive); // y > 0
int z = QString::compare("auto", "Car", Qt::CaseInsensitive); // z < 0
See also
operator==(), operator<(), operator>()

Definition at line 352 of file qstring.h.

353  { return s1.compare(s2, cs); }
int compare(const QString &s) const
Definition: qstring.cpp:5037

◆ compare() [6/9]

static int QString::compare ( const QString s1,
const QLatin1String s2,
Qt::CaseSensitivity  cs = Qt::CaseSensitive 
)
inlinestatic

Definition at line 355 of file qstring.h.

357  { return s1.compare(s2, cs); }
int compare(const QString &s) const
Definition: qstring.cpp:5037

◆ compare() [7/9]

static int QString::compare ( const QLatin1String s1,
const QString s2,
Qt::CaseSensitivity  cs = Qt::CaseSensitive 
)
inlinestatic

Definition at line 358 of file qstring.h.

360  { return -s2.compare(s1, cs); }
int compare(const QString &s) const
Definition: qstring.cpp:5037

◆ compare() [8/9]

int QString::compare ( const QStringRef s,
Qt::CaseSensitivity  cs = Qt::CaseSensitive 
) const
inline

Definition at line 1245 of file qstring.h.

1246 { return QString::compare_helper(constData(), length(), s.constData(), s.length(), cs); }
int length() const
Returns the number of characters referred to by the string reference.
Definition: qstring.h:1116
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
const QChar * constData() const
Same as unicode().
Definition: qstring.h:1159
static int compare_helper(const QChar *data1, int length1, const QChar *data2, int length2, Qt::CaseSensitivity cs=Qt::CaseSensitive)
Definition: qstring.cpp:5059
const QChar * constData() const
Returns a pointer to the data stored in the QString.
Definition: qstring.h:712

◆ compare() [9/9]

int QString::compare ( const QString s1,
const QStringRef s2,
Qt::CaseSensitivity  cs = Qt::CaseSensitive 
)
inlinestatic

Definition at line 1247 of file qstring.h.

1248 { return QString::compare_helper(s1.constData(), s1.length(), s2.constData(), s2.length(), cs); }
int length() const
Returns the number of characters referred to by the string reference.
Definition: qstring.h:1116
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
const QChar * constData() const
Same as unicode().
Definition: qstring.h:1159
static int compare_helper(const QChar *data1, int length1, const QChar *data2, int length2, Qt::CaseSensitivity cs=Qt::CaseSensitive)
Definition: qstring.cpp:5059
const QChar * constData() const
Returns a pointer to the data stored in the QString.
Definition: qstring.h:712

◆ compare_helper() [1/2]

int QString::compare_helper ( const QChar data1,
int  length1,
const QChar data2,
int  length2,
Qt::CaseSensitivity  cs = Qt::CaseSensitive 
)
staticprivate
Warning
This function is not part of the public interface.
Since
4.5

Definition at line 5059 of file qstring.cpp.

Referenced by compare(), and QStringRef::compare().

5061 {
5062  if (cs == Qt::CaseSensitive)
5063  return ucstrcmp(data1, length1, data2, length2);
5064  register const ushort *s1 = reinterpret_cast<const ushort *>(data1);
5065  register const ushort *s2 = reinterpret_cast<const ushort *>(data2);
5066  return ucstricmp(s1, s1 + length1, s2, s2 + length2);
5067 }
static int ucstricmp(const ushort *a, const ushort *ae, const ushort *b, const ushort *be)
Definition: qstring.cpp:141
unsigned short ushort
Definition: qglobal.h:995
static int ucstrcmp(const QChar *a, int alen, const QChar *b, int blen)
Definition: qstring.cpp:211

◆ compare_helper() [2/2]

int QString::compare_helper ( const QChar data1,
int  length1,
QLatin1String  s2,
Qt::CaseSensitivity  cs = Qt::CaseSensitive 
)
staticprivate
Warning
This function is not part of the public interface.
Since
4.5

Definition at line 5101 of file qstring.cpp.

5103 {
5104  const ushort *uc = reinterpret_cast<const ushort *>(data1);
5105  const ushort *e = uc + length1;
5106  const uchar *c = (uchar *)s2.latin1();
5107 
5108  if (!c)
5109  return length1;
5110 
5111  if (cs == Qt::CaseSensitive) {
5112  while (uc < e && *c && *uc == *c)
5113  uc++, c++;
5114 
5115  if (uc == e)
5116  return -*c;
5117 
5118  return *uc - *c;
5119  } else {
5120  return ucstricmp(uc, e, c);
5121  }
5122 }
unsigned char c[8]
Definition: qnumeric_p.h:62
unsigned char uchar
Definition: qglobal.h:994
const char * latin1() const
Returns the Latin-1 string stored in this object.
Definition: qstring.h:661
static int ucstricmp(const ushort *a, const ushort *ae, const ushort *b, const ushort *be)
Definition: qstring.cpp:141
unsigned short ushort
Definition: qglobal.h:995

◆ constBegin()

QString::const_iterator QString::constBegin ( ) const
inline

Returns a const STL-style iterator pointing to the first character in the string.

See also
begin(), constEnd()

Definition at line 892 of file qstring.h.

Referenced by QSvgFont::draw(), idFromUrl(), and QFileSystemEntry::isClean().

893 { return reinterpret_cast<const QChar*>(d->data); }
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
Data * d
Definition: qstring.h:618
ushort * data
Definition: qstring.h:606

◆ constData()

const QChar * QString::constData ( ) const
inline

Returns a pointer to the data stored in the QString.

The pointer can be used to access the characters that compose the string. For convenience, the data is '\0'-terminated.

Note that the pointer remains valid only as long as the string is not modified.

See also
data(), operator[]()

Definition at line 712 of file qstring.h.

Referenced by QTextCopyHelper::appendFragment(), QConcatenable< QString >::appendTo(), QTextEngine::attributes(), QDeclarativeCompiler::buildDynamicMeta(), QTextCodec::canEncode(), QFileSystemEngine::canonicalName(), compare(), QStringRef::compare(), QDeclarativeCompiler::completeComponentBuild(), QTextDocumentPrivate::compressPieceTable(), QAbstractConcatenable::convertFromAscii(), createFileFromTemplate(), QFileSystemEngine::createLink(), QScriptDeclarativeClass::createPersistentIdentifier(), createPolygonNode(), createPolylineNode(), QTextEngine::elidedText(), QAction::event(), QXmlInputSource::fetchData(), QTextCodec::fromUnicode(), QTextEncoder::fromUnicode(), QFileSystemEngine::getLinkTarget(), getText(), localeAwareCompare(), QStringRef::localeAwareCompare(), QLibraryInfo::location(), QFSFileEnginePrivate::nativeOpen(), QStyleSheetStyleSelector::nodeNameEquals(), QByteArray::operator!=(), operator+=(), QByteArray::operator<(), operator<(), operator<<(), QByteArray::operator<=(), QByteArray::operator==(), QByteArray::operator>(), QByteArray::operator>=(), QDeclarativeJS::Parser::parse(), parseAnimateTransformNode(), QDeclarativeStyledTextPrivate::parseAttribute(), QDeclarativeStyledTextPrivate::parseCloseTag(), QDeclarativeStyledTextPrivate::parseEntity(), parsePen(), QDeclarativeStyledTextPrivate::parseTag(), QDeclarativeStyledTextPrivate::parseValue(), QSQLiteResult::prepare(), QXmlNamespaceSupport::processName(), QPatternist::NamespaceSupport::processName(), QDeclarativeImportDatabase::QDeclarativeImportDatabase(), QFileSystemIterator::QFileSystemIterator(), qt_ACE_do(), qt_is_idn_enabled(), qt_string_normalize(), qt_u_strToCase(), QTextStreamPrivate::readPtr(), QDeclarativeBindingCompilerPrivate::registerLiteralString(), QFileSystemEngine::removeFile(), QFileSystemEngine::renameFile(), replace(), QDeclarativeCompiler::rewriteBinding(), QTextStreamPrivate::scan(), QAbstractXmlReceiver::sendAsNode(), QCoreApplication::setApplicationVersion(), QColor::setColorFromString(), QWSRegionCommand::setData(), ShaderEffectItem::setFragmentShader(), QDeclarativeTextInput::setPasswordCharacter(), QFileSystemEngine::setPermissions(), ShaderEffectItem::setVertexShader(), QFtpPI::startNextCmd(), QTextBlock::text(), QTextFragment::text(), QTextBlock::textDirection(), toDouble(), QUrl::toPunycode(), toPunycodeHelper(), QTest::toString(), XsdSchemaToken::toToken(), QPatternist::XSLTTokenLookup::toToken(), toUtf8(), QStringRef::toUtf8(), trimRef(), and QXmlSerializer::write().

713 { return reinterpret_cast<const QChar*>(d->data); }
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
Data * d
Definition: qstring.h:618
ushort * data
Definition: qstring.h:606

◆ constEnd()

QString::const_iterator QString::constEnd ( ) const
inline

Returns a const STL-style iterator pointing to the imaginary item after the last item in the list.

See also
constBegin(), end()

Definition at line 898 of file qstring.h.

Referenced by QSvgFont::draw(), and QFileSystemEntry::isClean().

899 { return reinterpret_cast<const QChar*>(d->data + d->size); }
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
Data * d
Definition: qstring.h:618
ushort * data
Definition: qstring.h:606

◆ contains() [1/5]

QBool QString::contains ( QChar  c,
Qt::CaseSensitivity  cs = Qt::CaseSensitive 
) const
inline

Definition at line 904 of file qstring.h.

Referenced by QHttpPrivate::_q_slotConnected(), QHttpPrivate::_q_slotReadyRead(), QFileDialogPrivate::_q_updateOkButton(), QNSOpenSavePanelDelegate::acceptableExtensionsForSave, QmlApplicationViewerPrivate::adjustPath(), QCoreApplication::applicationFilePath(), QStyleSheetStyleSelector::attribute(), QAudioDeviceInfoInternal::availableDevices(), QUrlPrivate::canonicalHost(), QODBCDriver::cleanup(), QXmlSerializer::comment(), QPatternist::DocumentProjector::comment(), QTransformedScreen::connect(), QConnmanEngine::connectToId(), QPatternist::ProcessingInstructionConstructor::data(), QKeySequencePrivate::decodeString(), QAudioDeviceInfoInternal::defaultOutputDevice(), QConnmanEngine::disconnectFromId(), DumpIDL(), QTextHtmlExporter::emitFontFamily(), QTextHtmlExporter::emitFragment(), QPatternist::MatchesFN::evaluateSingleton(), QMdiSubWindow::eventFilter(), QSortFilterProxyModel::filterAcceptsRow(), QPatternist::Numeric::fromLexical(), QPatternist::DerivedInteger< DerivedType >::fromLexical(), QDateTime::fromString(), QNetworkAccessFtpBackend::ftpRawCommandReply(), QAxScript::functions(), QBBSystemLocaleData::getCorrectFormat(), getFontWeight(), QConnmanManagerInterface::getPathForTechnology(), QGtkStylePrivate::getThemeName(), QScriptSyntaxHighlighter::highlightBlock(), QAxBase::initialize(), QPatternist::XSLTTokenizer::insideTemplate(), QDeclarativeDebugServer::instance(), isBypassed(), isHostExcluded(), QConnmanEngine::isRoamingAllowed(), QDateTimeEditPrivate::isSeparatorKey(), QtFontStyle::Key::Key(), QAxScript::load(), QDeclarativeDebugServerPrivate::loadConnectionPlugin(), QAbstractItemModel::match(), QXlibMime::mimeAtomForFormat(), networkChangeCallback(), QScriptEnginePrivate::newRegExp(), noBlockInString(), QFileSystemModelPrivate::node(), QAudioDeviceInfoInternal::open(), QODBCDriver::open(), QStringRef::operator=(), QHostAddressPrivate::parse(), QDateTimeParser::parse(), parse_locale_tag(), parseIp6(), QHostAddress::parseSubnet(), QGtkStyle::pixelMetric(), QXmlSerializer::processingInstruction(), QPatternist::DocumentProjector::processingInstruction(), QAudioDeviceInfoInternal::QAudioDeviceInfoInternal(), qExtractSecurityPolicyFromString(), qGetODBCVersion(), qIsEffectiveTLD(), QMultiInputContext::QMultiInputContext(), qNtlmPhase3(), QQnxMouseHandler::QQnxMouseHandler(), QtPrivate::QStringList_filter(), qt_aqua_get_known_size(), qt_create_commandline(), qt_format_to_attrib_list(), qt_parseQconfig(), qt_splitLocaleName(), QTextHtmlImporter::QTextHtmlImporter(), QFileSystemModel::setData(), QMdiSubWindowPrivate::setNewWindowTitle(), QDeclarativeValueTypeScriptClass::setProperty(), QDeclarativeObjectScriptClass::setProperty(), QTextBrowserPrivate::setSource(), QMacStyle::sizeFromContents(), QFSCompleter::splitPath(), QProcessPrivate::startDetached(), QXmlStreamReaderPrivate::startDocument(), QUrlPrivate::toEncoded(), totalDigitsForDecimal(), QFontSubset::toType1(), QFileDialogPrivate::typedFiles(), QDeclarativeTextPrivate::updateLayout(), QLabelPrivate::updateShortcut(), QFontDialogPrivate::updateStyles(), QXmlStreamWriter::writeAttribute(), QXmlStreamWriter::writeComment(), QXmlStreamWriter::writeEmptyElement(), QXmlStreamWriter::writeProcessingInstruction(), QXmlStreamWriter::writeStartElement(), and QX11Data::xdndMimeAtomForFormat().

905 { return QBool(indexOf(c, 0, cs) != -1); }
int indexOf(QChar c, int from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.cpp:2838

◆ contains() [2/5]

QBool QString::contains ( const QString str,
Qt::CaseSensitivity  cs = Qt::CaseSensitive 
) const
inline

Returns true if this string contains an occurrence of the string str; otherwise returns false.

If cs is Qt::CaseSensitive (default), the search is case sensitive; otherwise the search is case insensitive.

Example:

QString str = "Peter Pan";
str.contains("peter", Qt::CaseInsensitive); // returns true
See also
indexOf(), count()

Definition at line 900 of file qstring.h.

901 { return QBool(indexOf(s, 0, cs) != -1); }
int indexOf(QChar c, int from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.cpp:2838

◆ contains() [3/5]

QBool QString::contains ( const QStringRef str,
Qt::CaseSensitivity  cs = Qt::CaseSensitive 
) const
inline

Returns true if this string contains an occurrence of the string reference str; otherwise returns false.

Since
4.8

If cs is Qt::CaseSensitive (default), the search is case sensitive; otherwise the search is case insensitive.

See also
indexOf(), count()

Definition at line 902 of file qstring.h.

903 { return QBool(indexOf(s, 0, cs) != -1); }
int indexOf(QChar c, int from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.cpp:2838

◆ contains() [4/5]

QBool QString::contains ( const QRegExp rx) const
inline

Definition at line 204 of file qstring.h.

204 { return QBool(indexOf(rx) != -1); }
int indexOf(QChar c, int from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.cpp:2838

◆ contains() [5/5]

QBool QString::contains ( QRegExp rx) const
inline

Definition at line 209 of file qstring.h.

209 { return QBool(indexOf(rx) != -1); }
int indexOf(QChar c, int from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.cpp:2838

◆ count() [1/5]

int QString::count ( ) const
inline

Definition at line 103 of file qstring.h.

Referenced by QFileDialogPrivate::_q_useNameFilter(), QNSOpenSavePanelDelegate::acceptableExtensionsForSave, QWizardPrivate::addField(), QDir::addResourceSearchPath(), QKeySequence::assign(), QPatternist::AccelTreeBuilder< true >::attribute(), QTextEngine::calculateTabWidth(), QAccessibleLineEdit::characterCount(), QDeclarativeCompiler::checkValidId(), count(), QStyledItemDelegate::displayText(), QMacStyle::drawControl(), QRegExp::escape(), QDeclarativeImportedNamespace::find(), QDateTimeParser::findAmPm(), QTest::formatResult(), QTextHtmlParserNode::hasOnlyWhitespace(), QDirModel::index(), QDeclarativePropertyPrivate::initProperty(), QAxServerBase::Load(), QLibraryPrivate::load_sys(), QFileSystemModelPrivate::naturalCompare(), QPatternist::XQueryTokenizer::nextToken(), QPatternist::XQueryTokenizer::normalizeEOL(), QStringRef::operator=(), parseIp6(), QDeclarativeStringConverters::pointFFromString(), QDeclarativeStringConverters::rectFFromString(), QItemDelegatePrivate::replaceNewLine(), QAxServerBase::Save(), QAccessibleLineEdit::selection(), QDeclarativeStringConverters::sizeFFromString(), subControlLayout(), QDeclarativeBindingCompilerPrivate::subscriptionIndex(), QPatternist::XQueryTokenizer::tokenizeStringLiteral(), totalDigitsForDecimal(), QDeclarativeStringConverters::vector3DFromString(), QXmlStreamWriter::writeAttribute(), QTextOdfWriter::writeBlock(), QXmlStreamWriter::writeEmptyElement(), and QXmlStreamWriter::writeStartElement().

103 { return d->size; }
Data * d
Definition: qstring.h:618

◆ count() [2/5]

int QString::count ( QChar  c,
Qt::CaseSensitivity  cs = Qt::CaseSensitive 
) const

Definition at line 3234 of file qstring.cpp.

3235 {
3236  return qt_string_count(unicode(), size(), ch, cs);
3237  }
static int qt_string_count(const QChar *haystack, int haystackLen, const QChar *needle, int needleLen, Qt::CaseSensitivity cs)
Definition: qstring.cpp:9622
int size() const
Returns the number of characters in this string.
Definition: qstring.h:102
const QChar * unicode() const
Returns a &#39;\0&#39;-terminated Unicode representation of the string.
Definition: qstring.h:706

◆ count() [3/5]

int QString::count ( const QString str,
Qt::CaseSensitivity  cs = Qt::CaseSensitive 
) const

Returns the number of (potentially overlapping) occurrences of the string str in this string.

If cs is Qt::CaseSensitive (default), the search is case sensitive; otherwise the search is case insensitive.

See also
contains(), indexOf()

Definition at line 3220 of file qstring.cpp.

3221 {
3222  return qt_string_count(unicode(), size(), str.unicode(), str.size(), cs);
3223 }
static int qt_string_count(const QChar *haystack, int haystackLen, const QChar *needle, int needleLen, Qt::CaseSensitivity cs)
Definition: qstring.cpp:9622
int size() const
Returns the number of characters in this string.
Definition: qstring.h:102
const QChar * unicode() const
Returns a &#39;\0&#39;-terminated Unicode representation of the string.
Definition: qstring.h:706

◆ count() [4/5]

int QString::count ( const QStringRef s,
Qt::CaseSensitivity  cs = Qt::CaseSensitive 
) const

Definition at line 3253 of file qstring.cpp.

3254 {
3255  return qt_string_count(unicode(), size(), str.unicode(), str.size(), cs);
3256 }
static int qt_string_count(const QChar *haystack, int haystackLen, const QChar *needle, int needleLen, Qt::CaseSensitivity cs)
Definition: qstring.cpp:9622
int size() const
Returns the number of characters in this string.
Definition: qstring.h:102
const QChar * unicode() const
Returns a &#39;\0&#39;-terminated Unicode representation of the string.
Definition: qstring.h:706

◆ count() [5/5]

int QString::count ( const QRegExp rx) const

Definition at line 3429 of file qstring.cpp.

3430 {
3431  QRegExp rx2(rx);
3432  int count = 0;
3433  int index = -1;
3434  int len = length();
3435  while (index < len - 1) { // count overlapping matches
3436  index = rx2.indexIn(*this, index + 1);
3437  if (index == -1)
3438  break;
3439  count++;
3440  }
3441  return count;
3442 }
The QRegExp class provides pattern matching using regular expressions.
Definition: qregexp.h:61
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
int count() const
Definition: qstring.h:103
quint16 index

◆ data() [1/2]

QChar * QString::data ( )
inline

Returns a pointer to the data stored in the QString.

The pointer can be used to access and modify the characters that compose the string. For convenience, the data is '\0'-terminated.

Example:

QString str = "Hello world";
QChar *data = str.data();
while (!data->isNull()) {
qDebug() << data->unicode();
++data;
}

Note that the pointer remains valid only as long as the string is not modified by other means. For read-only access, constData() is faster because it never causes a deep copy to occur.

See also
constData(), operator[]()

Definition at line 710 of file qstring.h.

Referenced by append(), arg(), QLocalePrivate::bcp47Name(), canonicalOrderHelper(), QTextDocumentPrivate::compressPieceTable(), QCoreWlanEngine::connectToId(), containsProhibitedOuptut(), QGb18030Codec::convertToUnicode(), QIsciiCodec::convertToUnicode(), QSimpleTextCodec::convertToUnicode(), QLatin15Codec::convertToUnicode(), QGbkCodec::convertToUnicode(), QGb2312Codec::convertToUnicode(), createFileFromTemplate(), decomposeHelper(), QLocalePrivate::doubleToString(), QDragManager::drag(), QPainter::drawText(), escapedKey(), QProcessPrivate::execChild(), QTextStreamPrivate::fillReadBuffer(), QTextStreamPrivate::flushWriteBuffer(), QDir::fromNativeSeparators(), QRawFont::glyphIndexesForString(), QFontMetrics::inFontUcs4(), QFontMetricsF::inFontUcs4(), QSettingsPrivate::iniUnescapedStringList(), insert(), make_widget_eventUPP(), mapToLowerCase(), multiArg(), QResourceRoot::name(), QAxSelect::on_ActiveXList_clicked(), QAxSelect::on_ActiveXList_doubleClicked(), operator+=(), operator<<(), operator>>(), QXmlStreamReaderPrivate::parse(), parse_locale_tag(), parseFontName(), QTextDocumentPrivate::plainText(), QProcessPrivate::processStarted(), QTextStreamPrivate::putString(), qt_ACE_do(), qt_format_text(), qt_nameprep(), qt_string_normalize(), replace(), replaceWithSpace(), QXlibClipboard::sendSelection(), toAscii(), toLatin1_helper(), QDir::toNativeSeparators(), QTextDocument::toPlainText(), toPunycodeHelper(), AnchorVertex::toString(), QTextDecoder::toUnicode(), QCharRef::unicode(), QLineControl::updateDisplayText(), updateValue(), and QFontMetrics::width().

711 { detach(); return reinterpret_cast<QChar*>(d->data); }
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
void detach()
Definition: qstring.h:714
Data * d
Definition: qstring.h:618
ushort * data
Definition: qstring.h:606

◆ data() [2/2]

const QChar * QString::data ( ) const
inline

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

Definition at line 708 of file qstring.h.

709 { return reinterpret_cast<const QChar*>(d->data); }
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
Data * d
Definition: qstring.h:618
ushort * data
Definition: qstring.h:606

◆ data_ptr()

DataPtr & QString::data_ptr ( )
inline
Warning
This function is not part of the public interface.

Definition at line 650 of file qstring.h.

650 { return d; }
Data * d
Definition: qstring.h:618

◆ detach()

void QString::detach ( )
inline
Warning
This function is not part of the public interface.

Definition at line 714 of file qstring.h.

Referenced by begin(), QDBusConnectionPrivate::connectSignal(), data(), QDBusConnectionPrivate::disconnectSignal(), end(), QCharRef::operator=(), remove(), replace(), replace_helper(), and toCaseFolded().

715 { if (d->ref != 1 || d->data != d->array) realloc(); }
void realloc()
Definition: qstring.cpp:1472
QBasicAtomicInt ref
Definition: qstring.h:604
Data * d
Definition: qstring.h:618
ushort * data
Definition: qstring.h:606
ushort array[1]
Definition: qstring.h:614

◆ end() [1/2]

QString::iterator QString::end ( )
inline

Returns an STL-style iterator pointing to the imaginary character after the last character in the string.

See also
begin(), constEnd()

Definition at line 894 of file qstring.h.

Referenced by isStringRightToLeft(), lastIndexOfHelper(), multiArg(), qFindString(), repeated(), section(), split(), trimmed(), and updateProperties().

895 { detach(); return reinterpret_cast<QChar*>(d->data + d->size); }
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
void detach()
Definition: qstring.h:714
Data * d
Definition: qstring.h:618
ushort * data
Definition: qstring.h:606

◆ end() [2/2]

QString::const_iterator QString::end ( ) const
inline

Definition at line 896 of file qstring.h.

897 { return reinterpret_cast<const QChar*>(d->data + d->size); }
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
Data * d
Definition: qstring.h:618
ushort * data
Definition: qstring.h:606

◆ endsWith() [1/4]

bool QString::endsWith ( const QString s,
Qt::CaseSensitivity  cs = Qt::CaseSensitive 
) const

Returns true if the string ends with s; otherwise returns false.

If cs is Qt::CaseSensitive (default), the search is case sensitive; otherwise the search is case insensitive.

QString str = "Bananas";
str.endsWith("anas"); // returns true
str.endsWith("pple"); // returns false
See also
startsWith()

Definition at line 3796 of file qstring.cpp.

Referenced by QUnixPrintWidgetPrivate::_q_btnBrowseClicked(), _q_parseDosDir(), QDeclarativeImportsPrivate::add(), QFileDialogPrivate::addDefaultSuffixToFiles(), QZipWriter::addDirectory(), QSvgIconEngine::addFile(), QWindowsFileSystemWatcherEngine::addPaths(), QPollingFileSystemWatcherEngine::addPaths(), QDir::cleanPath(), QVNCScreen::connect(), QMultiScreen::connect(), QTransformedScreen::connect(), QFileSystemEngine::createDirectory(), QAbstractFileEngineIterator::currentFilePath(), QDeclarativeListModelParser::definesEmptyList(), QSvgText::draw(), QPSPrintEnginePrivate::emitHeader(), errorCodeToString(), QDB2Driver::escapeIdentifier(), QIBaseDriver::escapeIdentifier(), QSQLite2Driver::escapeIdentifier(), QTDSDriver::escapeIdentifier(), QMYSQLDriver::escapeIdentifier(), QPSQLDriver::escapeIdentifier(), QODBCDriver::escapeIdentifier(), QNetworkDiskCache::expire(), familyList(), QFileSystemModelPrivate::filePath(), QFileSystemEngine::fillMetaData(), find_translation(), QTextBrowserPrivate::findFile(), QResourceRoot::findNode(), QDateTime::fromString(), getFindData(), QFileSystemEngine::getLinkTarget(), QDirModel::index(), QSQLite2ResultPrivate::init(), intValueHelper(), isDirPath(), QMYSQLDriver::isIdentifierEscapedImplementation(), QODBCDriver::isIdentifierEscapedImplementation(), QSqlDriver::isIdentifierEscapedImplementation(), QLibrary::isLibrary(), isParentDomain(), QUrl::isParentOf(), isParentPath(), QLibraryPrivate::isPlugin(), QDBusUtil::isValidObjectPath(), jump(), launchWebBrowser(), QCss::ValueExtractor::lengthValue(), QSvgTinyDocument::load(), QTranslator::load(), QSystemLibrary::load(), QAxScriptManager::load(), QLibraryPrivate::load_sys(), loadOpenSslWin32(), QFSFileEnginePrivate::longFileName(), QAbstractItemModel::match(), QDirModelPrivate::name(), QFileSystemModelPrivate::node(), QDBusXmlParser::objectTree(), QNetworkAccessFtpBackend::open(), QStringRef::operator=(), parseAnimateColorNode(), parseAnimateTransformNode(), QTextHtmlParser::parseCloseTag(), parseLength(), QFSCompleter::pathFromIndex(), QFileSystemIterator::QFileSystemIterator(), QIconTheme::QIconTheme(), qmlFilesInDirectory(), QRenderRule::QRenderRule(), qt_create_commandline(), qt_init(), qt_mac_menu_merge_action(), QWizardField::QWizardField(), QCacheItem::read(), readImage(), readLink(), QFtpPI::readyRead(), QCss::Declaration::realValue(), QAxFactory::registerActiveObject(), QNetworkDiskCachePrivate::removeFile(), QWindowsFileSystemWatcherEngine::removePaths(), QDeclarativeImportsPrivate::resolvedUri(), QFileSystemModelPrivate::QFileSystemNode::retranslateStrings(), runningUnderDebugger(), QAxBase::setControl(), QFileDialog::setDirectory(), setFontSizeFromValue(), QDirPrivate::setPath(), setWidthAttribute(), QFSCompleter::splitPath(), QSqlDriver::sqlStatement(), QSettingsPrivate::stringToVariant(), QAbstractSpinBoxPrivate::stripped(), QSqlError::text(), QPollingFileSystemWatcherEngine::timeout(), QUrl::toString(), QFileInfoGatherer::translateDriveName(), QFileSystemModelPrivate::QFileSystemNode::updateIcon(), QSpinBoxValidator::validate(), and QXmlStreamWriter::writeComment().

3797 {
3798  return qt_ends_with(isNull() ? 0 : unicode(), size(),
3799  s.isNull() ? 0 : s.unicode(), s.size(), cs);
3800  }
int size() const
Returns the number of characters in this string.
Definition: qstring.h:102
const QChar * unicode() const
Returns a &#39;\0&#39;-terminated Unicode representation of the string.
Definition: qstring.h:706
bool isNull() const
Returns true if this string is null; otherwise returns false.
Definition: qstring.h:505
static bool qt_ends_with(const QChar *haystack, int haystackLen, const QChar *needle, int needleLen, Qt::CaseSensitivity cs)
Definition: qstring.cpp:9722

◆ endsWith() [2/4]

bool QString::endsWith ( const QStringRef s,
Qt::CaseSensitivity  cs = Qt::CaseSensitive 
) const

Definition at line 3816 of file qstring.cpp.

3817 {
3818  return qt_ends_with(isNull() ? 0 : unicode(), size(),
3819  s.isNull() ? 0 : s.unicode(), s.size(), cs);
3820 }
int size() const
Returns the number of characters referred to by the string reference.
Definition: qstring.h:1114
int size() const
Returns the number of characters in this string.
Definition: qstring.h:102
const QChar * unicode() const
Returns a &#39;\0&#39;-terminated Unicode representation of the string.
Definition: qstring.h:706
const QChar * unicode() const
Returns a Unicode representation of the string reference.
Definition: qstring.h:1153
bool isNull() const
Returns true if this string is null; otherwise returns false.
Definition: qstring.h:505
bool isNull() const
Returns true if string() returns a null pointer or a pointer to a null string; otherwise returns true...
Definition: qstring.h:1170
static bool qt_ends_with(const QChar *haystack, int haystackLen, const QChar *needle, int needleLen, Qt::CaseSensitivity cs)
Definition: qstring.cpp:9722

◆ endsWith() [3/4]

bool QString::endsWith ( const QLatin1String s,
Qt::CaseSensitivity  cs = Qt::CaseSensitive 
) const

Definition at line 3826 of file qstring.cpp.

3827 {
3828  return qt_ends_with(isNull() ? 0 : unicode(), size(), s, cs);
3829 }
int size() const
Returns the number of characters in this string.
Definition: qstring.h:102
const QChar * unicode() const
Returns a &#39;\0&#39;-terminated Unicode representation of the string.
Definition: qstring.h:706
bool isNull() const
Returns true if this string is null; otherwise returns false.
Definition: qstring.h:505
static bool qt_ends_with(const QChar *haystack, int haystackLen, const QChar *needle, int needleLen, Qt::CaseSensitivity cs)
Definition: qstring.cpp:9722

◆ endsWith() [4/4]

bool QString::endsWith ( const QChar c,
Qt::CaseSensitivity  cs = Qt::CaseSensitive 
) const

Definition at line 3837 of file qstring.cpp.

3838 {
3839  return d->size
3840  && (cs == Qt::CaseSensitive
3841  ? d->data[d->size - 1] == c
3842  : foldCase(d->data[d->size - 1]) == foldCase(c.unicode()));
3843 }
unsigned char c[8]
Definition: qnumeric_p.h:62
ushort unicode() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qchar.h:251
Data * d
Definition: qstring.h:618
static uint foldCase(const ushort *ch, const ushort *start)
Definition: qchar.cpp:1380
ushort * data
Definition: qstring.h:606

◆ expand()

void QString::expand ( int  i)
private

Definition at line 1477 of file qstring.cpp.

Referenced by insert(), and QCharRef::operator=().

1478 {
1479  int sz = d->size;
1480  resize(qMax(i + 1, sz));
1481  if (d->size - 1 > sz) {
1482  ushort *n = d->data + d->size - 1;
1483  ushort *e = d->data + sz;
1484  while (n != e)
1485  * --n = ' ';
1486  }
1487 }
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
Data * d
Definition: qstring.h:618
void resize(int size)
Sets the size of the string to size characters.
Definition: qstring.cpp:1353
ushort * data
Definition: qstring.h:606
unsigned short ushort
Definition: qglobal.h:995

◆ fill()

QString & QString::fill ( QChar  ch,
int  size = -1 
)

Sets every character in the string to character ch.

If size is different from -1 (default), the string is resized to size beforehand.

Example:

QString str = "Berlin";
str.fill('z');
// str == "zzzzzz"
str.fill('A', 2);
// str == "AA"
See also
resize()

Definition at line 4641 of file qstring.cpp.

Referenced by QPatternist::XsdSchemaDebugger::dumpInheritance(), QPatternist::XsdSchemaDebugger::dumpParticle(), int2string(), leftJustified(), QSvgPaintEngine::qbrushToSvg(), rightJustified(), QDateTimeParser::sectionFormat(), QLCDNumber::setDigitCount(), and QLineControl::updateDisplayText().

4642 {
4643  resize(size < 0 ? d->size : size);
4644  if (d->size) {
4645  QChar *i = (QChar*)d->data + d->size;
4646  QChar *b = (QChar*)d->data;
4647  while (i != b)
4648  *--i = ch;
4649  }
4650  return *this;
4651 }
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
int size() const
Returns the number of characters in this string.
Definition: qstring.h:102
Data * d
Definition: qstring.h:618
void resize(int size)
Sets the size of the string to size characters.
Definition: qstring.cpp:1353
ushort * data
Definition: qstring.h:606

◆ free()

void QString::free ( Data d)
staticprivate

Definition at line 1311 of file qstring.cpp.

Referenced by operator=(), realloc(), resize(), and ~QString().

1312 {
1313 #ifdef QT3_SUPPORT
1314  if (d->asciiCache) {
1315  QMutexLocker locker(asciiCacheMutex());
1316  Q_ASSERT(asciiCache);
1317  asciiCache->remove(d);
1318  }
1319 #endif
1320  qFree(d);
1321 }
Q_CORE_EXPORT void qFree(void *ptr)
Definition: qmalloc.cpp:58
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
Data * d
Definition: qstring.h:618
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
ushort asciiCache
Definition: qstring.h:610

◆ fromAscii()

QString QString::fromAscii ( const char *  str,
int  size = -1 
)
static

Returns a QString initialized with the first size characters from the string str.

If size is -1 (default), it is taken to be qstrlen(str).

Note that, despite the name, this function actually uses the codec defined by QTextCodec::setCodecForCStrings() to convert str to Unicode. Depending on the codec, it may not accept valid US-ASCII (ANSI X3.4-1986) input. If no codec has been set, this function does the same as fromLatin1().

See also
toAscii(), fromLatin1(), fromUtf8(), fromLocal8Bit()

Definition at line 4276 of file qstring.cpp.

Referenced by QDateTimeEditPrivate::_q_editorCursorPositionChanged(), QHttpPrivate::_q_slotReadyRead(), QHttpPrivate::_q_slotSendRequest(), QGraphicsAnchorLayoutPrivate::addAnchor_helper(), QBasicUnixFontDatabase::addTTFile(), QFontDatabasePrivate::addTTFile(), append(), QSQLite2Driver::beginTransaction(), QGraphicsWidget::close(), QSQLite2Driver::commitTransaction(), convert(), QAbstractConcatenable::convertFromAscii(), Graph< AnchorVertex, AnchorData >::createEdge(), createSequence(), QLayoutPrivate::createSpacerItem(), QPSQLResult::data(), QGridLayoutRowInfo::dump(), QGraphicsAnchorLayoutPrivate::dumpGraph(), QSimplex::dumpMatrix(), QPatternist::EncodeString::evaluateSingleton(), QRadioButton::event(), QCheckBox::event(), QDB2Result::exec(), QWSSoundServerPrivate::feedDevice(), QSQLite2ResultPrivate::fetchNext(), QSQLite2ResultPrivate::finalize(), QSplitterPrivate::findWidget(), QHttpThreadDelegate::finishedSlot(), QXmlInputSource::fromRawData(), fromStdString(), QSslSocketBackendPrivate::getErrorsFromOpenSsl(), QPSQLDriverPrivate::getPSQLVersion(), getSegments(), QBBVirtualKeyboardBps::handleLocaleEvent(), QPushButtonPrivate::hitButton(), QSQLite2ResultPrivate::init(), QStatusBarPrivate::messageRect(), QGroupBox::mouseReleaseEvent(), QSQLite2Driver::open(), QLatin1String::operator!=(), operator!=(), operator+(), operator+=(), QByteArray::operator<(), operator<(), QLatin1String::operator<(), operator<(), QDebug::operator<<(), operator<<(), QTextStream::operator<<(), QByteArray::operator<=(), operator<=(), QLatin1String::operator<=(), operator<=(), QLatin1String::operator==(), operator==(), QByteArray::operator>(), operator>(), QLatin1String::operator>(), operator>(), QByteArray::operator>=(), operator>=(), QLatin1String::operator>=(), operator>=(), QToolBoxButton::paintEvent(), ParallelAnchorData::ParallelAnchorData(), QHttpNetworkConnectionPrivate::prepareRequest(), prepend(), QBoxLayout::QBoxLayout(), QComboBox::QComboBox(), QCopChannel::QCopChannel(), QDial::QDial(), QDialog::QDialog(), QDoubleValidator::QDoubleValidator(), QFrame::QFrame(), QGridLayout::QGridLayout(), QHBoxLayout::QHBoxLayout(), QImage::QImage(), QIntValidator::QIntValidator(), QLabel::QLabel(), QLineEdit::QLineEdit(), QMainWindow::QMainWindow(), QMenuBar::QMenuBar(), QObject::QObject(), QRegExpValidator::QRegExpValidator(), QScriptValue::QScriptValue(), QScrollBar::QScrollBar(), QSignalMapper::QSignalMapper(), QSizeGrip::QSizeGrip(), QSlider::QSlider(), QSocketNotifier::QSocketNotifier(), QSound::QSound(), QSpinBox::QSpinBox(), qStringComparisonHelper(), qt_get_screen(), QTabWidget::QTabWidget(), qTdsMsgHandler(), QTextBrowser::QTextBrowser(), QTextEdit::QTextEdit(), QTimer::QTimer(), QToolBar::QToolBar(), QToolButton::QToolButton(), QTranslator::QTranslator(), QValidator::QValidator(), QVariant::QVariant(), QVBoxLayout::QVBoxLayout(), QWidget::QWidget(), QWorkspace::QWorkspace(), QWSServer::QWSServer(), QWSSoundServerPrivate::QWSSoundServerPrivate(), QFtpPI::readyRead(), QIBaseResult::record(), Graph< AnchorVertex, AnchorData >::removeEdge(), QGraphicsAnchorLayoutPrivate::replaceVertex(), QSQLite2Result::reset(), QTDSResult::reset(), QLibraryPrivate::resolve_sys(), QSQLite2Driver::rollbackTransaction(), SequentialAnchorData::SequentialAnchorData(), Graph< AnchorVertex, AnchorData >::serializeToDot(), QWSServer::setDefaultKeyboard(), QWSServer::setDefaultMouse(), QAction::setFont(), QAbstractButton::setIconSize(), QImage::setText(), setupDBusInterface(), QMessageBox::setWindowModality(), QGraphicsAnchorLayoutPrivate::simplifyGraph(), QHttpThreadDelegate::synchronousFinishedSlot(), Graph< AnchorVertex, AnchorData >::takeEdge(), QAccessibleItemRow::text(), QImage::text(), QTextHtmlExporter::toHtml(), AnchorVertex::toString(), QSimplexConstraint::toString(), AnchorData::toString(), GraphPath::toString(), QWSSoundServerClient::tryReadCommand(), QFontEngineFTRawFont::updateFamilyNameAndStyle(), and QAbstractSpinBoxPrivate::variantCompare().

4277 {
4278  return QString(fromAscii_helper(str, size), 0);
4279 }
int size() const
Returns the number of characters in this string.
Definition: qstring.h:102
static Data * fromAscii_helper(const char *str, int size=-1)
Definition: qstring.cpp:4155
QString()
Constructs a null string.
Definition: qstring.h:879

◆ fromAscii_helper()

QString::Data * QString::fromAscii_helper ( const char *  str,
int  size = -1 
)
staticprivate

Definition at line 4155 of file qstring.cpp.

Referenced by fromAscii().

4156 {
4157 #ifndef QT_NO_TEXTCODEC
4158  if (codecForCStrings) {
4159  Data *d;
4160  if (!str) {
4161  d = &shared_null;
4162  d->ref.ref();
4163  } else if (size == 0 || (!*str && size < 0)) {
4164  d = &shared_empty;
4165  d->ref.ref();
4166  } else {
4167  if (size < 0)
4168  size = qstrlen(str);
4170  d = s.d;
4171  d->ref.ref();
4172  }
4173  return d;
4174  }
4175 #endif
4176  return fromLatin1_helper(str, size);
4177 }
The QString class provides a Unicode character string.
Definition: qstring.h:83
QBasicAtomicInt ref
Definition: qstring.h:604
static Data shared_null
Definition: qstring.h:616
int size() const
Returns the number of characters in this string.
Definition: qstring.h:102
Data * d
Definition: qstring.h:618
QString toUnicode(const QByteArray &) const
Converts a from the encoding of this codec to Unicode, and returns the result in a QString...
uint qstrlen(const char *str)
Definition: qbytearray.h:79
static QTextCodec * codecForCStrings
Definition: qstring.h:621
static Data * fromLatin1_helper(const char *str, int size=-1)
Definition: qstring.cpp:4104
static Data shared_empty
Definition: qstring.h:617

◆ fromLatin1()

QString QString::fromLatin1 ( const char *  str,
int  size = -1 
)
static

Returns a QString initialized with the first size characters of the Latin-1 string str.

If size is -1 (default), it is taken to be qstrlen(str).

See also
toLatin1(), fromAscii(), fromUtf8(), fromLocal8Bit()

Definition at line 4188 of file qstring.cpp.

Referenced by QUnixPrintWidgetPrivate::_q_btnBrowseClicked(), QScriptDebuggerPrivate::_q_continue(), QScriptDebuggerPrivate::_q_interrupt(), QScriptDebuggerConsoleWidgetPrivate::_q_onCompletionTaskFinished(), QScriptDebuggerConsoleWidgetPrivate::_q_onLineEntered(), QFtpPrivate::_q_piError(), QUnixPrintWidgetPrivate::_q_printerChanged(), QHttpPrivate::_q_slotError(), QHttpPrivate::_q_slotSendRequest(), QScriptDebuggerPrivate::_q_stepInto(), QScriptDebuggerPrivate::_q_stepOut(), QScriptDebuggerPrivate::_q_stepOver(), QPrintPreviewDialogPrivate::_q_zoomFactorChanged(), QAccessibleObject::actionText(), QFontDatabasePrivate::addAppFont(), QZipStreamStrategy::addFile(), QFontDatabasePrivate::addFont(), addKey(), QLocalServerPrivate::addListener(), QScriptDebuggerLocalsModelPrivate::addTopLevelObject(), QPatternist::NamePool::allocateBinding(), QPatternist::NamePool::allocateQName(), QSslCertificate::alternateSubjectNames(), RequestAnalyzer::analyze(), QDBusMarshaller::append(), QPSQLDriverPrivate::appendTables(), QDBusMarshaller::appendVariantInternal(), QCoreApplication::applicationFilePath(), QUnixPrintWidgetPrivate::applyPrinterProperties(), QScriptDebuggerBackend::attachTo(), QStyleSheetStyleSelector::attribute(), QPatternist::AxisStep::axisName(), QDBusMarshaller::beginArray(), QDBusMarshaller::beginMap(), breakpointDataFromScriptValue(), breakpointDataToScriptValue(), QLibraryInfo::buildDate(), QLibraryInfo::buildKey(), bulletChar(), QNetworkAccessAuthenticationManager::cacheCredentials(), QDeclarativeObjectMethodScriptClass::callOverloaded(), QDeclarativeObjectMethodScriptClass::callPrecise(), QScript::callQtMethod(), QUrlPrivate::canonicalHost(), QScriptObjectSnapshot::capture(), QDir::cdUp(), QDBusUtil::checkBusName(), QDBusUtil::checkErrorName(), checkHRESULT(), QDBusUtil::checkInterfaceName(), QDBusUtil::checkMemberName(), QDBusUtil::checkObjectPath(), QCoreApplicationPrivate::checkReceiverThread(), QAxFactory::classID(), classIDL(), QBenchmarkValgrindUtils::cleanup(), QPatternist::ColorOutput::colorify(), QGLShaderPrivate::compile(), QVNCScreen::connect(), QMultiScreen::connect(), QTransformedScreen::connect(), QDirectFBScreen::connect(), consoleCommandGroupDataToScriptValue(), consoleCommandToScriptValue(), QScriptDebuggerConsole::consumeInput(), contextInfoToScriptValue(), QScriptDebugger::continueAction(), convert(), convertFlags(), QMacPasteboardMimeVCard::convertFromMime(), QLatin1Codec::convertToUnicode(), QIconvCodec::convertToUnicode(), QLatin15Codec::convertToUnicode(), convertTypes(), QPatternist::XsdSchemaParserContext::createAnonymousName(), createInterfaces(), QScriptDebuggerConsolePrivate::createJob(), QDBusMetaObject::createMetaObject(), QDirectFBScreenPrivate::createPixmapData(), createReadHandlerHelper(), QDBusArgumentPrivate::createSignature(), QOutputStrategy::createUniqueImageName(), QLocale::currencySymbol(), QScriptDebuggerStackModel::data(), QPSQLResult::data(), QScriptDebuggerLocalsModel::data(), QScriptDebuggerScriptsModel::data(), QScriptBreakpointsModel::data(), QGraphicsSceneBspTree::debug(), QScriptDebuggerPrivate::debuggerEvent(), debuggerResponseToScriptValue(), debuggerScriptValuePropertyFromScriptValue(), debuggerScriptValuePropertyToScriptValue(), decodeMSG(), QKeySequencePrivate::decodeString(), QBBEngine::defaultConfiguration(), QFont::defaultFamily(), QScript::QObjectDelegate::deleteProperty(), QPatternist::Expression::description(), QScriptDebuggerBackend::detach(), QPSQLDriverPrivate::detectBackslashEscape(), QPatternist::LocalNameTest::displayName(), QBBEngine::doRequestUpdate(), QLocalePrivate::doubleToString(), QWindowsXPStylePrivate::drawBackgroundThruNativeBuffer(), QPlastiqueStyle::drawComplexControl(), QGtkStyle::drawComplexControl(), QWindowsVistaStyle::drawControl(), QStyleHelper::drawDial(), drawEllipse_midpoint_i(), QWindowsVistaStyle::drawPrimitive(), QPlastiqueStyle::drawPrimitive(), QCleanlooksStyle::drawPrimitive(), QTextHtmlExporter::emitBlock(), QTextHtmlExporter::emitFragment(), QKeySequencePrivate::encodeString(), QPatternist::DerivedString< TypeToken >::error(), QRegExp::errorString(), QEgl::errorString(), QXmlDefaultHandler::errorString(), QAxFactory::eventsID(), QPSQLResult::exec(), QPicture::exec(), QScriptDebuggerCommandExecutor::execute(), QScript::QtFunction::execute(), QScript::QMetaObjectWrapperObject::execute(), QAxFactory::exposeToSuperClass(), QScriptEdit::extraAreaPaintEvent(), QGtkStylePrivate::extract_filter(), extractEncodingDecl(), fallbackTheme(), fbname(), QTextStreamPrivate::fillReadBuffer(), QImageTextureGlyphCache::fillTexture(), QScriptDebugger::findInScriptAction(), QGLEngineSharedShaders::findProgramInCache(), QDBusMetaObjectGenerator::findType(), flagCheck(), fontExists(), QTextEditMimeData::formats(), QDB2Driver::formatValue(), QFont::freetypeFace(), QUrl::fromAce(), QNetworkHeadersPrivate::fromHttpDate(), QPatternist::HexBinary::fromLexical(), fromLocal8Bit(), QHostInfoAgent::fromName(), QUrl::fromPunycode(), QScript::functionConnect(), QScript::functionDisconnect(), QScript::functionQsTranslate(), QAxScript::functions(), QSvgPaintEnginePrivate::generateGradientName(), generateInterfaceXml(), generateSubObjectXml(), QScriptDebuggerLocalsModelPrivate::get(), QXmlStreamReaderPrivate::getChar_helper(), QStyleSheetStyle::getDefaultStyleSheet(), QBenchmarkValgrindUtils::getNewestFileName(), QScript::QObjectDelegate::getOwnPropertyDescriptor(), QScript::QObjectDelegate::getOwnPropertyNames(), QScript::QObjectDelegate::getOwnPropertySlot(), QTextStreamPrivate::getReal(), QGtkStylePrivate::getThemeFont(), QFileIconProviderPrivate::getWinIcon(), QApplicationPrivate::globalEventProcessor(), QBBVirtualKeyboardPps::handleKeyboardInfoMessage(), QPatternist::ColoringMessageHandler::handleMessage(), QDBusConnectionPrivate::handleObjectCall(), QScriptToolTipJob::handleResponse(), QScriptDebuggerShowLineJob::handleResponse(), QAxFactory::hasStockEvents(), if(), imageReadMimeFormats(), imageWriteMimeFormats(), QScriptEngine::importExtension(), QScriptDebuggerLocalsModel::init(), QPrintPreviewDialogPrivate::init(), init_platform(), initFontSubst(), QImageReaderPrivate::initHandler(), QTextHtmlParserNode::initializeProperties(), QApplicationPrivate::initializeWidgetPaletteHash(), QWaylandInputDevice::inputHandleKey(), QDeclarativeDebugServer::instance(), int2string(), QAxFactory::interfaceID(), interfaceNotFoundError(), QAxBase::internalInvoke(), QScriptDebugger::interruptAction(), QAxServerBase::Invoke(), isDirPath(), QXmlSimpleReaderPrivate::isExpandedEntityValueTooLarge(), QLibraryPrivate::isPlugin(), QSslCertificate::issuerInfo(), QTextList::itemText(), jump(), QMessageBox::keyPressEvent(), QTextCodecPlugin::keys(), QMetaEnum::keysToValue(), QObject::killTimer(), QFont::lastResortFamily(), QFont::lastResortFont(), launch(), libraryPathList(), QCoreApplication::libraryPaths(), QLibraryInfo::licensedProducts(), QGLShaderProgram::link(), QTranslator::load(), QAxServerBase::Load(), QLibraryPrivate::load_sys(), QFontDatabase::loadXlfd(), QSystemTrayIconSys::locateSystemTray(), QPatternist::ReportContext::lookupSourceLocation(), lsOpen(), QLineControl::maskString(), QScriptErrorLogWidget::message(), QXlibMime::mimeAtomToString(), QXlibMime::mimeConvertToFormat(), QXlibMime::mimeDataForAtom(), QTest::mouseEvent(), QPatternist::NamePool::NamePool(), QStyleSheetStyleSelector::nodeNames(), QPSQLResult::numRowsAffected(), QWaylandClipboard::offer(), QAxEventSink::OnChanged(), QBBInputContext::onSetComposingRegion(), QOCIDriver::open(), QDB2Driver::open(), QAudioInputPrivate::open(), QAudioOutputPrivate::open(), QWSServer::openKeyboard(), QWSServer::openMouse(), operator<<(), operator=(), operator>>(), QBenchmarkValgrindUtils::outFileBase(), QTest::outputMessage(), QStaticTextPrivate::paintText(), QScriptDebuggerScriptedConsoleCommand::parse(), QDateTimeParser::parse(), QPatternist::XsdSchemaParser::parseAlternative(), QPatternist::XsdSchemaParser::parseAny(), QPatternist::XsdSchemaParser::parseAnyAttribute(), QPatternist::XsdSchemaParser::parseAppInfo(), QPatternist::XsdSchemaParser::parseAssertion(), QNlaThread::parseBlob(), QPatternist::XsdSchemaParser::parseComplexContent(), QPatternist::XsdSchemaParser::parseComplexContentExtension(), QPatternist::XsdSchemaParser::parseComplexContentRestriction(), QPatternist::XsdSchemaParser::parseDefaultOpenContent(), QFtpDTP::parseDir(), QXmlSimpleReaderPrivate::parseDoctype(), QPatternist::XsdSchemaParser::parseDocumentation(), QPatternist::XsdSchemaParser::parseEnumerationFacet(), QPatternist::XsdSchemaParser::parseField(), QPatternist::XsdSchemaParser::parseFractionDigitsFacet(), QPatternist::XsdSchemaParser::parseGlobalAttribute(), QPatternist::XsdSchemaParser::parseGlobalComplexType(), QPatternist::XsdSchemaParser::parseGlobalElement(), parseHeaderValue(), QAuthenticatorPrivate::parseHttpResponse(), QPatternist::XsdSchemaParser::parseImport(), QPatternist::XsdSchemaParser::parseInclude(), QPatternist::XsdSchemaParser::parseKeyRef(), QPatternist::XsdSchemaParser::parseLengthFacet(), QPatternist::XsdSchemaParser::parseList(), QPatternist::XsdSchemaParser::parseLocalAttribute(), QPatternist::XsdSchemaParser::parseLocalComplexType(), QPatternist::XsdSchemaParser::parseLocalElement(), QPatternist::XsdSchemaParser::parseMaxExclusiveFacet(), QPatternist::XsdSchemaParser::parseMaxInclusiveFacet(), QPatternist::XsdSchemaParser::parseMaxLengthFacet(), QPatternist::XsdSchemaParser::parseMinExclusiveFacet(), QPatternist::XsdSchemaParser::parseMinInclusiveFacet(), QPatternist::XsdSchemaParser::parseMinLengthFacet(), QPatternist::XsdSchemaParser::parseMinMaxConstraint(), QPatternist::XsdSchemaParser::parseNamedGroup(), QPatternist::XsdSchemaParser::parseNotation(), QPatternist::XsdSchemaParser::parseOpenContent(), QPatternist::XsdSchemaParser::parsePatternFacet(), QPatternist::XsdSchemaParser::parseRedefine(), QPatternist::XsdSchemaParser::parseReferredAttributeGroup(), QPatternist::XsdSchemaParser::parseReferredGroup(), QPatternist::XsdSchemaParser::parseSchema(), QPatternist::XsdSchemaParser::parseSelector(), QPatternist::XsdSchemaParser::parseSimpleContentExtension(), QPatternist::XsdSchemaParser::parseSimpleContentRestriction(), QPatternist::XsdSchemaParser::parseSimpleRestriction(), QHttpNetworkReplyPrivate::parseStatus(), parseStopNode(), QPatternist::XsdSchemaParser::parseTotalDigitsFacet(), QPatternist::XsdSchemaParser::parseUnion(), QPatternist::XsdSchemaParser::parseWhiteSpaceFacet(), QPictureIO::pictureFormat(), pixelToPoint(), QScriptBreakpointsWidgetPrivate::pixmap(), QScriptDebuggerPrivate::pixmap(), pointSize(), QScriptDebuggerAgent::positionChange(), QPSQLResult::prepare(), QTDSDriver::primaryIndex(), QPSQLDriver::primaryIndex(), QPatternist::AccelTree::printStats(), QApplicationPrivate::process_cmdline(), QDBusAbstractInterfacePrivate::property(), propertyNotFoundError(), propertyWriteReply(), QScript::QObjectDelegate::put(), QAudioDeviceInfoInternal::QAudioDeviceInfoInternal(), qax_docuFromName(), qax_generateDocumentation(), QSvgPaintEngine::qbrushToSvg(), qDBusGenerateMetaObjectXml(), qDBusIntrospectObject(), qDBusReplyFill(), QDeclarativeImportDatabase::QDeclarativeImportDatabase(), QDirPrivate::QDirPrivate(), qGetInterfaceType(), qGetODBCVersion(), QLinuxFbIntegration::QLinuxFbIntegration(), qMakeError(), qMakeFieldInfo(), qMakeStatement(), qmlExecuteDeferred(), QNetworkReplyDataImpl::QNetworkReplyDataImpl(), QPageSetupWidget::QPageSetupWidget(), QProgressDialog::QProgressDialog(), QRegExpValidator::QRegExpValidator(), QScriptDebuggerBackendPrivate::qsassert(), QScriptBreakpointsWidget::QScriptBreakpointsWidget(), QScriptDebuggerConsoleWidget::QScriptDebuggerConsoleWidget(), QScriptDebugOutputWidget::QScriptDebugOutputWidget(), QScriptNewBreakpointWidget::QScriptNewBreakpointWidget(), QSslSocketBackendPrivate::QSslCipher_from_SSL_CIPHER(), qt_clean_filter_list(), qt_error_string(), qt_eval_string(), qt_fillFontDef(), qt_getLprPrinters(), qt_guiPlatformPlugin(), qt_init(), qt_localeFromLCID(), qt_mac_applicationmenu_string(), QApplicationPrivate::qt_mac_apply_settings(), qt_mac_extract_filter(), qt_mac_menu_merge_action(), qt_message_output(), qt_parseEtcLpPrinters(), qt_pd_foreach(), qt_set_x11_resources(), qt_splitLocaleName(), qt_strip_filters(), qt_strippedText(), qt_win_extract_filter(), qt_win_filter(), qt_wince_is_pocket_pc(), qt_wince_is_smartphone(), qt_x11_set_fallback_font_family(), QtCeGetClipboard(), qTdsErrHandler(), qTdsMsgHandler(), QTest::qtest_qParseArgs(), QTextLayout::QTextLayout(), qToField(), qToStringList(), QVariantToVARIANT(), QXmlName::QXmlName(), QZipStreamStrategy::QZipStreamStrategy(), rasterFallbacksMask(), rasterFallbackWarn(), QAudioInputPrivate::read(), QTextStream::read(), read_xbm_header(), readAllProperties(), QPatternist::XsdSchemaParser::readBlockingConstraintAttribute(), MetaObjectGenerator::readClassInfo(), QPatternist::XsdSchemaParser::readDerivationConstraintAttribute(), MetaObjectGenerator::readEnumInfo(), QPatternist::XsdSchemaParser::readNameAttribute(), QPngHandlerPrivate::readPngTexts(), QPatternist::XsdSchemaParser::readXPathExpression(), QIBaseResult::record(), QPSQLDriver::record(), QNSOpenSavePanelDelegate::removeExtensions:, QSystemLibrary::resolve(), QDeclarativeVME::run(), QScriptDebugger::runToCursorAction(), QScriptDebugger::runToNewScriptAction(), QDomDocumentPrivate::saveDocument(), QSvgPaintEngine::saveGradientStops(), QScript::Lexer::scanRegExp(), QPatternist::XQueryTokenizer::scanUntil(), QLocalePrivate::scriptCode(), scriptDataFromScriptValue(), scriptDataToScriptValue(), QPatternist::XsdValidatingInstanceReader::selectNodeSets(), QSqlRelationalTableModel::selectStatement(), QWaylandSelection::send(), QAbstractXmlReceiver::sendAsNode(), QDBusConnectionPrivate::sendError(), QCoreApplication::sendPostedEvents(), QDBusConnectionPrivate::sendWithReplyLocal(), QPatternist::AccelTree::sequencedTypedValue(), QUnixPrintWidgetPrivate::setCupsProperties(), QScript::Lexer::setErrorMessage(), QDeclarativeJS::Lexer::setErrorMessage(), setIntOption(), QScriptDebuggerConsoleWidget::setLineContinuationMode(), QDBusPendingCallPrivate::setMetaTypes(), QComboBoxDelegate::setSeparator(), QPatternist::XsdSchemaContext::setupBuiltinTypesFacetList(), QPatternist::XsdSchemaParserContext::setupElementDescriptions(), QPageSetupWidget::setupPrinter(), QScriptDebuggerConsole::showDebuggerInfoMessage(), QPushButton::sizeHint(), QHttpSocketEngine::slotSocketReadNotification(), sm_performSaveYourself(), QSmSocketReceiver::socketActivated(), QFtpDTP::socketReadyRead(), QPatternist::XsdSchemaChecker::sourceLocation(), QPatternist::XsdSchemaResolver::sourceLocation(), standardLibraryErrorString(), QScriptCompletionTask::start(), QXmlStreamReaderPrivate::startDocument(), QSvgHandler::startElement(), QScriptDebugger::stepIntoAction(), QScriptDebugger::stepOutAction(), QScriptDebugger::stepOverAction(), QPatternist::Base64Binary::stringValue(), QPatternist::AbstractFloat< isDouble >::stringValue(), stripTextDecl(), QGuiPlatformPlugin::styleName(), QSslCertificate::subjectInfo(), QIBaseDriver::subscribeToNotificationImplementation(), QUrl::swap(), QGuiPlatformPlugin::systemIconThemeName(), QDeclarativeCompiler::testLiteralAssignment(), QLineControl::text(), QTextHtmlExporter::toHtml(), QPatternist::Tokenizer::tokenToString(), toQAudioFormat(), QPatternist::AnyURI::toQUrl(), QBenchmarkContext::toString(), QDate::toString(), QScriptDebuggerValue::toString(), QHashableLatin1Literal::toString(), QTest::toString(), QPatternist::Decimal::toString(), QTime::toString(), QDateTime::toString(), toUnicode(), QPatternist::AtomicValue::toXDM(), QCoreApplication::translate(), translate_color(), translate_dashPattern(), QXlibKeyboard::translateKeySym(), QXcbKeyboard::translateKeySym(), translateKeySym(), translateWSAError(), QSystemLocalePrivate::uiLanguages(), QScriptEngine::uncaughtExceptionBacktrace(), QPageSetupWidget::unitChanged(), QPatternist::NamePool::unlockedAllocateLocalName(), QIBaseDriver::unsubscribeFromNotificationImplementation(), QBBEngine::updateConfiguration(), QFactoryLoader::updateDir(), QLineControl::updateDisplayText(), QSystemLocaleData::updateLocale(), QPrintPreviewDialogPrivate::updatePageNumLabel(), ShaderEffectItem::updateShaderProgram(), QPatternist::XsdValidatingInstanceReader::validate(), QPatternist::XsdSchemaParser::validateIdAttribute(), QAxFactory::validateLicenseKey(), valueCheck(), QScript::variantProtoFuncToString(), QSettingsPrivate::variantToString(), vsprintf(), windowsErrorString(), WinMain(), QSystemLocalePrivate::winToQtFormat(), QXmlStreamWriterPrivate::write(), QTextOdfWriter::writeAll(), QTextOdfWriter::writeBlock(), QTextOdfWriter::writeBlockFormat(), QTextOdfWriter::writeCharacterFormat(), QTextOdfWriter::writeFormats(), QTextOdfWriter::writeFrame(), QTextOdfWriter::writeFrameFormat(), QPdfEnginePrivate::writeInfo(), QTextOdfWriter::writeInlineCharacter(), QTextOdfWriter::writeListFormat(), QTextOdfWriter::writeTableCellFormat(), QApplicationPrivate::x11_apply_settings(), QX11EmbedWidget::x11Event(), QXIMInputContext::x11FilterEvent(), QX11Data::xdndMimeAtomToString(), QX11Data::xdndMimeConvertToFormat(), QX11Data::xdndMimeDataForAtom(), xdndObtainData(), QDBusDefaultConnection::~QDBusDefaultConnection(), and QZipStreamStrategy::~QZipStreamStrategy().

4189 {
4190  return QString(fromLatin1_helper(str, size), 0);
4191 }
int size() const
Returns the number of characters in this string.
Definition: qstring.h:102
static Data * fromLatin1_helper(const char *str, int size=-1)
Definition: qstring.cpp:4104
QString()
Constructs a null string.
Definition: qstring.h:879

◆ fromLatin1_helper()

QString::Data * QString::fromLatin1_helper ( const char *  str,
int  size = -1 
)
staticprivate

Definition at line 4104 of file qstring.cpp.

Referenced by fromAscii_helper(), and fromLatin1().

4105 {
4106  Data *d;
4107  if (!str) {
4108  d = &shared_null;
4109  d->ref.ref();
4110  } else if (size == 0 || (!*str && size < 0)) {
4111  d = &shared_empty;
4112  d->ref.ref();
4113  } else {
4114  if (size < 0)
4115  size = qstrlen(str);
4116  d = static_cast<Data *>(qMalloc(sizeof(Data) + size * sizeof(QChar)));
4117  Q_CHECK_PTR(d);
4118  d->ref = 1;
4119  d->alloc = d->size = size;
4120  d->clean = d->asciiCache = d->simpletext = d->righttoleft = d->capacity = 0;
4121  d->data = d->array;
4122  d->array[size] = '\0';
4123  ushort *dst = d->data;
4124  /* SIMD:
4125  * Unpacking with SSE has been shown to improve performance on recent CPUs
4126  * The same method gives no improvement with NEON.
4127  */
4128 #if defined(QT_ALWAYS_HAVE_SSE2)
4129  if (size >= 16) {
4130  int chunkCount = size >> 4; // divided by 16
4131  const __m128i nullMask = _mm_set1_epi32(0);
4132  for (int i = 0; i < chunkCount; ++i) {
4133  const __m128i chunk = _mm_loadu_si128((__m128i*)str); // load
4134  str += 16;
4135 
4136  // unpack the first 8 bytes, padding with zeros
4137  const __m128i firstHalf = _mm_unpacklo_epi8(chunk, nullMask);
4138  _mm_storeu_si128((__m128i*)dst, firstHalf); // store
4139  dst += 8;
4140 
4141  // unpack the last 8 bytes, padding with zeros
4142  const __m128i secondHalf = _mm_unpackhi_epi8 (chunk, nullMask);
4143  _mm_storeu_si128((__m128i*)dst, secondHalf); // store
4144  dst += 8;
4145  }
4146  size = size % 16;
4147  }
4148 #endif
4149  while (size--)
4150  *dst++ = (uchar)*str++;
4151  }
4152  return d;
4153 }
Q_CORE_EXPORT void * qMalloc(size_t size)
Definition: qmalloc.cpp:53
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
QBasicAtomicInt ref
Definition: qstring.h:604
static Data shared_null
Definition: qstring.h:616
unsigned char uchar
Definition: qglobal.h:994
int size() const
Returns the number of characters in this string.
Definition: qstring.h:102
Data * d
Definition: qstring.h:618
uint qstrlen(const char *str)
Definition: qbytearray.h:79
#define Q_CHECK_PTR(p)
Definition: qglobal.h:1853
unsigned short ushort
Definition: qglobal.h:995
static Data shared_empty
Definition: qstring.h:617

◆ fromLocal8Bit()

QString QString::fromLocal8Bit ( const char *  str,
int  size = -1 
)
static

Returns a QString initialized with the first size characters of the 8-bit string str.

If size is -1 (default), it is taken to be qstrlen(str).

QTextCodec::codecForLocale() is used to perform the conversion.

See also
toLocal8Bit(), fromAscii(), fromLatin1(), fromUtf8()

Definition at line 4245 of file qstring.cpp.

Referenced by QUnixPrintWidgetPrivate::_q_printerChanged(), QCoreApplication::applicationFilePath(), QUnixPrintWidgetPrivate::applyPrinterProperties(), QApplicationPrivate::applyX11SpecificCommandLineArguments(), QCoreApplication::arguments(), QFileSystemEngine::canonicalName(), QCUPSSupport::collectMarkedOptionsHelper(), QApplicationPrivate::construct(), QWindowsMimeText::convertToMime(), QWindowsMimeURI::convertToMime(), dlIterateCallback(), QtopiaPrintEngine::end(), QZipReader::fileData(), QZipPrivate::fillFileInfo(), QPlatformFontDatabase::fontDir(), fontPath(), QHostInfoAgent::fromName(), QFileDialogPrivate::getEnvironmentVariable(), getMacLocaleName(), QGtkStylePrivate::getThemeName(), getWinLocaleName(), QTDSResult::gotoNext(), interfaceListingWin2k(), interfaceListingWinXP(), isDirPath(), QKde::kdeHome(), launchWebBrowser(), QLibraryInfo::licensee(), QAxScriptManager::load(), locale_decode(), QHostInfo::localHostName(), QLibraryInfo::location(), QXlibMime::mimeConvertToFormat(), QProcessEnvironmentPrivate::OrderedMutexLocker::OrderedMutexLocker(), parseGeometry(), QPlatformFontDatabase::populateFontDatabase(), QApplicationPrivate::process_cmdline(), QCoreApplicationPrivate::processCommandLineArguments(), qCmdLineArgs(), qdlerror(), qMakeError(), QPdfBaseEngine::QPdfBaseEngine(), QRuntimeGraphicsSystem::QRuntimeGraphicsSystem(), qt_create_commandline(), qt_error_string(), qt_getLprPrinters(), qt_guiPlatformPlugin(), qt_init(), qt_parseEtcLpPrinters(), qt_parsePrintcap(), qt_parsePrintersConf(), qt_parseSpoolInterface(), qt_set_qws_resources(), qt_set_x11_resources(), qt_tildeExpansion(), qt_wstate_iconified(), QUnixPrintWidgetPrivate::QUnixPrintWidgetPrivate(), qWinMsgHandler(), qwsFontPath(), QWSTslibMouseHandlerPrivate::QWSTslibMouseHandlerPrivate(), QXlibDisplay::QXlibDisplay(), QWSCalibratedMouseHandler::readCalibration(), QPSQLResult::record(), QXIMInputContext::reset(), QPageSetupWidget::selectPrinter(), QPPDOptionsEditor::setEditorData(), QSmSocketReceiver::socketActivated(), standardLibraryErrorString(), QProcessPrivate::startDetached(), QProcessPrivate::startProcess(), QApplication::style(), QProcess::systemEnvironment(), QCUPSSupport::tempFd(), timeZone(), translateWSAError(), QWSCalibratedMouseHandler::writeCalibration(), QX11Data::xdndMimeConvertToFormat(), and xic_draw_callback().

4246 {
4247  if (!str)
4248  return QString();
4249  if (size == 0 || (!*str && size < 0))
4250  return QLatin1String("");
4251 #if !defined(QT_NO_TEXTCODEC)
4252  if (size < 0)
4253  size = qstrlen(str);
4255  if (codec)
4256  return codec->toUnicode(str, size);
4257 #endif // !QT_NO_TEXTCODEC
4258  return fromLatin1(str, size);
4259 }
static QTextCodec * codecForLocale()
Returns a pointer to the codec most suitable for this locale.
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
int size() const
Returns the number of characters in this string.
Definition: qstring.h:102
static QTextCodec * codec(MYSQL *mysql)
Definition: qsql_mysql.cpp:220
QString toUnicode(const QByteArray &) const
Converts a from the encoding of this codec to Unicode, and returns the result in a QString...
uint qstrlen(const char *str)
Definition: qbytearray.h:79
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188
The QTextCodec class provides conversions between text encodings.
Definition: qtextcodec.h:62
QString()
Constructs a null string.
Definition: qstring.h:879

◆ fromRawData()

QString QString::fromRawData ( const QChar unicode,
int  size 
)
static

Constructs a QString that uses the first size Unicode characters in the array unicode.

The data in unicode is not copied. The caller must be able to guarantee that unicode will not be deleted or modified as long as the QString (or an unmodified copy of it) exists.

Any attempts to modify the QString or copies of it will cause it to create a deep copy of the data, ensuring that the raw data isn't modified.

Here's an example of how we can use a QRegExp on raw data in memory without requiring to copy the data into a QString:

QRegExp pattern;
static const QChar unicode[] = {
0x005A, 0x007F, 0x00A4, 0x0060,
0x1009, 0x0020, 0x0020};
int size = sizeof(unicode) / sizeof(QChar);
QString str = QString::fromRawData(unicode, size);
if (str.contains(QRegExp(pattern))) {
// ...
}
Warning
A string created with fromRawData() is not '\0'-terminated, unless the raw data contains a '\0' character at position size. This means unicode() will not return a '\0'-terminated string (although utf16() does, at the cost of copying the raw data).
See also
fromUtf16(), setRawData()

Definition at line 7673 of file qstring.cpp.

Referenced by QFontMetrics::charWidth(), QSvgPaintEngine::drawTextItem(), QRasterPaintEngine::drawTextItem(), getLocaleData(), getLocaleListData(), QDeclarativeExpressionPrivate::init(), launchWebBrowser(), QDeclarativeVMEMetaObject::method(), QXlibMime::mimeConvertToFormat(), QDeclarativeCompiledBindingsPrivate::run(), setRawData(), QTextBlock::text(), XsdSchemaToken::toString(), QPatternist::XSLTTokenLookup::toString(), and QX11Data::xdndMimeConvertToFormat().

7674 {
7675  Data *x = static_cast<Data *>(qMalloc(sizeof(Data)));
7676  Q_CHECK_PTR(x);
7677  if (unicode) {
7678  x->data = (ushort *)unicode;
7679  } else {
7680  x->data = x->array;
7681  size = 0;
7682  }
7683  x->ref = 1;
7684  x->alloc = x->size = size;
7685  *x->array = '\0';
7686  x->clean = x->asciiCache = x->simpletext = x->righttoleft = x->capacity = 0;
7687  return QString(x, 0);
7688 }
Q_CORE_EXPORT void * qMalloc(size_t size)
Definition: qmalloc.cpp:53
int size() const
Returns the number of characters in this string.
Definition: qstring.h:102
#define Q_CHECK_PTR(p)
Definition: qglobal.h:1853
unsigned short ushort
Definition: qglobal.h:995
QString()
Constructs a null string.
Definition: qstring.h:879

◆ fromStdString()

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

Returns a copy of the str string.

The given string is converted to Unicode using the fromAscii() function.

This constructor is only available if Qt is configured with STL compatibility enabled.

See also
fromAscii(), fromLatin1(), fromLocal8Bit(), fromUtf8()

Definition at line 1047 of file qstring.h.

1048 { return fromAscii(s.data(), int(s.size())); }
static QString fromAscii(const char *, int size=-1)
Returns a QString initialized with the first size characters from the string str. ...
Definition: qstring.cpp:4276

◆ fromStdWString()

QString QString::fromStdWString ( const std::wstring &  str)
inlinestatic

Returns a copy of the str string.

The given string is assumed to be encoded in utf16 if the size of wchar_t is 2 bytes (e.g. on windows) and ucs4 if the size of wchar_t is 4 bytes (most Unix systems).

This method is only available if Qt is configured with STL compatibility enabled.

See also
fromUtf16(), fromLatin1(), fromLocal8Bit(), fromUtf8(), fromUcs4()

Definition at line 1065 of file qstring.h.

1066 { return fromWCharArray(s.data(), int(s.size())); }
static QString fromWCharArray(const wchar_t *, int size=-1)
Returns a copy of the string, where the encoding of string depends on the size of wchar...
Definition: qstring.cpp:1019

◆ fromUcs4()

QString QString::fromUcs4 ( const uint unicode,
int  size = -1 
)
static

Returns a QString initialized with the first size characters of the Unicode string unicode (ISO-10646-UCS-4 encoded).

Since
4.2

If size is -1 (default), unicode must be terminated with a 0.

See also
toUcs4(), fromUtf16(), utf16(), setUtf16(), fromWCharArray()

Definition at line 4356 of file qstring.cpp.

Referenced by fromSQLTCHAR(), fromWCharArray(), QFontMetrics::inFontUcs4(), QFontMetricsF::inFontUcs4(), and QXmlStreamReaderPrivate::parse().

4357 {
4358  if (!unicode)
4359  return QString();
4360  if (size < 0) {
4361  size = 0;
4362  while (unicode[size] != 0)
4363  ++size;
4364  }
4365  return QUtf32::convertToUnicode((const char *)unicode, size*4, 0);
4366 }
static QString convertToUnicode(const char *, int, QTextCodec::ConverterState *, DataEndianness=DetectEndianness)
Definition: qutfcodec.cpp:444
int size() const
Returns the number of characters in this string.
Definition: qstring.h:102
const QChar * unicode() const
Returns a &#39;\0&#39;-terminated Unicode representation of the string.
Definition: qstring.h:706
QString()
Constructs a null string.
Definition: qstring.h:879

◆ fromUtf16()

QString QString::fromUtf16 ( const ushort unicode,
int  size = -1 
)
static

Returns a QString initialized with the first size characters of the Unicode string unicode (ISO-10646-UTF-16 encoded).

If size is -1 (default), unicode must be terminated with a 0.

This function checks for a Byte Order Mark (BOM). If it is missing, host byte order is assumed.

This function is slow compared to the other Unicode conversions. Use QString(const QChar *, int) or QString(const QChar *) if possible.

QString makes a deep copy of the Unicode data.

See also
utf16(), setUtf16()

Definition at line 4329 of file qstring.cpp.

Referenced by QChar::decomposition(), fromSQLTCHAR(), fromWCharArray(), launchWebBrowser(), QNlaThread::parseQuerySet(), and qMakeError().

4330 {
4331  if (!unicode)
4332  return QString();
4333  if (size < 0) {
4334  size = 0;
4335  while (unicode[size] != 0)
4336  ++size;
4337  }
4338  return QUtf16::convertToUnicode((const char *)unicode, size*2, 0);
4339 }
int size() const
Returns the number of characters in this string.
Definition: qstring.h:102
const QChar * unicode() const
Returns a &#39;\0&#39;-terminated Unicode representation of the string.
Definition: qstring.h:706
static QString convertToUnicode(const char *, int, QTextCodec::ConverterState *, DataEndianness=DetectEndianness)
Definition: qutfcodec.cpp:313
QString()
Constructs a null string.
Definition: qstring.h:879

◆ fromUtf8()

QString QString::fromUtf8 ( const char *  str,
int  size = -1 
)
static

Returns a QString initialized with the first size bytes of the UTF-8 string str.

If size is -1 (default), it is taken to be qstrlen(str).

UTF-8 is a Unicode codec and can represent all characters in a Unicode string like QString. However, invalid sequences are possible with UTF-8 and, if any such are found, they will be replaced with one or more "replacement characters", or suppressed. These include non-Unicode sequences, non-characters, overlong sequences or surrogate codepoints encoded into UTF-8.

Non-characters are codepoints that the Unicode standard reserves and must not be used in text interchange. They are the last two codepoints in each Unicode Plane (U+FFFE, U+FFFF, U+1FFFE, U+1FFFF, U+2FFFE, etc.), as well as 16 codepoints in the range U+FDD0..U+FDDF, inclusive.

See also
toUtf8(), fromAscii(), fromLatin1(), fromLocal8Bit()

Definition at line 4302 of file qstring.cpp.

Referenced by QDeclarativeVisualDataModel::_q_itemsChanged(), _q_mapFromX509Name(), QDBusServer::address(), QDeclarativePropertyCache::append(), QDeclarativeCompiler::buildBinding(), QDeclarativeCompiler::buildGroupedProperty(), QDeclarativeCompiler::buildObject(), QDeclarativeCompiler::buildProperty(), QDeclarativeCompiler::buildPropertyObjectAssignment(), QDeclarativeCompiler::buildPropertyOnAssignment(), QDeclarativeCompiler::buildSignal(), QDeclarativeCompiler::buildValueTypeProperty(), cacheForNamespace(), QDeclarativeObjectMethodScriptClass::callOverloaded(), QDeclarativeCompiler::checkDynamicMeta(), QODBCDriver::cleanup(), QPrintDialogPrivate::closeCarbonPrintPanel(), QDeclarativeGestureAreaParser::compile(), QDeclarativeConnectionsParser::compile(), QDeclarativePropertyChangesParser::compile(), QDeclarativeListModelParser::compile(), containsTLDEntry(), Maemo::convertKey(), QMacPasteboardMimeAny::convertToMime(), QWindowsMimeHtml::convertToMime(), Maemo::convertValue(), QDeclarativePropertyCache::create(), QDeclarativeEnginePrivate::createCache(), QPatternist::ExpressionFactory::createExpression(), QDBusMarshaller::currentSignature(), QDBusDemarshaller::currentSignature(), QPSQLResult::data(), QDeclarativeScriptData::dataReceived(), QDeclarativeQmldirData::dataReceived(), QDeclarativeCompiler::deferredProperties(), QDeclarativeXMLHttpRequest::downloadProgress(), QDeclarativeXMLHttpRequest::error(), QXmlQuery::evaluateTo(), QFontEngineQPA::extractHeaderField(), QFontEngineQPF::extractHeaderField(), QFontconfigDatabase::fallbacksForFamily(), QSQLite2ResultPrivate::fetchNext(), QDeclarativeImportsPrivate::find(), QDeclarativeImportedNamespace::find_helper(), QDeclarativeInclude::finished(), QDeclarativeXMLHttpRequest::finished(), QDBusMessagePrivate::fromDBusMessage(), fromPercentEncodingHelper(), fromPercentEncodingMutable(), fromSQLTCHAR(), QFreetypeFace::getFace(), QGtkStylePrivate::getFilesystemIcon(), getFullPath(), QGtkStylePrivate::getGConfString(), getIBaseError(), QGtkStylePrivate::getIconThemeName(), Maemo::getVariantFromDBusMessage(), QApplicationPrivate::globalAppleEventProcessor(), QIBaseResult::gotoNext(), QDeclarativeXMLHttpRequest::header(), QDeclarativeXMLHttpRequest::headers(), QTextHtmlParser::importStyleSheet(), QDeclarativeInclude::include(), QDeclarativeCompiler::indexOfProperty(), QDeclarativeCompiler::indexOfSignal(), QFontEngineFT::init(), initializeDb(), QDeclarativeVisualDataModelPartsMetaObject::initialValue(), QTextControl::insertFromMimeData(), QSslCertificatePrivate::isBlacklisted(), QDeclarativeVisualDataModel::item(), launchWebBrowser(), QLibraryPrivate::load_sys(), loadFontConfig(), locale_decode(), macQuoteString(), QXlibMime::mimeConvertToFormat(), QBBClipboard::MimeData::MimeData(), QXlibMime::mimeDataForAtom(), QDeclarativeProperty::name(), QDeclarativePropertyCache::Data::name(), QDeclarativeEngineDebugService::objectData(), QDeclarativeDebugService::objectToString(), QGtkStylePrivate::openDirectory(), QGtkStylePrivate::openFilename(), QGtkStylePrivate::openFilenames(), QDeclarativeRewrite::RewriteBinding::operator()(), QDeclarativeDirParser::parse(), QNetworkCookiePrivate::parseSetCookieHeaderLine(), QFontconfigDatabase::populateFontDatabase(), QDBusConnectionPrivate::prepareHook(), QSvgHandler::processingInstruction(), QDeclarativeWorkerScriptEnginePrivate::processLoad(), QDBusAbstractInterfacePrivate::property(), QDeclarativePropertyMapMetaObject::propertyCreated(), QDeclarativeEngineDebugService::propertyData(), QDeclarativeObjectScriptClass::propertyNames(), QDeclarativePropertyMapMetaObject::propertyWritten(), ModelNodeMetaObject::propertyWritten(), QDBusError::QDBusError(), qDBusGenerateMetaObjectXml(), QDeclarativeGridScaledImage::QDeclarativeGridScaledImage(), qGetStringData(), qMakeError(), qMakeFieldInfo(), QScript::qobjectProtoFuncToString(), QScriptDebuggerCodeFinderWidget::QScriptDebuggerCodeFinderWidget(), QScriptNewBreakpointWidget::QScriptNewBreakpointWidget(), qStringFromNSString(), qt_FcPatternToQFontDef(), QFileDialogPrivate::qt_mac_filedialog_event_proc(), QFileDialogPrivate::qt_mac_filedialog_filter_proc(), qWarnODBCHandle(), QXcbScreen::QXcbScreen(), readArrayBuffer(), QPngHandlerPrivate::readPngTexts(), QPSQLResult::record(), registerComponent(), registerFont(), QDeclarativeXMLHttpRequest::requestFromUrl(), QDeclarativeImports::resolveType(), QDeclarativeXMLHttpRequest::responseBody(), QDeclarativeRewrite::RewriteBinding::rewrite(), QGtkStylePrivate::saveFilename(), QCoreApplication::sendPostedEvents(), QJSDebuggerAgent::setBreakpoints(), QDBusConnectionPrivate::setConnection(), QDeclarativeListModelParser::setCustomData(), QDeclarativeEngineDebugService::setMethodBody(), QDBusAbstractInterfacePrivate::setProperty(), QProcessPrivate::startProcess(), QNetworkProxyFactory::systemProxyForQuery(), QDeclarativeCompiler::testLiteralAssignment(), QDeclarativeCompiler::testQualifiedEnumAssignment(), QDBusDemarshaller::toObjectPathUnchecked(), QDBusDemarshaller::toSignatureUnchecked(), QDeclarativeObjectScriptClass::tostring(), QDBusDemarshaller::toStringUnchecked(), toUrl(), QCoreApplication::translate(), Maemo::IAPConfPrivate::valueToVariant(), vsprintf(), QDeclarativeInclude::worker_include(), QDeclarativePropertyPrivate::write(), QFontDatabase::writingSystemSample(), QX11Data::xdndMimeConvertToFormat(), QX11Data::xdndMimeDataForAtom(), QCoreApplicationData::~QCoreApplicationData(), and QDeclarativeInfo::~QDeclarativeInfo().

4303 {
4304  if (!str)
4305  return QString();
4306  if (size < 0)
4307  size = qstrlen(str);
4308 
4309  return QUtf8::convertToUnicode(str, size, 0);
4310 }
int size() const
Returns the number of characters in this string.
Definition: qstring.h:102
static QString convertToUnicode(const char *, int, QTextCodec::ConverterState *)
Definition: qutfcodec.cpp:156
uint qstrlen(const char *str)
Definition: qbytearray.h:79
QString()
Constructs a null string.
Definition: qstring.h:879

◆ fromWCharArray()

QString QString::fromWCharArray ( const wchar_t *  string,
int  size = -1 
)
static

Returns a copy of the string, where the encoding of string depends on the size of wchar.

Since
4.2

If wchar is 4 bytes, the string is interpreted as ucs-4, if wchar is 2 bytes it is interpreted as ucs-2.

If size is -1 (default), the string has to be 0 terminated.

See also
fromUtf16(), fromLatin1(), fromLocal8Bit(), fromUtf8(), fromUcs4(), fromStdWString()

Definition at line 1019 of file qstring.cpp.

Referenced by QAxClientSite::activateObject(), QFileSystemModelPrivate::addNode(), QWindowsMime::allMimesForFormats(), QSystemLocalePrivate::amText(), QCoreApplication::arguments(), checkHRESULT(), childKeysOrGroups(), QNativeWifiEngine::connectToId(), ControlList::ControlList(), QWindowsMimeText::convertToMime(), QWindowsMimeURI::convertToMime(), QBuiltInMimes::convertToMime(), QClassFactory::CreateInstanceLic(), QSystemLocalePrivate::currencySymbol(), QWin32PrintEngine::drawTextItem(), DumpIDL(), errorCodeToString(), expandEnvStrings(), QAxEventSink::findProperty(), QSystemLocalePrivate::firstDayOfWeek(), fromStdWString(), QFontEngineWin::getCMap(), QOleDataObject::GetData(), QNativeWifiEngine::getInterfaceFromId(), QAxScriptSite::GetItemInfo(), QSystemLocalePrivate::getLocaleInfo(), QNativeWifiEngine::hasIdentifier(), IFontToQFont(), QWindowsSystemProxy::init(), initFontInfo(), QAxBase::initializeLicensedHelper(), interfaceListingWinXP(), QAxServerBase::Invoke(), isDirPath(), launchWebBrowser(), QSystemLibrary::load(), QAxServerBase::Load(), loadEngine(), QFSFileEnginePrivate::longFileName(), QSystemLocalePrivate::measurementSystem(), menuItemEntry(), MetaObjectGenerator::metaObject(), MetaObjectGenerator::MetaObjectGenerator(), QLastResortMimes::mimeForFormat(), QFileSystemEngine::nativeAbsoluteFilePath(), QFileSystemModelPrivate::node(), QAxServerBase::OnAmbientPropertyChange(), QBBInputContext::onCommitText(), QAxScriptSite::OnScriptError(), QAxScriptSite::OnScriptTerminate(), QBBInputContext::onSetComposingText(), QFileSystemEngine::owner(), QNlaThread::parseQuerySet(), QSystemLocalePrivate::pmText(), QFontEngineWin::properties(), qAppFileName(), qax_docuFromName(), qax_readClassInfo(), qax_readInterfaceInfo(), qAxInit(), qCmdLineArgs(), QSessionManager::QSessionManager(), QSystemLibrary::QSystemLibrary(), qt_CoCreateGuid(), qt_create_commandline(), qt_error_string(), qt_LOGFONTtoQFont(), QAxClientSite::qt_metacall(), qt_reg_winclass(), qt_win_get_existing_directory(), qt_win_get_open_file_name(), qt_win_get_open_file_names(), qt_win_get_save_file_name(), QtCeGetClipboard(), QtWndProc(), QWin32PrintEnginePrivate::queryDefault(), qWinCmdArgs(), QtPropertyBag::Read(), QWin32PrintEnginePrivate::readDevnames(), MetaObjectGenerator::readEnumInfo(), MetaObjectGenerator::readEventInterface(), MetaObjectGenerator::readFuncsInfo(), QWinSettingsPrivate::readKey(), readLink(), readSymLink(), MetaObjectGenerator::readVarsInfo(), QAxFactory::registerActiveObject(), registerFont(), QAxServerBase::Save(), QAxServerBase::SaveCompleted(), QNativeWifiEngine::scanComplete(), QAxFactory::serverDirPath(), QAxFactory::serverFilePath(), storeFont(), timeZone(), QSystemLocalePrivate::toCurrencyString(), QSystemLocalePrivate::toString(), QDateTime::toString(), QSystemLocalePrivate::uiLanguages(), QFileSystemEngine::uncListSharesOnServer(), UpdateRegistry(), MetaObjectGenerator::usertypeToString(), QAxFactory::validateLicenseKey(), VARIANTToQVariant(), QAxBase::verbs(), windowsConfigPath(), windowsErrorString(), winGetExistDirCallbackProc(), winIso3116CtryName(), winIso639LangName(), WinMain(), and QtPropertyBag::Write().

1020 {
1021  if (sizeof(wchar_t) == sizeof(QChar)) {
1022  return fromUtf16((const ushort *)string, size);
1023  } else {
1024  return fromUcs4((uint *)string, size);
1025  }
1026 }
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
int size() const
Returns the number of characters in this string.
Definition: qstring.h:102
unsigned int uint
Definition: qglobal.h:996
unsigned short ushort
Definition: qglobal.h:995
static QString fromUtf16(const ushort *, int size=-1)
Returns a QString initialized with the first size characters of the Unicode string unicode (ISO-10646...
Definition: qstring.cpp:4329
static QString fromUcs4(const uint *, int size=-1)
Returns a QString initialized with the first size characters of the Unicode string unicode (ISO-10646...
Definition: qstring.cpp:4356

◆ grow()

int QString::grow ( int  size)
staticprivate

Definition at line 822 of file qstring.cpp.

Referenced by append(), and resize().

823 {
824  return qAllocMore(size * sizeof(QChar), sizeof(Data)) / sizeof(QChar);
825 }
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
int qAllocMore(int alloc, int extra)
Definition: qbytearray.cpp:70
int size() const
Returns the number of characters in this string.
Definition: qstring.h:102

◆ indexOf() [1/6]

int QString::indexOf ( QChar  c,
int  from = 0,
Qt::CaseSensitivity  cs = Qt::CaseSensitive 
) const

Definition at line 2838 of file qstring.cpp.

Referenced by _q_parseUnixDir(), QHttpPrivate::_q_slotReadyRead(), QDeclarativePropertyCache::append(), QKeySequence::assign(), QDeclarativeEngineDebugService::buildObjectDump(), QTextEngine::calculateTabWidth(), QDBusAbstractInterface::callWithArgumentList(), QDir::cd(), QVNCScreen::connect(), QTransformedScreen::connect(), QLinuxFbIntegration::connect(), contains(), QHttpHeader::contentType(), QPatternist::XsdInstanceReader::convertToQName(), QPatternist::XsdTypeChecker::convertToQName(), QDeclarativePropertyCache::create(), QFileSystemEngine::createDirectory(), QScriptDebuggerConsolePrivate::createJob(), QDeclarativeComponentPrivate::createObject(), QScriptDebuggerLocalsModel::data(), QKeySequencePrivate::decodeString(), double2string(), QWindowsCEStyle::drawControl(), QWindowsVistaStyle::drawControl(), QPlastiqueStyle::drawControl(), QCleanlooksStyle::drawControl(), QWindowsXPStyle::drawControl(), QWindowsStyle::drawControl(), QGtkStyle::drawControl(), QMotifStyle::drawControl(), QMacStyle::drawControl(), QStyleSheetStyle::drawControl(), QItemDelegate::drawDisplay(), QFontMetrics::elidedText(), QFontMetricsF::elidedText(), QConfFileSettingsPrivate::ensureSectionParsed(), QPatternist::SubstringBeforeFN::evaluateSingleton(), QSymSQLResult::exec(), QSqlResult::exec(), extractEncodingDecl(), QDateTimeParser::findAmPm(), findChildObject(), QFontDatabase::findFont(), findObject(), fixedCDataSection(), fixedComment(), fixedPIData(), fixedPubidLiteral(), fixedSystemLiteral(), QMacPasteboardMimeUnicodeText::flavorFor(), fontPath(), fractionDigitsForDecimal(), QPatternist::NamePool::fromClarkName(), QUrl::fromLocalFile(), QDir::fromNativeSeparators(), QSslCertificate::fromPath(), QDateTime::fromString(), QUrl::fromUserInput(), QDirPrivate::getFilterSepChar(), getStringTok(), QImageReaderPrivate::getText(), QGtkStylePrivate::getThemeName(), QScriptToolTipJob::handleResponse(), QByteArray::indexOf(), QSvgSwitch::init(), QAxBase::initializeRemote(), QMenu::initStyleOption(), QDeclarativeDebugServer::instance(), QAxServerBase::Invoke(), isDirPath(), QXmlSimpleReaderPrivate::isExpandedEntityValueTooLarge(), QSslSocketBackendPrivate::isMatchingHostname(), isUncRoot(), QDBusUtil::isValidObjectPath(), QMenuBar::keyPressEvent(), QMenu::keyPressEvent(), QByteArray::lastIndexOf(), launchWebBrowser(), QAxServerBase::Load(), QLibraryPrivate::load_sys(), Qt::mightBeRichText(), QKeySequence::mnemonic(), QDeclarativePropertyCache::Data::name(), QSqlRelationalTableModelPrivate::nameToIndex(), QWSServerPrivate::newMouseHandler(), QDeclarativeEngineDebugService::objectData(), QAudioDeviceInfoInternal::open(), QWSServer::openKeyboard(), QStringRef::operator=(), QDeclarativeDirParser::parse(), QHttpHeader::parse(), parseFontName(), QLineControl::parseInputMask(), QHttpHeader::parseLine(), QHttpResponseHeader::parseLine(), parseServerList(), QHostAddress::parseSubnet(), QDeclarativeStringConverters::pointFFromString(), QApplicationPrivate::process_cmdline(), QSettingsPrivate::processChild(), QFtpPI::processReply(), QDeclarativeGridScaledImage::QDeclarativeGridScaledImage(), qExtractSecurityPolicyFromString(), qGetTableInfo(), qIsEffectiveTLD(), QMacSettingsPrivate::QMacSettingsPrivate(), qSplitTableAndOwner(), qSplitTableName(), qt_accAmpIndex(), qt_get_screen(), qt_mac_menu_merge_action(), qt_make_filter_list(), qt_parsePrinterDesc(), qt_parsePrintersConf(), qt_parseQconfig(), qt_parseSpoolInterface(), qt_set_x11_resources(), qt_setWindowTitle_helperHelper(), qt_split_namespace(), qt_splitLocaleName(), qt_win_get_save_file_name(), QTextHtmlImporter::QTextHtmlImporter(), quotedValue(), QXmlStreamAttribute::QXmlStreamAttribute(), QDeclarativeStringConverters::rectFFromString(), registerFont(), remove(), QInternalMimeData::renderDataHelper(), replacePercentN(), QDeclarativeXMLHttpRequest::requestFromUrl(), QAxServerBase::Save(), QPatternist::XQueryTokenizer::scanUntil(), QAxScriptManager::scriptForFunction(), set_text(), QUrlPrivate::setAuthority(), QAxBase::setControl(), QTextBrowserPrivate::setSource(), QUndoCommand::setText(), QGtkStylePrivate::setupGtkFileChooser(), QUrl::setUrl(), QUrlPrivate::setUserInfo(), QDeclarativeStringConverters::sizeFFromString(), QFileSystemEngine::slowCanonicalized(), split(), QXmlNamespaceSupport::splitName(), splitSpaceSemicolon(), QAudioDeviceInfoInternal::testSettings(), QImage::textLanguages(), QImage::textList(), QPatternist::XQueryTokenizer::tokenizeCharacterReference(), QDir::toNativeSeparators(), tryDriveUNCFallback(), QMenuPrivate::updateActionRects(), QAuthenticatorPrivate::updateCredentials(), QDeclarativeStringConverters::vector3DFromString(), QFontMetrics::width(), QFontMetricsF::width(), xdndObtainData(), and QDeclarativeInfo::~QDeclarativeInfo().

2839 {
2840  return findChar(unicode(), length(), ch, from, cs);
2841 }
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
const QChar * unicode() const
Returns a &#39;\0&#39;-terminated Unicode representation of the string.
Definition: qstring.h:706
static int findChar(const QChar *str, int len, QChar ch, int from, Qt::CaseSensitivity cs)
Returns the index position of the first occurrence of the character ch in the string given by str and...
Definition: qstring.cpp:333

◆ indexOf() [2/6]

int QString::indexOf ( const QString str,
int  from = 0,
Qt::CaseSensitivity  cs = Qt::CaseSensitive 
) const

Returns the index position of the first occurrence of the string str in this string, searching forward from index position from.

Returns -1 if str is not found.

If cs is Qt::CaseSensitive (default), the search is case sensitive; otherwise the search is case insensitive.

Example:

QString x = "sticky question";
QString y = "sti";
x.indexOf(y); // returns 0
x.indexOf(y, 1); // returns 10
x.indexOf(y, 10); // returns 10
x.indexOf(y, 11); // returns -1

If from is -1, the search starts at the last character; if it is -2, at the next to last character and so on.

See also
lastIndexOf(), contains(), count()

Definition at line 2721 of file qstring.cpp.

2722 {
2723  return qFindString(unicode(), length(), from, str.unicode(), str.length(), cs);
2724 }
int qFindString(const QChar *haystack, int haystackLen, int from, const QChar *needle, int needleLen, Qt::CaseSensitivity cs)
Definition: qstring.cpp:2753
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
const QChar * unicode() const
Returns a &#39;\0&#39;-terminated Unicode representation of the string.
Definition: qstring.h:706

◆ indexOf() [3/6]

int QString::indexOf ( const QLatin1String str,
int  from = 0,
Qt::CaseSensitivity  cs = Qt::CaseSensitive 
) const

Returns the index position of the first occurrence of the string str in this string, searching forward from index position from.

Since
4.5 Returns -1 if str is not found.

If cs is Qt::CaseSensitive (default), the search is case sensitive; otherwise the search is case insensitive.

Example:

QString x = "sticky question";
QString y = "sti";
x.indexOf(y); // returns 0
x.indexOf(y, 1); // returns 10
x.indexOf(y, 10); // returns 10
x.indexOf(y, 11); // returns -1

If from is -1, the search starts at the last character; if it is -2, at the next to last character and so on.

See also
lastIndexOf(), contains(), count()

Definition at line 2748 of file qstring.cpp.

2749 {
2750  return qt_find_latin1_string(unicode(), size(), str, from, cs);
2751 }
static int qt_find_latin1_string(const QChar *hay, int size, const QLatin1String &needle, int from, Qt::CaseSensitivity cs)
Definition: qstring.cpp:9659
int size() const
Returns the number of characters in this string.
Definition: qstring.h:102
const QChar * unicode() const
Returns a &#39;\0&#39;-terminated Unicode representation of the string.
Definition: qstring.h:706

◆ indexOf() [4/6]

int QString::indexOf ( const QStringRef s,
int  from = 0,
Qt::CaseSensitivity  cs = Qt::CaseSensitive 
) const

Definition at line 2858 of file qstring.cpp.

2859 {
2860  return qFindString(unicode(), length(), from, str.unicode(), str.length(), cs);
2861 }
int qFindString(const QChar *haystack, int haystackLen, int from, const QChar *needle, int needleLen, Qt::CaseSensitivity cs)
Definition: qstring.cpp:2753
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
const QChar * unicode() const
Returns a &#39;\0&#39;-terminated Unicode representation of the string.
Definition: qstring.h:706

◆ indexOf() [5/6]

int QString::indexOf ( const QRegExp rx,
int  from = 0 
) const

Definition at line 3342 of file qstring.cpp.

3343 {
3344  QRegExp rx2(rx);
3345  return rx2.indexIn(*this, from);
3346 }
The QRegExp class provides pattern matching using regular expressions.
Definition: qregexp.h:61

◆ indexOf() [6/6]

int QString::indexOf ( QRegExp rx,
int  from = 0 
) const

Definition at line 3366 of file qstring.cpp.

3367 {
3368  return rx.indexIn(*this, from);
3369 }
int indexIn(const QString &str, int offset=0, CaretMode caretMode=CaretAtZero) const
Attempts to find a match in str from position offset (0 by default).
Definition: qregexp.cpp:4136

◆ insert() [1/4]

QString & QString::insert ( int  i,
QChar  c 
)

Definition at line 1671 of file qstring.cpp.

Referenced by QWizardPrivate::_q_handleFieldObjectDestroyed(), QScriptDebuggerLocalsWidgetPrivate::_q_insertCompletion(), QScriptDebuggerLocalsWidgetPrivate::_q_onCompletionTaskFinished(), QScriptDebuggerConsoleWidgetPrivate::_q_onCompletionTaskFinished(), QXmlStreamPrivateTagStack::addToStringStorage(), QCss::StyleSheet::buildIndexes(), decimalForm(), QPatternist::LocalNameTest::displayName(), QPatternist::QNameTest::displayName(), exponentForm(), QTest::formatResult(), QUrl::fromPunycode(), insert(), QByteArray::insert(), QDomCharacterDataPrivate::insertData(), QAccessibleSimpleEditableTextInterface::insertText(), int2string(), QLineControl::internalInsert(), QLineControl::internalRedo(), QLineControl::internalUndo(), launchWebBrowser(), QLibraryPrivate::load_sys(), QLocalePrivate::longLongToString(), QDateTimeParser::parseSection(), QAccessibleSimpleEditableTextInterface::pasteText(), QDateTimeParser::potentialValue(), qDateTimeFromString(), qt_create_commandline(), QXmlStreamReader::readElementText(), toPunycodeHelper(), AnchorVertex::toString(), QLocalePrivate::unsLongLongToString(), and QTextEngine::validate().

1672 {
1673  if (i < 0)
1674  i += d->size;
1675  if (i < 0)
1676  return *this;
1677  expand(qMax(i, d->size));
1678  ::memmove(d->data + i + 1, d->data + i, (d->size - i) * sizeof(QChar));
1679  d->data[i] = ch.unicode();
1680  return *this;
1681 }
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
void expand(int i)
Definition: qstring.cpp:1477
Data * d
Definition: qstring.h:618
ushort * data
Definition: qstring.h:606

◆ insert() [2/4]

QString & QString::insert ( int  i,
const QChar uc,
int  len 
)

Definition at line 1638 of file qstring.cpp.

1639 {
1640  if (i < 0 || size <= 0)
1641  return *this;
1642 
1643  const ushort *s = (const ushort *)unicode;
1644  if (s >= d->data && s < d->data + d->alloc) {
1645  // Part of me - take a copy
1646  ushort *tmp = static_cast<ushort *>(qMalloc(size * sizeof(QChar)));
1647  Q_CHECK_PTR(tmp);
1648  memcpy(tmp, s, size * sizeof(QChar));
1649  insert(i, reinterpret_cast<const QChar *>(tmp), size);
1650  qFree(tmp);
1651  return *this;
1652  }
1653 
1654  expand(qMax(d->size, i) + size - 1);
1655 
1656  ::memmove(d->data + i + size, d->data + i, (d->size - i - size) * sizeof(QChar));
1657  memcpy(d->data + i, s, size * sizeof(QChar));
1658  return *this;
1659 }
Q_CORE_EXPORT void qFree(void *ptr)
Definition: qmalloc.cpp:58
Q_CORE_EXPORT void * qMalloc(size_t size)
Definition: qmalloc.cpp:53
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
QChar * data()
Returns a pointer to the data stored in the QString.
Definition: qstring.h:710
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
int size() const
Returns the number of characters in this string.
Definition: qstring.h:102
const QChar * unicode() const
Returns a &#39;\0&#39;-terminated Unicode representation of the string.
Definition: qstring.h:706
void expand(int i)
Definition: qstring.cpp:1477
Data * d
Definition: qstring.h:618
ushort * data
Definition: qstring.h:606
#define Q_CHECK_PTR(p)
Definition: qglobal.h:1853
unsigned short ushort
Definition: qglobal.h:995
QString & insert(int i, QChar c)
Definition: qstring.cpp:1671

◆ insert() [3/4]

QString & QString::insert ( int  position,
const QString str 
)
inline

Inserts the string str at the given index position and returns a reference to this string.

Example:

QString str = "Meal";
str.insert(1, QString("ontr"));
// str == "Montreal"

If the given position is greater than size(), the array is first extended using resize().

See also
append(), prepend(), replace(), remove()

Definition at line 255 of file qstring.h.

Referenced by insert().

255 { return insert(i, s.constData(), s.length()); }
QString & insert(int i, QChar c)
Definition: qstring.cpp:1671

◆ insert() [4/4]

QString & QString::insert ( int  i,
const QLatin1String s 
)

Definition at line 1616 of file qstring.cpp.

1617 {
1618  const uchar *s = (const uchar *)str.latin1();
1619  if (i < 0 || !s || !(*s))
1620  return *this;
1621 
1622  int len = qstrlen(str.latin1());
1623  expand(qMax(d->size, i) + len - 1);
1624 
1625  ::memmove(d->data + i + len, d->data + i, (d->size - i - len) * sizeof(QChar));
1626  for (int j = 0; j < len; ++j)
1627  d->data[i + j] = s[j];
1628  return *this;
1629 }
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
unsigned char uchar
Definition: qglobal.h:994
const char * latin1() const
Returns the Latin-1 string stored in this object.
Definition: qstring.h:661
void expand(int i)
Definition: qstring.cpp:1477
Data * d
Definition: qstring.h:618
ushort * data
Definition: qstring.h:606
uint qstrlen(const char *str)
Definition: qbytearray.h:79

◆ isDetached()

bool QString::isDetached ( ) const
inline
Warning
This function is not part of the public interface.

Definition at line 716 of file qstring.h.

717 { return d->ref == 1; }
QBasicAtomicInt ref
Definition: qstring.h:604
Data * d
Definition: qstring.h:618

◆ isEmpty()

bool QString::isEmpty ( ) const
inline

Returns true if the string has no characters; otherwise returns false.

Example:

QString().isEmpty(); // returns true
QString("").isEmpty(); // returns true
QString("x").isEmpty(); // returns false
QString("abc").isEmpty(); // returns false
See also
size()

Definition at line 704 of file qstring.h.

Referenced by QTextBrowserPrivate::_q_activateAnchor(), QUnixPrintWidgetPrivate::_q_btnBrowseClicked(), QTextBrowserPrivate::_q_documentModified(), QComboBoxPrivate::_q_editingFinished(), QFileDialogPrivate::_q_enterDirectory(), _q_escapeIdentifier(), QFileSystemModelPrivate::_q_fileSystemChanged(), QFileDialogPrivate::_q_goToDirectory(), QTextBrowserPrivate::_q_highlightLink(), QLabelPrivate::_q_linkHovered(), QProcessPrivate::_q_notified(), QScriptDebuggerConsoleWidgetPrivate::_q_onCompletionTaskFinished(), QScriptDebuggerPrivate::_q_onFindCodeRequest(), QPrintPreviewDialogPrivate::_q_print(), QUnixPrintWidgetPrivate::_q_printerChanged(), QPrintDialogPrivate::_q_printerOrFileSelected(), QComboBoxPrivate::_q_returnPressed(), QLineEditPrivate::_q_selectionChanged(), QFileDialogPrivate::_q_selectionChanged(), QHttpPrivate::_q_slotReadyRead(), QHttpPrivate::_q_slotSendRequest(), QScriptDebuggerCodeFinderWidgetPrivate::_q_updateButtons(), QFileDialogPrivate::_q_updateOkButton(), QFileDialogPrivate::_q_useNameFilter(), QFtpPI::abort(), QMessageBox::aboutQt(), QDir::absoluteFilePath(), QDeclarativeTypeLoader::absoluteFilePath(), QMenuPrivate::activateAction(), QDBusConnectionPrivate::activateInternalFilters(), QTextControlPrivate::activateLinkUnderCursor(), QDBusConnectionPrivate::activateObject(), QSettingsPrivate::actualKey(), QDeclarativeImportsPrivate::add(), QFontDatabasePrivate::addAppFont(), QScriptDebuggerConsoleCommandManager::addCommand(), QScriptDebuggerConsoleCommandManager::addCommandGroup(), QIcdEngine::addConfiguration(), QFileDialogPrivate::addDefaultSuffixToFiles(), QSvgIconEngine::addFile(), QIcon::addFile(), QPixmapIconEngine::addFile(), addFontToDatabase(), QDeclarativeContextData::addImportedScript(), QDeclarativeImportDatabase::addImportPath(), addKey(), QCoreApplication::addLibraryPath(), QFileSystemModelPrivate::addNode(), QFileSystemWatcher::addPath(), QFontDatabasePrivate::addQPF2File(), QHttpPrivate::addRequest(), QDir::addResourceSearchPath(), Maemo::IcdPrivate::addrinfo(), QConnmanEngine::addServiceConfiguration(), QPainterPath::addText(), allKeys(), QWindowsMime::allMimesForFormats(), QPatternist::NamePool::allocateBinding(), QPatternist::NamePool::allocateQName(), QTextControl::anchorPosition(), QCopChannel::answer(), QTextHtmlImporter::appendNodeText(), QPSQLDriverPrivate::appendTables(), QCoreApplication::applicationFilePath(), QTextHtmlParser::applyAttributes(), QTextHtmlParserNode::applyBackgroundImage(), QTextHtmlParserNode::applyCssDeclarations(), QUnixPrintWidgetPrivate::applyPrinterProperties(), QApplicationPrivate::appName(), QDeclarativeParser::Variant::asScript(), QSvgStyleSelector::attribute(), QAccessibleTextWidget::attributes(), QNetworkAccessManagerPrivate::authenticationRequired(), QUrlPrivate::authority(), QAuthDevice::authorizeMessage(), QTransportAuth::authorizeRequest(), QCss::StyleSelector::basicSelectorMatches(), QSettingsPrivate::beginGroupOrArray(), bestStyle(), QFontDatabase::bold(), QPainter::boundingRect(), QSvgGradientStyle::brush(), QDeclarativeCompiler::buildDynamicMeta(), QCss::StyleSheet::buildIndexes(), buildMatchRule(), QDeclarativeCompiler::buildSignal(), QNetworkManagerEngine::bytesReceived(), QNetworkManagerEngine::bytesWritten(), QNetworkAccessAuthenticationManager::cacheCredentials(), QNetworkAccessAuthenticationManager::cacheProxyCredentials(), QMenuBarPrivate::calcActionRects(), QAuthenticatorPrivate::calculateResponse(), QWindowsMimeURI::canConvertFromMime(), QWindowsMimeHtml::canConvertFromMime(), QTextControl::canInsertFromMimeData(), QDBusAbstractInterfacePrivate::canMakeCalls(), QUrlPrivate::canonicalHost(), QDir::cd(), QDomHandler::characters(), QDBusUtil::checkBusName(), QPatternist::XsdSchemaChecker::checkComplexTypeConstraints(), QDBusUtil::checkErrorName(), checkHRESULT(), checkIfValid(), QDBusUtil::checkInterfaceName(), QDBusUtil::checkMemberName(), QAbstractItemViewPrivate::checkMouseMove(), QDBusUtil::checkObjectPath(), QScript::SyntaxChecker::checkSyntax(), QDeclarativeCompiler::checkValidId(), childKeysOrGroups(), QConfFileSettingsPrivate::children(), classIDL(), QDir::cleanPath(), QBenchmarkValgrindUtils::cleanup(), clipboardData(), QPdfBaseEnginePrivate::closePrintDevice(), QPatternist::ColorOutput::colorify(), comify(), QDeclarativeCompiler::compile(), QGLShaderPrivate::compile(), QDeclarativeCompiler::compileTree(), QLineControl::complete(), QDeclarativeFolderListModel::componentComplete(), QTransformedScreen::connect(), QDirectFBScreen::connect(), QDBusConnection::connect(), QDBusConnection::connectToBus(), QCoreWlanEngine::connectToId(), QNativeWifiEngine::connectToId(), QDBusConnection::connectToPeer(), QLocalSocket::connectToServer(), constructWindowTitleFromFilePath(), QScriptDebuggerConsole::consumeInput(), QHttpHeader::contentType(), QWindowsMimeURI::convertFromMime(), QMacPasteboardMimeFileUri::convertFromMime(), QMacPasteboardMimeUrl::convertFromMime(), QScriptEnginePrivate::convertValue(), QLineControl::copy(), QPlatformIntegrationFactory::create(), QNetworkAccessFileBackendFactory::create(), QPatternist::AbstractDuration::create(), QPatternist::AbstractDateTime::create(), QSettingsPrivate::create(), QDeclarativeEnginePrivate::createComponent(), QSqlRecordPrivate::createField(), QSqlIndex::createField(), createFontNode(), QScriptDebuggerConsolePrivate::createJob(), createLinearGradientNode(), QDBusMetaObject::createMetaObject(), createPixmapDataSync(), QDeclarativeEnginePrivate::createQmlObject(), createRadialGradientNode(), createRectNode(), QUndoGroup::createRedoAction(), QUndoStack::createRedoAction(), QLabelPrivate::createStandardContextMenu(), QLineEdit::createStandardContextMenu(), createSvgNode(), QUndoGroup::createUndoAction(), QUndoStack::createUndoAction(), createUseNode(), QMessageBox::critical(), QAbstractFileEngineIterator::currentFilePath(), QNetworkSessionPrivateImpl::currentInterface(), QScriptDebuggerStackModel::data(), QPSQLResult::data(), QScriptDebuggerScriptsModel::data(), QScriptBreakpointsModel::data(), QScriptDebuggerPrivate::debuggerEvent(), QCss::StyleSelector::declarationsForNode(), decodeMSG(), QPatternist::CompressedWhitespace::decompress(), QSqlTableModel::deleteRowFromTable(), QCommandLinkButtonPrivate::descriptionHeight(), QWidget::destroy(), QLocalSocketPrivate::destroyPipeHandles(), QDeclarativeTextPrivate::determineHorizontalAlignment(), QDeclarativeTextEditPrivate::determineHorizontalAlignment(), QDeclarativeTextInputPrivate::determineHorizontalAlignment(), determineScreenSize(), QDBusConnection::disconnect(), QPatternist::NamePool::displayName(), dlIterateCallback(), do_dbus_call(), QScriptDebuggerBackend::doPendingEvaluate(), QGenericEngine::doRequestUpdate(), QIcdEngine::doRequestUpdate(), QDragManager::drag(), QSvgText::draw(), QTextDocumentLayoutPrivate::drawBlock(), QCommonStyle::drawControl(), QWindowsCEStyle::drawControl(), QWindowsVistaStyle::drawControl(), QPlastiqueStyle::drawControl(), QCleanlooksStyle::drawControl(), QWindowsXPStyle::drawControl(), QWindowsStyle::drawControl(), QGtkStyle::drawControl(), QMacStyle::drawControl(), QStyleSheetStyle::drawControl(), QItemDelegate::drawDisplay(), QWindowsCEStyle::drawItemText(), QCleanlooksStyle::drawItemText(), QStyle::drawItemText(), QWindowsVistaStyle::drawPrimitive(), QPainter::drawStaticText(), QPainter::drawText(), QGridLayoutRowInfo::dump(), QGridLayoutEngine::dump(), QDeclarativeCompiledData::dumpInstructions(), QAxBase::dynamicCallHelper(), elliditide(), QTextHtmlExporter::emitBackgroundAttribute(), QTextHtmlExporter::emitCharFormatStyle(), QTextHtmlExporter::emitFragment(), QPSPrintEnginePrivate::emitHeader(), QTextHtmlExporter::emitTable(), QClipboardWatcher::empty(), QStringRef::endsWith(), QIconLoader::ensureInitialized(), err_info_about_objects(), QRegExpEngine::error(), QPluginLoader::errorString(), QLibrary::errorString(), QImageReader::errorString(), QDB2Driver::escapeIdentifier(), QIBaseDriver::escapeIdentifier(), QOCIDriver::escapeIdentifier(), QSQLite2Driver::escapeIdentifier(), QTDSDriver::escapeIdentifier(), QMYSQLDriver::escapeIdentifier(), QPSQLDriver::escapeIdentifier(), QODBCDriver::escapeIdentifier(), QPatternist::QNameFN::evaluateSingleton(), QPatternist::StringJoinFN::evaluateSingleton(), QPatternist::PrefixFromQNameFN::evaluateSingleton(), QScriptDebuggerCodeView::event(), QTabBar::event(), QAxServerBase::eventFilter(), QFontDef::exactMatch(), QScriptDebuggerBackendPrivate::exception(), QDeclarativeExpressionPrivate::exceptionToError(), QSqlTableModelPrivate::exec(), QSqlQuery::exec(), QPSQLResult::exec(), QSqlDatabase::exec(), QDeclarativeStateChangeScript::execute(), QDeclarativeScriptActionPrivate::execute(), QDir::exists(), QPatternist::QNameConstructor::expandQName(), QScreen::exposeRegion(), QZipReader::extractAll(), QFontDatabase::families(), familyList(), fbname(), QNetworkAccessAuthenticationManager::fetchCachedCredentials(), QNetworkAccessAuthenticationManager::fetchCachedProxyCredentials(), QDir::filePath(), QHttpNetworkConnectionPrivate::fillPipeline(), QDeclarativeImportedNamespace::find_helper(), find_translation(), QDateTimeParser::findAmPm(), QScriptDebuggerPrivate::findCode(), QLibraryInfoPrivate::findConfiguration(), QDateTimeParser::findDay(), findEncoding(), QFontDatabase::findFont(), findGraphicsFactory(), findGroupFactory(), QSystemTrayIconSys::findIconGeometry(), QIconLoader::findIconHelper(), QDBusConnectionPrivate::findMetaObject(), QDateTimeParser::findMonth(), QXmlStreamWriterPrivate::findNamespace(), QResourceRoot::findNode(), findStyleFactoryMethod(), findStyleUtilFactoryMethod(), QSystemTrayIconSys::findTrayGeometry(), findUtilFactory(), QDomNode::firstChildElement(), fixedXmlName(), QTextStreamPrivate::flushWriteBuffer(), fmtDateTime(), QFontDatabase::font(), QPlatformFontDatabase::fontDir(), QTest::formatResult(), QMacPasteboard::formats(), QWindowsMimeHtml::formatsForMime(), QPatternist::NamePool::fromClarkName(), QPatternist::Numeric::fromLexical(), QPatternist::XsdTypeChecker::fromLexical(), QHostInfoAgent::fromName(), QSslCertificate::fromPath(), QXmlInputSource::fromRawData(), QDate::fromString(), QTime::fromString(), QFont::fromString(), QDateTime::fromString(), QUrl::fromUserInput(), QDeclarativeCompiler::genComponent(), QDeclarativeStatePrivate::generateActionList(), generateSubObjectXml(), QDeclarativeCompiler::genObject(), QDeclarativeTypeLoader::get(), QWindowsAccessible::get_accDefaultAction(), QTextStreamPrivate::getChar(), GetClassObject(), QColorDialog::getColor(), QAxServerBase::GetCurFile(), QSslSocketBackendPrivate::getErrorsFromOpenSsl(), getFamiliesAndSignatures(), getFcPattern(), QFileInfoGatherer::getFileInfos(), getFmtString(), QFontDialogPrivate::getFont(), getIBaseError(), getImage(), QFileInfoGatherer::getInfo(), QFileSystemEngine::getLinkTarget(), QSystemLocalePrivate::getLocaleInfo_qchar(), getNetworkAttrs(), QBenchmarkValgrindUtils::getNewestFileName(), QFileDialog::getOpenFileName(), QFileDialog::getOpenFileNames(), getPath(), getPixmap(), QDeclarativeTypeLoader::getQmldir(), QFileDialog::getSaveFileName(), QDeclarativeTypeLoader::getScript(), QGtkStylePrivate::getThemeFont(), QGtkStylePrivate::getThemeName(), QScanThread::getUserConfigurations(), QNetworkManagerSettingsConnection::getUuid(), QDeclarativeXmlQueryEngine::getValuesOfKeyRoles(), QFileIconProviderPrivate::getWinIcon(), getWinLocaleName(), QSystemSemaphorePrivate::handle(), QSharedMemoryPrivate::handle(), QDBusConnectionPrivate::handleSignal(), handleStringAttribute(), QSvgStyleSelector::hasAttributes(), QDomImplementation::hasFeature(), QMacPasteboard::hasFormat(), QGraphicsScene::helpEvent(), QScriptSyntaxHighlighter::highlightBlock(), QScriptSyntaxHighlighter::highlightWord(), QTextDocumentLayout::hitTest(), QFileSystemEngine::homePath(), QNetworkInterface::humanReadableName(), QIcdEngine::icdServiceOwnerChanged(), QGuiPlatformPlugin::iconThemeSearchPaths(), QTextHtmlImporter::import(), QDeclarativeImportsPrivate::importExtension(), QScriptEngine::importExtension(), QTextHtmlParser::importStyleSheet(), QDeclarativeInclude::include(), QDirModel::index(), QMoviePrivate::infoForFrame(), QObject::inherits(), QTextEditPrivate::init(), QFontDialogPrivate::init(), QPlainTextEditPrivate::init(), QFileDialogPrivate::init(), QMessageBoxPrivate::init(), QWindowsSystemProxy::init(), QSQLiteResultPrivate::initColumns(), QGtkStylePrivate::initGtkWidgets(), QAxScriptEngine::initialize(), QSocks5SocketEnginePrivate::initialize(), QTextHtmlParserNode::initializeProperties(), QAxBase::initializeRemote(), QFileDialogPrivate::initialSelection(), QSslSocketBackendPrivate::initSslContext(), QTextControlPrivate::inputMethodEvent(), QLineEdit::inputMethodEvent(), QComboBox::inputMethodEvent(), QAbstractItemView::inputMethodEvent(), QTextCursor::insertImage(), QFormLayout::insertRow(), QSqlTableModel::insertRowIntoTable(), QTextCursor::insertText(), QPatternist::XSLTTokenizer::insideTemplate(), QDeclarativeDebugServer::instance(), QLineControl::internalSetText(), QFileSystemEntry::isAbsolute(), QFontDatabase::isBitmapScalable(), isBypassed(), isc(), QWinInputContext::isComposing(), isDirPath(), Text::isElementContentWhitespace(), QFileSystemEntry::isEmpty(), QUrl::isEmpty(), isHostExcluded(), Maemo::ProxyConfPrivate::isHostExcluded(), QLibrary::isLibrary(), QPixmapIconEngineEntry::isNull(), QUrl::isParentOf(), QLibraryPrivate::isPlugin(), QFileSystemEntry::isRelative(), QUrl::isRelative(), QTextEngine::isRightToLeft(), QDateTimeEditPrivate::isSeparatorKey(), isServerProcess(), QDBusConnectionPrivate::isServiceRegisteredByThread(), QFontDatabase::isSmoothlyScalable(), isUncRoot(), QAudioFormat::isValid(), QTgaFile::isValid(), QNetworkInterface::isValid(), QDBusUtil::isValidBusName(), QColor::isValidColor(), QDBusUtil::isValidInterfaceName(), QDBusUtil::isValidMemberName(), QPatternist::DerivedString< TypeToken >::isValidName(), QDBusUtil::isValidPartOfObjectPath(), QDBusUtil::isValidUniqueConnectionName(), QFontDatabase::italic(), QStyle::itemTextRect(), QKde::kdeHome(), QTreeView::keyboardSearch(), QAbstractItemView::keyboardSearch(), QTextBrowser::keyPressEvent(), QTextControlPrivate::keyPressEvent(), QMenuBar::keyPressEvent(), QAbstractSpinBox::keyPressEvent(), QDateTimeEdit::keyPressEvent(), QLineEdit::keyPressEvent(), QPlainTextEdit::keyPressEvent(), QComboBox::keyPressEvent(), QTextEdit::keyPressEvent(), QAbstractItemView::keyPressEvent(), QPlatformIntegrationFactory::keys(), QDomNode::lastChildElement(), QStringList::lastIndexOf(), launchWebBrowser(), QWizardPrivate::layoutInfoForCurrentPage(), QCoreApplication::libraryPaths(), QGLShaderProgram::link(), QFtp::list(), QLocalServer::listen(), QPluginLoader::load(), QTranslator::load(), QLibraryPrivate::load(), QDeclarativeBorderImage::load(), QDeclarativeAnimatedImage::load(), QAxScript::load(), QPixmap::load(), QFontDatabase::load(), QDeclarativeDataLoader::load(), QAxScriptManager::load(), QImage::load(), QAxServerBase::Load(), QLibraryPrivate::load_sys(), QSvgIconEnginePrivate::loadDataForModeAndState(), loadEngine(), QTextDocument::loadResource(), loadSingleEngine(), QFontDatabase::loadXlfd(), QHostInfo::localDomainName(), FAREnforcer::logAuthAttempt(), longestCommonPrefix(), QFSFileEnginePrivate::longFileName(), QLocalePrivate::longLongToString(), QHostInfo::lookupHost(), lsOpen(), macFormatCurrency(), macQuoteString(), makeCacheKey(), QSharedMemoryPrivate::makePlatformSafeKey(), QResourceRoot::mappingRootSubdir(), QAbstractItemModel::match(), QDirIteratorPrivate::matchesFilters(), QCompletionEngine::matchHint(), QUrlPrivate::mergePaths(), QScriptDebugOutputWidget::message(), QScriptDebuggerConsoleWidget::message(), QScriptStdMessageHandler::message(), MetaObjectGenerator::metaObject(), Qt::mightBeRichText(), QLastResortMimes::mimeForFormat(), QXlibMime::mimeStringToAtom(), QDir::mkdir(), QDir::mkpath(), QWhatsThat::mouseMoveEvent(), QTextControlPrivate::mouseReleaseEvent(), QWhatsThat::mouseReleaseEvent(), QFileSystemEngine::nativeAbsoluteFilePath(), QNetworkManagerEngine::newAccessPoint(), QTextHtmlParser::newNode(), QErrorMessagePrivate::nextPending(), QDomNode::nextSiblingElement(), QPatternist::XQueryTokenizer::nextToken(), QFileSystemModelPrivate::node(), QUrlPrivate::normalized(), QSettingsPrivate::normalizedKey(), QDBusConnection::objectRegisteredAt(), QDeclarativeDebugService::objectToString(), QDBusXmlParser::objectTree(), QNetworkAccessFileBackend::open(), QNetworkAccessFtpBackend::open(), QIBaseDriver::open(), QSQLite2Driver::open(), QSQLiteDriver::open(), QOCIDriver::open(), QDB2Driver::open(), QMYSQLDriver::open(), QPSQLDriver::open(), QODBCDriver::open(), QWSPcMouseHandlerPrivate::openDevices(), openDocument(), QWSServer::openKeyboard(), QWSServer::openMouse(), QPdfBaseEnginePrivate::openPrintDevice(), QLinuxFbIntegrationPrivate::openTty(), QLinuxFbScreenPrivate::openTty(), PvrEglScreen::openTty(), QFontDef::operator<(), operator<<(), QUrl::operator=(), QProcessPrivate::Channel::operator=(), QFontDef::operator==(), QDBusIntrospection::Interface::operator==(), operator==(), operator>(), QProcessEnvironmentPrivate::OrderedMutexLocker::OrderedMutexLocker(), QTest::outputMessage(), QPlainTextEdit::paintEvent(), QNSOpenSavePanelDelegate::panel:shouldShowFilename:, QScriptXmlParser::parse(), QDeclarativeDirParser::parse(), QScriptParser::parse(), QXmlStreamReaderPrivate::parse(), QRegExpEngine::parse(), parseAnimateColorNode(), parseAnimateTransformNode(), QPatternist::XsdSchemaParser::parseAny(), QPatternist::XsdSchemaParser::parseAnyAttribute(), QPatternist::XsdSchemaParser::parseAppInfo(), parseBaseGradient(), parseCombinedArgString(), parseCompOp(), QNetworkManagerEngine::parseConnection(), parseCSStoXMLAttrs(), parseDateString(), QPatternist::XsdSchemaParser::parseDocumentation(), QXmlStreamReaderPrivate::parseEntity(), QPatternist::PatternPlatform::parseFlags(), parseFontFaceNameNode(), parseFontFaceNode(), QDateTimeParser::parseFormat(), parseHeaderValue(), QAuthenticatorPrivate::parseHttpResponse(), QPatternist::XsdSchemaParser::parseImport(), QLineControl::parseInputMask(), parseIp6(), QPatternist::XsdSchemaParser::parseNotation(), parseOthers(), QXmlSimpleReaderPrivate::parseProlog(), QSocks5SocketEnginePrivate::parseRequestMethodReply(), parseServerList(), QNetworkCookiePrivate::parseSetCookieHeaderLine(), QHostAddress::parseSubnet(), QPatternist::AbstractDateTime::parseZoneOffset(), QDeclarativePackage::part(), QLineControl::paste(), QFSCompleter::pathFromIndex(), QStringMatcher::pattern(), QProcessPrivate::pipeWriterBytesToWrite(), QFontDatabase::pointSizes(), populate_database(), QScriptDebuggerAgent::positionChange(), QKeyMapper::possibleKeys(), QDateTimeParser::potentialValue(), QXmlNamespaceSupport::prefix(), QXmlNamespaceSupport::prefixes(), QOCIResult::prepare(), QPSQLResult::prepare(), QSqlQuery::prepare(), QDomNode::previousSiblingElement(), QOCIDriver::primaryIndex(), QSQLite2Driver::primaryIndex(), QTDSDriver::primaryIndex(), QPSQLDriver::primaryIndex(), QApplicationPrivate::process_cmdline(), QLineControl::processInputMethodEvent(), QPatternist::XSLTSimpleContentConstructor::processItem(), QDeclarativePixmapReader::processJob(), QLineControl::processKeyEvent(), QTextHtmlImporter::processSpecialNodes(), propertyNotFoundError(), propertyWriteReply(), proxyAuthenticationKey(), QMacStylePrivate::pushButtonSizeFromContents(), Q_GLOBAL_STATIC_WITH_ARGS(), qAppendWhereClause(), qAppFileName(), QAudioDeviceInfoInternal::QAudioDeviceInfoInternal(), qax_docuFromName(), qax_generateDocumentation(), QAxScriptEngine::QAxScriptEngine(), QConfFileSettingsPrivate::QConfFileSettingsPrivate(), qDateFromString(), qDateTimeFromString(), QDBusAbstractInterface::QDBusAbstractInterface(), QDBusAbstractInterfacePrivate::QDBusAbstractInterfacePrivate(), QDBusConnection::QDBusConnection(), qDBusGenerateMetaObjectXml(), qDBusIntrospectObject(), QDBusServer::QDBusServer(), QDeclarativeGridScaledImage::QDeclarativeGridScaledImage(), qDecodeDataUrl(), QDirPrivate::QDirPrivate(), qExtractSecurityPolicyFromString(), QGraphicsTextItem::QGraphicsTextItem(), QHttpHeader::QHttpHeader(), qInit(), QMacSettingsPrivate::QMacSettingsPrivate(), qmlsqldatabase_open_sync(), QMultiInputContext::QMultiInputContext(), QNetworkReplyFileImpl::QNetworkReplyFileImpl(), QNetworkSession::QNetworkSession(), qNtlmPhase3(), QQnxMouseHandler::QQnxMouseHandler(), QRenderRule::QRenderRule(), QScriptDebuggerBackendPrivate::qsassert(), QTest::qSignalDumperCallback(), QTest::qSignalDumperCallbackSlot(), qt_accAmpIndex(), qt_ACE_do(), qt_addPatternProps(), qt_create_commandline(), qt_error_string(), qt_fillFontDef(), qt_format_text(), qt_get_screen(), qt_getLprPrinters(), qt_guiPlatformPlugin(), qt_init(), qt_keyrelease_scanner(), QApplicationPrivate::qt_mac_apply_settings(), qt_mac_extract_filter(), QFileDialogPrivate::qt_mac_filedialog_event_proc(), qt_mac_make_filters_list(), qt_make_filter_list(), qt_parsePrintcap(), qt_parseSpoolInterface(), qt_perhapsAddPrinter(), qt_resource_fixResourceRoot(), qt_set_x11_resources(), qt_setWindowTitle_helperHelper(), qt_splitLocaleName(), qt_win_filter(), qt_win_get_existing_directory(), qt_win_get_open_file_name(), qt_win_get_open_file_names(), qt_win_get_save_file_name(), qt_win_make_filters_list(), qt_win_make_OFN(), qt_x11_set_fallback_font_family(), qTimeFromString(), QToolButton::QToolButton(), QtWndProc(), QWin32PrintEnginePrivate::queryDefault(), QPatternist::XSLTTokenizer::queueTextConstructor(), QUrl::QUrl(), QVFbKeyboardHandler::QVFbKeyboardHandler(), QVFbMouseHandler::QVFbMouseHandler(), qWarnODBCHandle(), QWinSettingsPrivate::QWinSettingsPrivate(), qws_dataDir(), qwsFontPath(), QWSKbPrivate::QWSKbPrivate(), QWSLinuxTPMouseHandlerPrivate::QWSLinuxTPMouseHandlerPrivate(), QWSQnxKeyboardHandler::QWSQnxKeyboardHandler(), QXmlName::QXmlName(), QWSCalibratedMouseHandler::readCalibration(), MetaObjectGenerator::readClassInfo(), QInotifyFileSystemWatcherEngine::readFromInotify(), QWinSettingsPrivate::readKey(), QPatternist::XsdSchemaParser::readNamespaceAttribute(), QPngHandlerPrivate::readPngTexts(), QPatternist::XsdSchemaParser::readXPathAttribute(), QPatternist::XsdSchemaParser::readXPathExpression(), QFtpPI::readyRead(), QSocks5SocketEnginePrivate::reauthenticate(), QDB2Driver::record(), QOCIDriver::record(), QPSQLDriver::record(), QAxScriptManager::registerEngine(), registerFont(), QDBusConnection::registerObject(), QPlatformFontDatabase::registerQPF2Font(), QResource::registerResource(), QAccessibleGroupBox::relationTo(), QDir::relativeFilePath(), QSettings::remove(), QDir::remove(), QWinSettingsPrivate::remove(), QSidebar::removeEntry(), QNetworkDiskCachePrivate::removeFile(), QCoreApplication::removeLibraryPath(), QFileSystemWatcher::removePath(), QInotifyFileSystemWatcherEngine::removePaths(), QKqueueFileSystemWatcherEngine::removePaths(), QDir::rename(), replace(), QDeclarativeXMLHttpRequest::requestFromUrl(), QMacInputContext::reset(), QUrl::resolved(), QFileSystemEntry::resolveFilePath(), resolveGdi32(), QFileSystemEntry::resolveNativeFilePath(), resolveScheme(), QTextBrowserPrivate::resolveUrl(), QDockAreaLayoutInfo::restoreState(), QFileSystemModelPrivate::QFileSystemNode::retranslateStrings(), QMacPasteboard::retrieveData(), QXlibClipboardMime::retrieveData_sys(), QPatternist::AccelTreeResourceLoader::retrieveUnparsedText(), QDir::rmdir(), QDir::rmpath(), QKqueueFileSystemWatcherEngine::run(), QFileInfoGatherer::run(), QDomDocumentTypePrivate::save(), QAxServerBase::Save(), QDomElementPrivate::save(), QDomDocumentPrivate::saveDocument(), QDockAreaLayoutInfo::saveState(), QToolBarAreaLayout::saveState(), Maemo::IcdPrivate::scan(), QAxScriptManager::scriptFileFilter(), QScriptDebuggerAgent::scriptLoad(), QScriptDebuggerAgent::scriptUnload(), QTextEdit::scrollToAnchor(), section(), QDeclarativeViewSection::sectionString(), QSqlTableModel::select(), QFileDialog::selectFile(), QSqlRelationalTableModel::selectStatement(), QSqlTableModel::selectStatement(), QDBusConnectionPrivate::sendError(), QWSServer::sendIMEvent(), QCopChannel::sendLocally(), QLineEditPrivate::sendMouseEventToInputContext(), QTextControlPrivate::sendMouseEventToInputContext(), QHttpNetworkConnectionChannel::sendRequest(), QSocks5SocketEnginePrivate::sendRequestMethod(), QXlibClipboard::sendSelection(), set_text(), QCoreApplication::setApplicationName(), QUrlPrivate::setAuthority(), QScriptDebuggerAgent::setBreakpoint(), QNetworkDiskCache::setCacheDirectory(), QColor::setColorFromString(), QTextControlPrivate::setContent(), QAxBase::setControl(), QNetworkCookieJar::setCookiesFromUrl(), QLineEditPrivate::setCursorVisible(), QScriptDebuggerLocalsModel::setData(), QFileSystemModel::setData(), QMessageBox::setDetailedText(), QFileDialog::setDirectory(), QSocks5SocketEnginePrivate::setErrorState(), QPluginLoader::setFileName(), QLibrary::setFileName(), QTextControl::setFocusToAnchor(), QDeclarativeFolderListModel::setFolder(), setFontFamilyFromValues(), QMessageBox::setInformativeText(), QMdiSubWindowPrivate::setNewWindowTitle(), QPrinter::setOutputFileName(), QWidgetPrivate::setParent_sys(), QTextLayout::setPreeditArea(), QUndoAction::setPrefixedText(), QPrintDialogPrivate::setPrinter(), QPrinter::setPrinterName(), QWin32PrintEngine::setProperty(), QHttpSocketEngine::setProxy(), QAbstractSpinBoxPrivate::setRange(), QFileSystemModel::setRootPath(), QDeclarativeFontLoader::setSource(), QTextBrowserPrivate::setSource(), QApplication::setStyleSheet(), QWidget::setStyleSheet(), QAccessibleAbstractScrollArea::setText(), QImageWriter::setText(), QAction::setText(), QGtkStylePrivate::setupGtkFileChooser(), QUrlModel::setUrl(), setWidthAttribute(), QWidgetPrivate::setWindowIconText_sys(), QWidget::setWindowTitle(), QWidgetPrivate::setWindowTitle_sys(), shouldWatchService(), QBalloonTip::showBalloon(), QSystemTrayIconPrivate::showMessage_sys(), QMessageBoxPrivate::showOldMessageBox(), QToolTip::showText(), QTextControlPrivate::showToolTip(), QPushButton::sizeHint(), QHttpSocketEngine::slotSocketReadNotification(), QFileSystemEngine::slowCanonicalized(), QFontDatabase::smoothSizes(), QFtpDTP::socketReadyRead(), QAbstractSpinBoxPrivate::specialValue(), QCss::Selector::specificity(), QFSCompleter::splitPath(), QCompleter::splitPath(), QSqlDriver::sqlStatement(), QLocale::standaloneDayName(), QLocale::standaloneMonthName(), QCommonStyle::standardIconImplementation(), QStyleSheetStyle::standardIconImplementation(), QStyleSheetStyle::standardPixmap(), QScriptCompletionTask::start(), QThreadPrivate::start(), QHttpSetProxyRequest::start(), QProcessPrivate::startDetached(), QSslSocketBackendPrivate::startHandshake(), QProcessPrivate::startProcess(), QStringRef::startsWith(), Maemo::IcdPrivate::state(), QNetworkSessionPrivateImpl::stateChange(), Maemo::IcdPrivate::statistics(), QApplication::style(), QtFontFoundry::style(), QStyleSheetStyle::styleHint(), QFontDatabase::styles(), QFontDatabase::styleString(), styleStringHelper(), supportsAttribute(), QMenuPrivate::QMacMenuPrivate::syncAction(), QNetworkSessionPrivateImpl::syncStateWithInterface(), QGuiPlatformPlugin::systemIconThemeName(), QNetworkProxyFactory::systemProxyForQuery(), QDB2Driver::tables(), QIBaseDriver::tables(), QSQLiteDriver::tables(), tabTextFor(), QFileSystemEngine::tempPath(), QAccessibleButton::text(), QAccessibleWidget::text(), QClipboard::text(), QAccessibleMenuBar::text(), QAccessibleToolButton::text(), QAccessibleHeader::text(), QAccessibleDisplay::text(), QAccessibleGroupBox::text(), QAccessibleLineEdit::text(), QAccessibleTable2Cell::text(), QAccessibleTabBar::text(), QAccessibleTable2HeaderCell::text(), QImage::text(), QAccessibleComboBox::text(), QAccessibleItemRow::text_helper(), QIconLoader::themeName(), QCoreFuriCuri::timerEvent(), QMdiSubWindowPrivate::titleBarOptions(), QmlJSDebugger::AbstractLiveEditTool::titleForItem(), QCommandLinkButtonPrivate::titleRect(), QScript::ToBool(), QPatternist::NamePool::toClarkName(), QSystemLocalePrivate::toCurrencyString(), QLocale::toCurrencyString(), QDBusMessagePrivate::toDBusMessage(), QUrlPrivate::toEncoded(), QTextHtmlExporter::toHtml(), tokenUntil(), QUrl::toLocalFile(), QNetworkCookie::toRawForm(), QScriptContext::toString(), QHostAddress::toString(), QDeclarativeObjectScriptClass::tostring(), QUrl::toString(), QDateTime::toString(), QCoreApplication::translate(), QETWidget::translateConfigEvent(), QKeyMapperPrivate::translateKeyEvent(), QETWidget::translateKeyEvent(), QXlibKeyboard::translateKeySym(), QXcbKeyboard::translateKeySym(), translateKeySym(), translateWSAError(), MetaObjectGenerator::tryCache(), QFileIconProvider::type(), QSystemLocalePrivate::uiLanguages(), unquote(), QLocalePrivate::unsLongLongToString(), unstylable(), QDeclarativeStateGroupPrivate::updateAutoState(), QGraphicsSvgItemPrivate::updateDefaultSize(), QAbstractSpinBoxPrivate::updateEdit(), QFileSystemModelPrivate::QFileSystemNode::updateIcon(), ShaderEffectItem::updateProperties(), UpdateRegistry(), QSqlTableModel::updateRowInTable(), ShaderEffectItem::updateShaderProgram(), QIconLoader::updateSystemTheme(), QUnixPrintWidgetPrivate::updateWidget(), QMdiSubWindowPrivate::updateWindowTitle(), QHttpNetworkRequestPrivate::uri(), QDeclarativeEnginePrivate::urlToLocalFileOrQrc(), QUrlPrivate::userInfo(), QSpinBoxValidator::validate(), QUrlPrivate::validate(), QSpinBoxPrivate::validateAndInterpret(), QDateTimeEditPrivate::validateAndInterpret(), QDoubleSpinBoxPrivate::validateAndInterpret(), QPatternist::XsdValidatingInstanceReader::validateElementComplexType(), QPatternist::XsdValidatingInstanceReader::validateElementSimpleType(), QAxFactory::validateLicenseKey(), QDeclarativeEngineDebugService::valueContents(), QDeclarativeStringConverters::variantFromString(), QAxBase::verbs(), QHeaderView::viewportEvent(), QMYSQLResult::virtual_hook(), QFontDatabase::weight(), QAbstractXmlReceiver::whitespaceOnly(), QPatternist::AccelTreeBuilder< true >::whitespaceOnly(), QPatternist::QAbstractXmlReceiver::whitespaceOnly(), windowsConfigPath(), windowsErrorString(), winGetExistDirCallbackProc(), winIso639LangName(), QDeclarativeInclude::worker_include(), QFileDialogPrivate::workingDirectory(), QDBusMetaObjectGenerator::write(), QSvgIconEngine::write(), QImageWriter::write(), QWSCalibratedMouseHandler::writeCalibration(), QXmlSerializer::writeEscaped(), QXmlSerializer::writeEscapedAttribute(), QXmlStreamWriter::writeNamespace(), QApplicationPrivate::x11_apply_settings(), QXIMInputContext::x11FilterEvent(), QX11Data::xdndMimeStringToAtom(), xic_draw_callback(), and QDeclarativeInfo::~QDeclarativeInfo().

705 { return d->size == 0; }
Data * d
Definition: qstring.h:618

◆ isNull()

bool QString::isNull ( ) const
inline

Returns true if this string is null; otherwise returns false.

Example:

QString().isNull(); // returns true
QString("").isNull(); // returns false
QString("abc").isNull(); // returns false

Qt makes a distinction between null strings and empty strings for historical reasons. For most applications, what matters is whether or not a string contains any data, and this can be determined using the isEmpty() function.

See also
isEmpty()

Definition at line 505 of file qstring.h.

Referenced by QHttpPrivate::_q_slotSendRequest(), QCoreApplication::applicationDirPath(), QCoreApplication::applicationFilePath(), QPatternist::XQueryTokenizer::attributeAsRaw(), QCss::StyleSelector::basicSelectorMatches(), buildMatchRule(), QWizard::buttonText(), QNetworkAccessAuthenticationManager::cacheProxyCredentials(), QUrlPrivate::canonicalHost(), clear(), QDBusConnectionPrivate::connectSignal(), QSvgIconPlugin::create(), QDomImplementation::createDocumentType(), createUseNode(), QAbstractFileEngineIterator::currentFilePath(), QDBusConnectionPrivate::disconnectSignal(), QTranslatorPrivate::do_translate(), QMotifStyle::drawControl(), QLineEdit::dropEvent(), endsWith(), QStringRef::endsWith(), QPatternist::ReplaceFN::evaluateSingleton(), find_translation(), QSystemTrayIconSys::findTrayGeometry(), QMacPasteboardMime::flavorToMime(), fontExists(), QtFontFamily::foundry(), QUrlPrivate::fragmentImpl(), QWindowsAccessible::get_accValue(), QDBusConnectionPrivate::handleSignal(), QFtpDTP::hasError(), QTextControl::insertFromMimeData(), QComboBox::insertItem(), QPatternist::XSLTTokenizer::insideFunction(), QAxServerBase::Invoke(), QNetworkAuthenticationCredential::isNull(), QStringRef::isNull(), QTranslator::load(), QLibraryInfo::location(), QFtp::login(), QDomNamedNodeMapPrivate::namedItemNS(), QPatternist::XQueryTokenizer::nextToken(), QDBusXmlParser::object(), QMYSQLDriver::open(), QPatternist::AccelTreeResourceLoader::openUnparsedText(), operator!=(), QDirSortItemComparator::operator()(), operator<<(), operator==(), QDeclarativeDirParser::parse(), QXmlStreamReaderPrivate::parse(), QXmlSimpleReaderPrivate::parseBeginOrContinue(), QXmlSimpleReaderPrivate::parseFailed(), QUrl::path(), populate_database(), QDBusConnectionPrivate::prepareHook(), QTextHtmlImporter::processSpecialNodes(), qCreateParamString(), QDomAttrPrivate::QDomAttrPrivate(), QDomElementPrivate::QDomElementPrivate(), qDrawPlainRect(), StringSplitter::qIsForwardIteratorEnd(), qIsForwardIteratorEnd(), qmlxmlhttprequest_open(), QRuntimeGraphicsSystem::QRuntimeGraphicsSystem(), qt_aqua_get_known_size(), qt_get_screen(), qt_init(), QApplicationPrivate::qt_mac_apply_settings(), qt_mac_display_change_callbk(), qt_qFindChild_helper(), qt_qFindChildren_helper(), QTextLayout::QTextLayout(), QWSTslibMouseHandlerPrivate::QWSTslibMouseHandlerPrivate(), QXmlStreamReaderPrivate::raiseError(), QXmlSimpleReaderPrivate::reportParseError(), QDomDocumentTypePrivate::save(), QDomAttrPrivate::save(), QDomElementPrivate::save(), QDomNotationPrivate::save(), QDomEntityPrivate::save(), QFutureWatcherBasePrivate::sendCallOutEvent(), QDomElementPrivate::setAttributeNodeNS(), QUrlPrivate::setAuthority(), QProgressDialog::setCancelButtonText(), QUrl::setFragment(), QSystemTrayIconSys::setIconContents(), QDomNamedNodeMapPrivate::setNamedItemNS(), QXmlNamespaceSupport::setPrefix(), QLabel::setTextFormat(), QWidget::setWindowTitle(), QXmlStreamReaderPrivate::startDocument(), startsWith(), QStringRef::startsWith(), QLineControl::text(), QLocale::toCurrencyString(), QUrlPrivate::toEncoded(), QPatternist::XQueryTokenizer::tokenizeStringLiteral(), toPercentEncodingHelper(), QUrl::toString(), toUtf8(), QStringRef::toUtf8(), QUrlPrivate::userInfo(), QTextOdfWriter::writeBlockFormat(), QXmlStreamWriter::writeProcessingInstruction(), QApplicationPrivate::x11_apply_settings(), and QPSQLResult::~QPSQLResult().

505 { return d == &shared_null; }
static Data shared_null
Definition: qstring.h:616
Data * d
Definition: qstring.h:618

◆ isRightToLeft()

bool QString::isRightToLeft ( ) const

Returns true if the string is read right to left.

Definition at line 7528 of file qstring.cpp.

Referenced by QDeclarativeTextEditPrivate::determineHorizontalAlignment(), QDeclarativeTextInputPrivate::determineHorizontalAlignment(), QTextEngine::isRightToLeft(), and QLabelPrivate::textDirection().

7529 {
7530  return isStringRightToLeft(d->data, d->data + d->size);
7531 }
static bool isStringRightToLeft(const ushort *p, const ushort *end)
Definition: qstring.cpp:7487
Data * d
Definition: qstring.h:618
ushort * data
Definition: qstring.h:606

◆ isSharedWith()

bool QString::isSharedWith ( const QString other) const
inline
Warning
This function is not part of the public interface.

Definition at line 123 of file qstring.h.

123 { return d == other.d; }
Data * d
Definition: qstring.h:618

◆ isSimpleText()

bool QString::isSimpleText ( ) const
inline
Warning
This function is not part of the public interface.

Definition at line 588 of file qstring.h.

588 { if (!d->clean) updateProperties(); return d->simpletext; }
void updateProperties() const
Definition: qstring.cpp:7510
ushort clean
Definition: qstring.h:607
Data * d
Definition: qstring.h:618
ushort simpletext
Definition: qstring.h:608

◆ lastIndexOf() [1/6]

int QString::lastIndexOf ( QChar  c,
int  from = -1,
Qt::CaseSensitivity  cs = Qt::CaseSensitive 
) const

Definition at line 3000 of file qstring.cpp.

Referenced by _q_parseDosDir(), QFileDialogPrivate::_q_updateOkButton(), QDeclarativeImportsPrivate::add(), QFileDialogPrivate::addDefaultSuffixToFiles(), addTag(), QCoreApplicationPrivate::appendApplicationPathToLibraryPaths(), QFileDialogPrivate::basename(), QDeclarativeCompiler::buildDynamicMeta(), createImageNode(), QDeclarativeComponentPrivate::createObject(), customMimeType(), QKeySequencePrivate::decodeString(), QDeclarativeXmlQueryEngine::doQueryJob(), DumpIDL(), fbname(), QFileInfoGatherer::fetchExtendedInformation(), QResourceFileEngine::fileName(), fileName(), QDeclarativeImportedNamespace::find(), find_translation(), QSslCertificate::fromPath(), QFileSystemEngine::getLinkTarget(), QSymSQLResultPrivate::initColumns(), QAxBase::initializeRemote(), isDirPath(), QSslSocketBackendPrivate::isMatchingHostname(), keyName(), keyPath(), lastIndexOf(), QByteArray::lastIndexOf(), QStringRef::lastIndexOf(), launchWebBrowser(), QTranslator::load(), QAxServerBase::Load(), QFSFileEnginePrivate::longFileName(), menuItemEntry(), QDeclarativeEngineDebugService::objectData(), QScriptNewBreakpointWidget::onOkClicked(), QStringRef::operator=(), parseFontName(), parseIp6(), qAxInit(), qt_init(), qt_is_idn_enabled(), QFileDialogPrivate::qt_mac_filedialog_filter_proc(), qt_mac_menu_merge_action(), qt_set_x11_resources(), qt_setWindowTitle_helperHelper(), MetaObjectGenerator::readClassInfo(), QFileSystemEngine::removeDirectory(), QDeclarativeImportsPrivate::resolvedUri(), QAxServerBase::Save(), QNetworkCookieJar::setCookiesFromUrl(), QDeclarativeFolderListModel::setFolder(), QDesktopServices::storageLocation(), QMenuPrivate::QMacMenuPrivate::syncAction(), QFileInfoGatherer::updateFile(), UpdateRegistry(), QAxFactory::validateLicenseKey(), and QDeclarativeInfo::~QDeclarativeInfo().

3001 {
3002  return qt_last_index_of(unicode(), size(), ch, from, cs);
3003  }
static int qt_last_index_of(const QChar *haystack, int haystackLen, const QChar &needle, int from, Qt::CaseSensitivity cs)
Definition: qstring.cpp:9595
int size() const
Returns the number of characters in this string.
Definition: qstring.h:102
const QChar * unicode() const
Returns a &#39;\0&#39;-terminated Unicode representation of the string.
Definition: qstring.h:706

◆ lastIndexOf() [2/6]

int QString::lastIndexOf ( const QString str,
int  from = -1,
Qt::CaseSensitivity  cs = Qt::CaseSensitive 
) const

Returns the index position of the last occurrence of the string str in this string, searching backward from index position from.

If from is -1 (default), the search starts at the last character; if from is -2, at the next to last character and so on. Returns -1 if str is not found.

If cs is Qt::CaseSensitive (default), the search is case sensitive; otherwise the search is case insensitive.

Example:

QString x = "crazy azimuths";
QString y = "az";
x.lastIndexOf(y); // returns 6
x.lastIndexOf(y, 6); // returns 6
x.lastIndexOf(y, 5); // returns 2
x.lastIndexOf(y, 1); // returns -1
See also
indexOf(), contains(), count()

Definition at line 2925 of file qstring.cpp.

2926 {
2927  const int sl = str.d->size;
2928  if (sl == 1)
2929  return lastIndexOf(QChar(str.d->data[0]), from, cs);
2930 
2931  const int l = d->size;
2932  if (from < 0)
2933  from += l;
2934  int delta = l-sl;
2935  if (from == l && sl == 0)
2936  return from;
2937  if (from < 0 || from >= l || delta < 0)
2938  return -1;
2939  if (from > delta)
2940  from = delta;
2941 
2942  return lastIndexOfHelper(d->data, from, str.d->data, str.d->size, cs);
2943 }
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
Data * d
Definition: qstring.h:618
ushort * data
Definition: qstring.h:606
int lastIndexOf(QChar c, int from=-1, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.cpp:3000
static int lastIndexOfHelper(const ushort *haystack, int from, const ushort *needle, int sl, Qt::CaseSensitivity cs)
Definition: qstring.cpp:2863
QFactoryLoader * l

◆ lastIndexOf() [3/6]

int QString::lastIndexOf ( const QLatin1String s,
int  from = -1,
Qt::CaseSensitivity  cs = Qt::CaseSensitive 
) const

Definition at line 2967 of file qstring.cpp.

2968 {
2969  const int sl = qstrlen(str.latin1());
2970  if (sl == 1)
2971  return lastIndexOf(QLatin1Char(str.latin1()[0]), from, cs);
2972 
2973  const int l = d->size;
2974  if (from < 0)
2975  from += l;
2976  int delta = l-sl;
2977  if (from == l && sl == 0)
2978  return from;
2979  if (from < 0 || from >= l || delta < 0)
2980  return -1;
2981  if (from > delta)
2982  from = delta;
2983 
2985  for (int i = 0; i < sl; ++i)
2986  s[i] = str.latin1()[i];
2987 
2988  return lastIndexOfHelper(d->data, from, s.data(), sl, cs);
2989 }
const char * latin1() const
Returns the Latin-1 string stored in this object.
Definition: qstring.h:661
Data * d
Definition: qstring.h:618
ushort * data
Definition: qstring.h:606
uint qstrlen(const char *str)
Definition: qbytearray.h:79
int lastIndexOf(QChar c, int from=-1, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.cpp:3000
static int lastIndexOfHelper(const ushort *haystack, int from, const ushort *needle, int sl, Qt::CaseSensitivity cs)
Definition: qstring.cpp:2863
QFactoryLoader * l
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ lastIndexOf() [4/6]

int QString::lastIndexOf ( const QStringRef s,
int  from = -1,
Qt::CaseSensitivity  cs = Qt::CaseSensitive 
) const

Definition at line 3023 of file qstring.cpp.

3024 {
3025  const int sl = str.size();
3026  if (sl == 1)
3027  return lastIndexOf(str.at(0), from, cs);
3028 
3029  const int l = d->size;
3030  if (from < 0)
3031  from += l;
3032  int delta = l - sl;
3033  if (from == l && sl == 0)
3034  return from;
3035  if (from < 0 || from >= l || delta < 0)
3036  return -1;
3037  if (from > delta)
3038  from = delta;
3039 
3040  return lastIndexOfHelper(d->data, from, reinterpret_cast<const ushort*>(str.unicode()),
3041  str.size(), cs);
3042 }
Data * d
Definition: qstring.h:618
ushort * data
Definition: qstring.h:606
int lastIndexOf(QChar c, int from=-1, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.cpp:3000
static int lastIndexOfHelper(const ushort *haystack, int from, const ushort *needle, int sl, Qt::CaseSensitivity cs)
Definition: qstring.cpp:2863
QFactoryLoader * l

◆ lastIndexOf() [5/6]

int QString::lastIndexOf ( const QRegExp rx,
int  from = -1 
) const

Definition at line 3385 of file qstring.cpp.

3386 {
3387  QRegExp rx2(rx);
3388  return rx2.lastIndexIn(*this, from);
3389 }
The QRegExp class provides pattern matching using regular expressions.
Definition: qregexp.h:61

◆ lastIndexOf() [6/6]

int QString::lastIndexOf ( QRegExp rx,
int  from = -1 
) const

Definition at line 3409 of file qstring.cpp.

3410 {
3411  return rx.lastIndexIn(*this, from);
3412 }
int lastIndexIn(const QString &str, int offset=-1, CaretMode caretMode=CaretAtZero) const
Attempts to find a match backwards in str from position offset.
Definition: qregexp.cpp:4167

◆ left()

QString QString::left ( int  n) const

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

The entire string is returned if n is greater than size() or less than zero.

QString x = "Pineapple";
QString y = x.left(4); // y == "Pine"
See also
right(), mid(), startsWith()

Definition at line 3664 of file qstring.cpp.

Referenced by QLineEditPrivate::_q_completionHighlighted(), _q_escapeIdentifier(), _q_resolveEntryAndCreateLegacyEngine_recursive(), QDeclarativeTypeLoader::absoluteFilePath(), QDeclarativeImportsPrivate::add(), QDeclarativePropertyCache::append(), QUnixPrintWidgetPrivate::applyPrinterProperties(), QKeySequence::assign(), computeElidedText(), QVNCScreen::connect(), QMultiScreen::connect(), QTransformedScreen::connect(), QHttpHeader::contentType(), QPatternist::XsdInstanceReader::convertToQName(), QPatternist::XsdTypeChecker::convertToQName(), QFileSystemEngine::createDirectory(), QScriptDebuggerConsolePrivate::createJob(), QPSQLResult::data(), QCalendarModel::dayName(), QNativeWifiEngine::disconnectFromId(), QDragManager::drag(), QWindowsCEStyle::drawControl(), QWindowsVistaStyle::drawControl(), QPlastiqueStyle::drawControl(), QCleanlooksStyle::drawControl(), QWindowsXPStyle::drawControl(), QWindowsStyle::drawControl(), QGtkStyle::drawControl(), QMotifStyle::drawControl(), QMacStyle::drawControl(), QStyleSheetStyle::drawControl(), DumpIDL(), QTextEngine::elidedText(), elliditide(), extractEncodingDecl(), QResourceFileEngine::fileName(), QDeclarativeImportedNamespace::find(), QFontDatabase::findFont(), QSystemTrayIconSys::findIconGeometry(), QSystemTrayIconSys::findTrayGeometry(), fontPath(), QSslCertificate::fromPath(), QDateTime::fromString(), QUrl::fromUserInput(), QFileSystemEngine::getLinkTarget(), getStringTok(), QImageReaderPrivate::getText(), getVariables(), QMacInputContext::globalEventProcessor(), QDirModel::index(), QAxBase::initializeRemote(), QLineControl::internalInsert(), QLineControl::internalSetText(), QAxServerBase::Invoke(), isDirPath(), keyPath(), leftJustified(), QTranslator::load(), QAxServerBase::Load(), longestCommonPrefix(), QFSFileEnginePrivate::longFileName(), QSharedMemoryPrivate::makePlatformSafeKey(), QFileDialogPrivate::maxNameLength(), menuItemEntry(), QDeclarativePropertyCache::Data::name(), QWSServerPrivate::newMouseHandler(), QDeclarativeEngineDebugService::objectData(), QScriptNewBreakpointWidget::onOkClicked(), QIBaseDriver::open(), QMYSQLDriver::open(), QWSServer::openKeyboard(), QFontMetrics::operator!=(), QTest::outputMessage(), QDeclarativeDirParser::parse(), parseFontName(), QLineControl::parseInputMask(), QHttpHeader::parseLine(), QHttpResponseHeader::parseLine(), QHttpRequestHeader::parseLine(), QDateTimeParser::parseSection(), QFileSystemEntry::path(), QDeclarativeStringConverters::pointFFromString(), QApplicationPrivate::process_cmdline(), QXmlNamespaceSupport::processName(), QPatternist::NamespaceSupport::processName(), qAxInit(), QDeclarativeGridScaledImage::QDeclarativeGridScaledImage(), qDrawPlainRect(), qExtractSecurityPolicyFromString(), qGetTableInfo(), QIconTheme::QIconTheme(), qParseOpts(), qSplitTableAndOwner(), qSplitTableName(), qt_mac_to_pascal_string(), qt_parsePrinterDesc(), qt_parseQconfig(), qt_set_x11_resources(), qt_split_namespace(), qt_win_get_open_file_name(), qt_win_get_open_file_names(), qt_win_get_save_file_name(), MetaObjectGenerator::readClassInfo(), QFtpPI::readyRead(), QDeclarativeStringConverters::rectFFromString(), registerFont(), QFileSystemEngine::removeDirectory(), rightJustified(), QAxServerBase::Save(), QAxScriptManager::scriptForFunction(), section(), set_text(), QUrlPrivate::setAuthority(), QNetworkCookieJar::setCookiesFromUrl(), QDeclarativeFolderListModel::setFolder(), QSystemTrayIconSys::setIconContents(), QTextBrowserPrivate::setSource(), QUndoCommand::setText(), QGtkStylePrivate::setupGtkFileChooser(), QUrl::setUrl(), QUrlPrivate::setUserInfo(), QDeclarativeStringConverters::sizeFFromString(), QFileSystemEngine::slowCanonicalized(), QXmlNamespaceSupport::splitName(), QFtpPI::startNextCmd(), QPainter::testRenderHint(), QLineControl::textBeforeSelection(), QImage::textList(), QPatternist::Decimal::toString(), totalDigitsForDecimal(), QMenuPrivate::updateActionRects(), QAuthenticatorPrivate::updateCredentials(), UpdateRegistry(), QDateTimeEditPrivate::validateAndInterpret(), QAxFactory::validateLicenseKey(), QDeclarativeStringConverters::vector3DFromString(), and QDeclarativeInfo::~QDeclarativeInfo().

3665 {
3666  if (n >= d->size || n < 0)
3667  return *this;
3668  return QString((const QChar*) d->data, n);
3669 }
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
Data * d
Definition: qstring.h:618
ushort * data
Definition: qstring.h:606
QString()
Constructs a null string.
Definition: qstring.h:879

◆ leftJustified()

QString QString::leftJustified ( int  width,
QChar  fill = QLatin1Char(' '),
bool  truncate = false 
) const

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

If truncate is false and the size() of the string is more than width, then the returned string is a copy of the string.

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

If truncate is true and the size() of the string is more than width, then any characters in a copy of the string after position width are removed, and the copy is returned.

QString str = "Pineapple";
str = str.leftJustified(5, '.', true); // str == "Pinea"
See also
rightJustified()

Definition at line 5318 of file qstring.cpp.

Referenced by QPatternist::AbstractDuration::create(), QPatternist::AbstractDateTime::create(), and vsprintf().

5319 {
5320  QString result;
5321  int len = length();
5322  int padlen = width - len;
5323  if (padlen > 0) {
5324  result.resize(len+padlen);
5325  if (len)
5326  memcpy(result.d->data, d->data, sizeof(QChar)*len);
5327  QChar *uc = (QChar*)result.d->data + len;
5328  while (padlen--)
5329  * uc++ = fill;
5330  } else {
5331  if (truncate)
5332  result = left(width);
5333  else
5334  result = *this;
5335  }
5336  return result;
5337 }
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
The QString class provides a Unicode character string.
Definition: qstring.h:83
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
void truncate(int pos)
Truncates the string at the given position index.
Definition: qstring.cpp:4603
QString left(int n) const Q_REQUIRED_RESULT
Returns a substring that contains the n leftmost characters of the string.
Definition: qstring.cpp:3664
Data * d
Definition: qstring.h:618
void resize(int size)
Sets the size of the string to size characters.
Definition: qstring.cpp:1353
ushort * data
Definition: qstring.h:606
QString & fill(QChar c, int size=-1)
Sets every character in the string to character ch.
Definition: qstring.cpp:4641

◆ leftRef()

QStringRef QString::leftRef ( int  n) const

Returns a substring reference to the n leftmost characters of the string.

Since
4.4

If n is greater than size() or less than zero, a reference to the entire string is returned.

QString x = "Pineapple";
QStringRef y = x.leftRef(4); // y == "Pine"
See also
left(), rightRef(), midRef(), startsWith()

Definition at line 9045 of file qstring.cpp.

Referenced by QDeclarativePropertyCache::create(), QSslSocketBackendPrivate::isMatchingHostname(), and parseServerList().

9046 {
9047  if (n >= d->size || n < 0)
9048  n = d->size;
9049  return QStringRef(this, 0, n);
9050 }
Data * d
Definition: qstring.h:618
friend class QStringRef
Definition: qstring.h:644

◆ length()

int QString::length ( ) const
inline

Returns the number of characters in this string.

Equivalent to size().

See also
resize()

Definition at line 696 of file qstring.h.

Referenced by QScriptDebuggerConsoleWidgetPrivate::_q_onCompletionTaskFinished(), QPrintDialogPrivate::_q_printerOrFileSelected(), QHttpPrivate::_q_slotConnected(), QFileDialogPrivate::_q_updateOkButton(), QDeclarativeTypeLoader::absoluteFilePath(), QFileDialog::accept(), QDBusConnectionPrivate::activateObject(), QDeclarativeImportDatabase::addImportPath(), QDeclarativeImportDatabase::addPluginPath(), QDir::addResourceSearchPath(), addTag(), QTextHtmlImporter::appendNodeText(), QConcatenable< QString >::appendTo(), QSyntaxHighlighterPrivate::applyFormatChanges(), QUnixPrintWidgetPrivate::applyPrinterProperties(), QKeySequence::assign(), QPatternist::DerivedString< TypeToken >::attributeNormalize(), QTextEngine::attributes(), QFileSystemEntry::baseName(), bidiItemize(), QOCIResultPrivate::bindValue(), QFontMetrics::boundingRect(), QFontMetricsF::boundingRect(), QPainter::boundingRect(), QDeclarativeCompiler::buildDynamicMeta(), QTextCodec::canEncode(), canonicalOrderHelper(), QRegExpEngine::Box::cat(), QFontMetrics::charWidth(), QPatternist::XsdTypeChecker::checkConstrainingFacetsString(), QDir::cleanPath(), QLineControl::clear(), QLocalePrivate::codeToCountry(), QLocalePrivate::codeToLanguage(), QLocalePrivate::codeToScript(), QDeclarativeStringConverters::colorFromString(), compare(), QStringRef::compare(), QLineControl::complete(), QFileSystemEntry::completeBaseName(), QDeclarativeCompiler::completeComponentBuild(), QScriptCompletionTaskPrivate::completeScriptExpression(), QScriptDebuggerConsoleCommandManager::completions(), composeHelper(), QWinInputContext::composition(), computeElidedText(), QLinuxFbScreen::connect(), QAbstractConcatenable::convertFromAscii(), QWindowsMimeText::convertFromMime(), QWindowsMimeURI::convertFromMime(), QBuiltInMimes::convertFromMime(), Qt::convertFromPlainText(), QWindowsMimeURI::convertToMime(), QUtf8::convertToUnicode(), count(), QNetworkAccessFileBackendFactory::create(), QFileSystemEngine::createDirectory(), createFileFromTemplate(), QPatternist::URILoader::createRequest(), QPSQLResult::data(), QDomCharacterDataPrivate::dataLength(), QLocalePrivate::dateTimeToString(), decimalForm(), QKeySequencePrivate::decodeString(), decomposeHelper(), QPatternist::CompressedWhitespace::decompress(), QDeclarativeListModelParser::definesEmptyList(), derefEngine(), double2string(), QLocalePrivate::doubleToString(), QDragManager::drag(), QSvgText::draw(), QPainter::drawText(), QLineEdit::dropEvent(), DumpIDL(), QAxBase::dynamicCallHelper(), QTextEngine::elidedText(), QTextHtmlExporter::emitFragment(), QTextHtmlExporter::emitFrameStyle(), encodeText(), QStringRef::endsWith(), QPatternist::CaseInsensitiveStringComparator::equals(), errorCodeToString(), Qt::escape(), QPatternist::escape(), escapedKey(), QPatternist::AtomicString::evaluateEBV(), QPatternist::DerivedString< TypeToken >::evaluateEBV(), QPatternist::TranslateFN::evaluateSingleton(), QCalendarTextNavigator::eventFilter(), QRegExp::exactMatch(), QDB2Result::exec(), QODBCResult::exec(), QSqlResult::exec(), QOCICols::execBatch(), QProcessPrivate::execChild(), exponentForm(), extractEncodingDecl(), familyList(), QWSSoundServerPrivate::feedDevice(), QFileSystemEntry::fileName(), QDir::filePath(), QFileSystemModelPrivate::filePath(), QShortcutMap::find(), findArgEscapes(), findChildObject(), findGraphicsFactory(), findGroupFactory(), findInBlock(), QResourceRoot::findNode(), findObject(), findStyleFactoryMethod(), findStyleUtilFactoryMethod(), QSystemTrayIconSys::findTrayGeometry(), findUtilFactory(), fmtDateTime(), QTextEngine::formatIndex(), QTest::formatResult(), QSqlDriver::formatValue(), QPatternist::NamePool::fromClarkName(), QPatternist::HexBinary::fromLexical(), QUrl::fromLocalFile(), QDir::fromNativeSeparators(), QUrl::fromPunycode(), QDateTime::fromString(), QTextCodec::fromUnicode(), QTextEncoder::fromUnicode(), generateName(), QAxServerBase::GetCurFile(), getEnglishName(), getMessage(), getNextChar(), QGtkStylePrivate::getThemeName(), QMacInputContext::globalEventProcessor(), QApplicationPrivate::globalEventProcessor(), QRegExpEngine::goodStringMatch(), QDBusConnectionPrivate::handleSignal(), QLineControl::hasAcceptableInput(), QDeclarativeXMLHttpRequest::headers(), QRegExpEngine::heuristicallyChooseHeuristic(), QScriptSyntaxHighlighter::highlightBlock(), QCalendarDateSectionValidator::highlightString(), QScriptSyntaxHighlighter::highlightWord(), QTextDocumentLayout::hitTest(), QUrl::host(), QRegExp::indexIn(), indexOf(), QStringRef::indexOf(), QFontMetrics::inFontUcs4(), QFontMetricsF::inFontUcs4(), QSettingsPrivate::iniEscapedKey(), QDeclarativeTextInputPrivate::init(), QSQLite2ResultPrivate::init(), QLineControl::init(), QAxBase::initializeRemote(), QSettingsPrivate::iniUnescapedKey(), QTextControlPrivate::inputMethodEvent(), QTextDocumentPrivate::insert(), QTextDocumentPrivate::insertBlock(), QTextCursor::insertText(), int2string(), QLineControl::internalDelete(), QLineControl::internalInsert(), QLCDNumberPrivate::internalSetString(), QLineControl::internalSetText(), QAxServerBase::Invoke(), QFileSystemEntry::isAbsolute(), QKeyMapperPrivate::isADeadKey(), isDirPath(), QFileSystemEntry::isDriveRoot(), QPatternist::LangFN::isLangMatch(), QSslSocketBackendPrivate::isMatchingHostname(), QUrl::isParentOf(), isPrefixOf(), QXmlUtils::isPublicID(), QFileSystemEntry::isRelative(), isSignalPropertyName(), isSupportedSvgFeature(), isUncRoot(), QDBusUtil::isValidBusName(), QDBusUtil::isValidInterfaceName(), QDBusUtil::isValidMemberName(), QPatternist::DerivedString< TypeToken >::isValidName(), QPatternist::DerivedString< TypeToken >::isValidNMTOKEN(), QDBusUtil::isValidPartOfObjectPath(), QDBusUtil::isValidUniqueConnectionName(), QTextEngine::itemize(), QTextEngine::justify(), QTest::keyClicks(), QMenuBar::keyPressEvent(), QMenu::keyPressEvent(), QTextEdit::keyPressEvent(), QRegExp::lastIndexIn(), launchWebBrowser(), QTextLine::layout_helper(), QTextEngine::LayoutData::LayoutData(), leftJustified(), QPatternist::ProcessingInstructionConstructor::leftTrimmed(), CharacterData::length(), lengthLessThan(), QCss::ValueExtractor::lengthValue(), QTextEngine::lineNumberForTextPosition(), QTranslator::load(), QAxServerBase::Load(), loadEngine(), localeAwareCompare(), QStringRef::localeAwareCompare(), localizedName(), longestCommonPrefix(), QFSFileEnginePrivate::longFileName(), QLocalePrivate::longLongToString(), QPatternist::XQueryTokenizer::lookupKeyword(), QLineControl::maskString(), menuItemEntry(), Qt::mightBeRichText(), QMacPasteboardMimeAny::mimeFor(), QKeySequence::mnemonic(), QMacInputContext::mouseHandler(), QWinInputContext::mouseHandler(), QXIMInputContext::mouseHandler(), QDeclarativeTextInput::moveCursorSelection(), QFileSystemEngine::nativeAbsoluteFilePath(), QFileSystemModelPrivate::naturalCompare(), QTextHtmlParser::newNode(), QScriptEnginePrivate::newRegExp(), QCssScanner_Generated::next(), nextDotDelimiter(), QTextEngine::nextLogicalPosition(), QPatternist::XQueryTokenizer::nextToken(), QFileSystemModelPrivate::node(), QStyleSheetStyleSelector::nodeNameEquals(), QLocalePrivate::numberToCLocale(), QScriptNewBreakpointWidget::onOkClicked(), QOCIDriver::open(), QDB2Driver::open(), QAudioInputPrivate::open(), QODBCDriver::open(), QAudioOutputPrivate::open(), QTemporaryFileEngine::open(), operator<(), operator<<(), QGraphicsSimpleTextItem::paint(), QDeclarativeStyledTextPrivate::parse(), QDeclarativeDirParser::parse(), QDeclarativeJS::Parser::parse(), QTextHtmlParser::parse(), parse_locale_tag(), QSvgHandler::parseCSStoXMLAttrs(), QTextHtmlParser::parseEntity(), QPatternist::PatternPlatform::parseFlags(), parseFontName(), QLineControl::parseInputMask(), QHttpResponseHeader::parseLine(), QHttpRequestHeader::parseLine(), QDeclarativeBindingCompilerPrivate::parseName(), parseServerList(), QXmlSimpleReaderPrivate::parseString(), QFileSystemEntry::path(), QFSCompleter::pathFromIndex(), populate_database(), QDeclarativeTextEdit::positionAt(), QDB2Result::prepare(), QOCIResult::prepare(), QODBCResult::prepare(), QDBusConnectionPrivate::prepareHook(), QDB2Driver::primaryIndex(), QODBCDriver::primaryIndex(), QLineControl::processInputMethodEvent(), QLineControl::processKeyEvent(), QXmlSimpleReaderPrivate::processReference(), QFtpPI::processReply(), QProcessPrivate::processStarted(), QDeclarativeTextInput::q_canPasteChanged(), qDateTimeFromString(), qDBusGenerateMetaObjectXml(), qDBusInterfaceFromMetaObject(), QDeclarative_isFileCaseCorrect(), QDeclarativeImportDatabase::QDeclarativeImportDatabase(), qEncodeNtlmString(), QLineEdit::QLineEdit(), QRegExpEngine::QRegExpEngine(), qReplacePlaceholderMarkers(), qSplitTableAndOwner(), qStreamNtlmString(), qStringAsUcs2Le(), QtPrivate::QStringList_contains(), QStringToBSTR(), QStringToOLESTR(), qt_accAmpIndex(), qt_ACE_do(), qt_create_commandline(), qt_format_text(), qt_keyrelease_scanner(), QFileDialogPrivate::qt_mac_filedialog_event_proc(), QFileDialogPrivate::qt_mac_filedialog_filter_proc(), qt_mac_menu_merge_action(), qt_mac_removeMnemonics(), qt_mac_to_pascal_string(), qt_parsePrintcap(), qt_parsePrinterDesc(), qt_parsePrintersConf(), qt_parseQconfig(), qt_parseSpoolInterface(), qt_section_chunk::qt_section_chunk(), qt_set_x11_resources(), qt_splitLocaleName(), qt_string_normalize(), qt_tildeExpansion(), qt_win_get_open_file_names(), qt_win_make_OFN(), qTextAfterOffsetFromString(), qTextAtOffsetFromString(), qTextBeforeOffsetFromString(), QUuid::QUuid(), qWinCmdArgs(), qwsSetClipboardText(), QTextStreamPrivate::read(), QWinSettingsPrivate::readKey(), QVFbScreenKeyboardHandler::readKeyboardData(), QFtpPI::readyRead(), QDB2Driver::record(), QODBCDriver::record(), QPSQLDriver::record(), QTextControlPrivate::rectForPosition(), QDeclarativeBindingCompilerPrivate::registerLiteralString(), QFileSystemEngine::removeDirectory(), QLineControl::removeSelectedText(), replace(), replaceArgEscapes(), replacePercentN(), QDeclarativeXMLHttpRequest::requestFromUrl(), QDB2Result::reset(), QODBCResult::reset(), QDeclarativeImportsPrivate::resolvedUri(), resolveScheme(), QDeclarativeCompiler::rewriteBinding(), rightJustified(), QAxServerBase::Save(), section(), QLineEdit::selectionStart(), QKeyMapper::sendKeyEvent(), QLineEditPrivate::sendMouseEventToInputContext(), QTextControlPrivate::sendMouseEventToInputContext(), QWSInputMethod::sendPreeditString(), QWSServerPrivate::sendQCopEvent(), QWinSettingsPrivate::set(), set_text(), QCoreApplication::setApplicationVersion(), QUrlPrivate::setAuthority(), QTextEngine::setBoundary(), QWSQCopRegisterChannelCommand::setChannel(), QScript::Lexer::setCode(), QDeclarativeJS::Lexer::setCode(), QColor::setColorFromString(), QBBInputContext::setComposingText(), QAxBase::setControl(), QPluginLoader::setFileName(), QWSPlaySoundCommand::setFileName(), QSystemTrayIconSys::setIconContents(), QWSIdentifyCommand::setId(), QTextLine::setLineWidth(), QWSQCopSendCommand::setMessage(), QDeclarativeTextInput::setPasswordCharacter(), QDirPrivate::setPath(), QLineControl::setSelection(), QGtkStylePrivate::setupGtkFileChooser(), QUrlPrivate::setUserInfo(), QSystemTrayIconSys::showMessage(), QNmDBusHelper::slotAccessPointAdded(), QNmDBusHelper::slotAccessPointRemoved(), QSettingsPrivate::splitArgs(), splitSpaceSemicolon(), QSqlDriver::sqlStatement(), QScriptCompletionTask::start(), QFtpPI::startNextCmd(), QTextBoundaryFinder::string(), stringContainsNullChar(), QSettingsPrivate::stringListToVariantList(), QLineControl::stripString(), stripTextDecl(), QMenuPrivate::QMacMenuPrivate::syncAction(), QDB2Driver::tables(), QODBCDriver::tables(), QFontMetrics::tightBoundingRect(), QFontMetricsF::tightBoundingRect(), toAscii(), QStringRef::toAscii(), QFileDialogPrivate::toInternal(), QPatternist::Tokenizer::tokenToString(), toLatin1(), QStringRef::toLatin1(), QProcessEnvironmentPrivate::toList(), QStringRef::toLocal8Bit(), QUrl::toLocalFile(), QDir::toNativeSeparators(), toPunycodeHelper(), toStdWString(), QKeySequence::toString(), totalDigitsForDecimal(), totalDigitsForSignedLongLong(), totalDigitsForUnsignedLongLong(), XsdSchemaToken::toToken(), QPatternist::XSLTTokenLookup::toToken(), toUcs4(), QStringRef::toUcs4(), toUcs4_helper(), QFontEngineXLFD::toUnicode(), toUtf8(), QStringRef::toUtf8(), toWCharArray(), QETWidget::translateKeyEvent(), QXlibKeyboard::translateKeySym(), QXcbKeyboard::translateKeySym(), translateKeySym(), QWSSoundServerClient::tryReadCommand(), typeNameToXml(), QLocalePrivate::unsLongLongToString(), QLineControl::updateDisplayText(), QFileInfoGatherer::updateFile(), QPrintPreviewDialogPrivate::updatePageNumLabel(), UpdateRegistry(), QSpinBoxValidator::validate(), QLocalePrivate::validateChars(), vsprintf(), wc2rx(), QFontMetrics::width(), QFontMetricsF::width(), QXmlSerializer::write(), write_xbm_image(), QTextOdfWriter::writeBlock(), QXmlSerializer::writeEscaped(), QXmlSerializer::writeEscapedAttribute(), QApplication::x11ProcessEvent(), and xic_draw_callback().

697 { return d->size; }
Data * d
Definition: qstring.h:618

◆ localeAwareCompare() [1/4]

int QString::localeAwareCompare ( const QString s) const

Definition at line 5197 of file qstring.cpp.

Referenced by QStringRef::at(), QSortFilterProxyModel::lessThan(), localeAwareCompare(), QFileSystemModelPrivate::naturalCompare(), QDirSortItemComparator::operator()(), and QAbstractItemModelPrivate::variantLessThan().

5198 {
5199  return localeAwareCompare_helper(constData(), length(), other.constData(), other.length());
5200 }
static int localeAwareCompare_helper(const QChar *data1, int length1, const QChar *data2, int length2)
Definition: qstring.cpp:5212
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
const QChar * constData() const
Returns a pointer to the data stored in the QString.
Definition: qstring.h:712

◆ localeAwareCompare() [2/4]

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

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.

On Mac OS X since Qt 4.3, this function compares according the "Order for sorted lists" setting in the International prefereces panel.

See also
compare(), QTextCodec::locale()

Definition at line 367 of file qstring.h.

368  { return s1.localeAwareCompare(s2); }
int localeAwareCompare(const QString &s) const
Definition: qstring.cpp:5197

◆ localeAwareCompare() [3/4]

int QString::localeAwareCompare ( const QStringRef s) const
inline

Definition at line 1262 of file qstring.h.

1263 { return localeAwareCompare_helper(constData(), length(), s.constData(), s.length()); }
static int localeAwareCompare_helper(const QChar *data1, int length1, const QChar *data2, int length2)
Definition: qstring.cpp:5212
int length() const
Returns the number of characters referred to by the string reference.
Definition: qstring.h:1116
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
const QChar * constData() const
Same as unicode().
Definition: qstring.h:1159
const QChar * constData() const
Returns a pointer to the data stored in the QString.
Definition: qstring.h:712

◆ localeAwareCompare() [4/4]

int QString::localeAwareCompare ( const QString s1,
const QStringRef s2 
)
inlinestatic

Definition at line 1264 of file qstring.h.

1265 { return localeAwareCompare_helper(s1.constData(), s1.length(), s2.constData(), s2.length()); }
static int localeAwareCompare_helper(const QChar *data1, int length1, const QChar *data2, int length2)
Definition: qstring.cpp:5212
int length() const
Returns the number of characters referred to by the string reference.
Definition: qstring.h:1116
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
const QChar * constData() const
Same as unicode().
Definition: qstring.h:1159
const QChar * constData() const
Returns a pointer to the data stored in the QString.
Definition: qstring.h:712

◆ localeAwareCompare_helper()

int QString::localeAwareCompare_helper ( const QChar data1,
int  length1,
const QChar data2,
int  length2 
)
staticprivate
Warning
This function is not part of the public interface.
Since
4.5

Definition at line 5212 of file qstring.cpp.

Referenced by localeAwareCompare(), and QStringRef::localeAwareCompare().

5214 {
5215  // do the right thing for null and empty
5216  if (length1 == 0 || length2 == 0)
5217  return ucstrcmp(data1, length1, data2, length2);
5218 
5219 #if defined(Q_OS_WIN32) || defined(Q_OS_WINCE)
5220  int res = CompareString(GetUserDefaultLCID(), 0, (wchar_t*)data1, length1, (wchar_t*)data2, length2);
5221 
5222  switch (res) {
5223  case CSTR_LESS_THAN:
5224  return -1;
5225  case CSTR_GREATER_THAN:
5226  return 1;
5227  default:
5228  return 0;
5229  }
5230 #elif defined (Q_OS_MAC)
5231  // Use CFStringCompare for comparing strings on Mac. This makes Qt order
5232  // strings the same way as native applications do, and also respects
5233  // the "Order for sorted lists" setting in the International preferences
5234  // panel.
5235  const CFStringRef thisString =
5236  CFStringCreateWithCharactersNoCopy(kCFAllocatorDefault,
5237  reinterpret_cast<const UniChar *>(data1), length1, kCFAllocatorNull);
5238  const CFStringRef otherString =
5239  CFStringCreateWithCharactersNoCopy(kCFAllocatorDefault,
5240  reinterpret_cast<const UniChar *>(data2), length2, kCFAllocatorNull);
5241 
5242  const int result = CFStringCompare(thisString, otherString, kCFCompareLocalized);
5243  CFRelease(thisString);
5244  CFRelease(otherString);
5245  return result;
5246 #elif defined(Q_OS_SYMBIAN)
5247  TPtrC p1 = TPtrC16(reinterpret_cast<const TUint16 *>(data1), length1);
5248  TPtrC p2 = TPtrC16(reinterpret_cast<const TUint16 *>(data2), length2);
5249  return p1.CompareC(p2);
5250 #elif defined(Q_OS_UNIX)
5251 # if defined(QT_USE_ICU)
5252  int res;
5253  if (qt_ucol_strcoll(data1, length1, data2, length2, &res)) {
5254  if (res == 0)
5255  res = ucstrcmp(data1, length1, data2, length2);
5256  return res;
5257  } // else fall through
5258 # endif
5259  // declared in <string.h>
5260  int delta = strcoll(toLocal8Bit_helper(data1, length1), toLocal8Bit_helper(data2, length2));
5261  if (delta == 0)
5262  delta = ucstrcmp(data1, length1, data2, length2);
5263  return delta;
5264 #else
5265  return ucstrcmp(data1, length1, data2, length2);
5266 #endif
5267 }
const struct __CFString * CFStringRef
bool qt_ucol_strcoll(const QChar *source, int sourceLength, const QChar *target, int targetLength, int *result)
#define CSTR_GREATER_THAN
Definition: qstring.cpp:5181
static int ucstrcmp(const QChar *a, int alen, const QChar *b, int blen)
Definition: qstring.cpp:211
#define CSTR_LESS_THAN
Definition: qstring.cpp:5179

◆ mid()

QString QString::mid ( int  position,
int  n = -1 
) const

Returns a string that contains n characters of this string, starting at the specified position index.

Returns a null string if the position index exceeds the length of the string. If there are less than n characters available in the string starting at the given position, or if n is -1 (default), the function returns all characters that are available from the specified position.

Example:

QString x = "Nine pineapples";
QString y = x.mid(5, 4); // y == "pine"
QString z = x.mid(5); // z == "pineapples"
See also
left(), right()

Definition at line 3706 of file qstring.cpp.

Referenced by QLineEditPrivate::_q_completionHighlighted(), QScriptDebuggerLocalsWidgetPrivate::_q_insertCompletion(), QScriptDebuggerLocalsWidgetPrivate::_q_onCompletionTaskFinished(), QScriptDebuggerConsoleWidgetPrivate::_q_onCompletionTaskFinished(), _q_parseDosDir(), _q_parseUnixDir(), _q_resolveEntryAndCreateLegacyEngine_recursive(), QFileDialogPrivate::_q_updateOkButton(), QNSOpenSavePanelDelegate::acceptableExtensionsForSave, QFileSystemWatcher::addPaths(), QTextCodec::availableMibs(), QFileSystemEntry::baseName(), QFileDialogPrivate::basename(), QDeclarativeCompiler::buildDynamicMeta(), QDeclarativeEngineDebugService::buildObjectDump(), QMacSettingsPrivate::children(), comify(), QFileSystemEntry::completeBaseName(), QScriptCompletionTaskPrivate::completeScriptExpression(), QFileSystemEntry::completeSuffix(), QVNCScreen::connect(), QVFbScreen::connect(), QMultiScreen::connect(), QTransformedScreen::connect(), QLinuxFbIntegration::connect(), QPatternist::XsdInstanceReader::convertToQName(), QPatternist::XsdTypeChecker::convertToQName(), QTextCodecPlugin::create(), createImageNode(), QScriptDebuggerConsolePrivate::createJob(), QDeclarativeComponentPrivate::createObject(), customMimeType(), QKeySequencePrivate::decodeString(), QNativeWifiEngine::disconnectFromId(), QDeclarativeJS::TextWriter::doMove(), QDeclarativeXmlQueryEngine::doQueryJob(), QWindowsCEStyle::drawControl(), QWindowsVistaStyle::drawControl(), QPlastiqueStyle::drawControl(), QCleanlooksStyle::drawControl(), QWindowsXPStyle::drawControl(), QWindowsStyle::drawControl(), QGtkStyle::drawControl(), QMotifStyle::drawControl(), QMacStyle::drawControl(), QStyleSheetStyle::drawControl(), QItemDelegate::drawDisplay(), driveSpec(), QAxBase::dynamicCallHelper(), QFontMetrics::elidedText(), QFontMetricsF::elidedText(), QTextEngine::elidedText(), elliditide(), QResourcePrivate::ensureChildren(), QResourcePrivate::ensureInitialized(), QScriptDebuggerCodeView::event(), QDeclarativeScriptParser::extractMetaData(), QDeclarativeScriptParser::extractPragmas(), familyList(), fbname(), QFileSystemEntry::fileName(), fileName(), QFileSystemModelPrivate::filePath(), QDeclarativeImportedNamespace::find(), QResourceRoot::findNode(), QMacPasteboardMimeUnicodeText::flavorFor(), fontPath(), QPatternist::NamePool::fromClarkName(), QProcessEnvironmentPrivate::fromList(), QUrl::fromLocalFile(), QSslCertificate::fromPath(), QDate::fromString(), QTime::fromString(), QDateTime::fromString(), getFmtString(), QDeclarativeEnginePrivate::getImageFromProvider(), QDeclarativeEnginePrivate::getPixmapFromProvider(), getStringTok(), QImageReaderPrivate::getText(), getVariables(), hasValidSignal(), QCalendarDateSectionValidator::highlightString(), QUrl::host(), QSQLite2ResultPrivate::init(), QSvgSwitch::init(), QSymSQLResultPrivate::initColumns(), QAxBase::initializeRemote(), QDeclarativePropertyPrivate::initProperty(), QTextDocumentPrivate::insert_string(), QDeclarativeDebugServer::instance(), QAxServerBase::Invoke(), isParentDomain(), QUrl::isParentOf(), QDBusUtil::isValidUniqueConnectionName(), keyName(), launchWebBrowser(), QTextLine::layout_helper(), QPatternist::ProcessingInstructionConstructor::leftTrimmed(), QTranslator::load(), QAxServerBase::Load(), QLibraryInfo::location(), QLineControl::maskString(), Qt::mightBeRichText(), QMacPasteboardMimeAny::mimeFor(), QTextDocumentPrivate::move(), QWSServerPrivate::newMouseHandler(), QPatternist::XQueryTokenizer::nextToken(), QDeclarativeEngineDebugService::objectData(), QBBInputContext::onGetTextAfterCursor(), QBBInputContext::onGetTextBeforeCursor(), QScriptNewBreakpointWidget::onOkClicked(), QBBInputContext::onSetComposingRegion(), QIBaseDriver::open(), QSQLiteDriver::open(), QAudioDeviceInfoInternal::open(), QMYSQLDriver::open(), QWSServer::openKeyboard(), QDeclarativeDirParser::parse(), parseFontName(), QDateTimeParser::parseFormat(), parseIp6(), QHttpHeader::parseLine(), QHttpResponseHeader::parseLine(), QDateTimeParser::parseSection(), parseServerList(), QHostAddress::parseSubnet(), QFSCompleter::pathFromIndex(), QDeclarativeStringConverters::pointFFromString(), QSqlResult::prepare(), QCss::Scanner::preprocess(), QApplicationPrivate::process_cmdline(), QXmlNamespaceSupport::processName(), QPatternist::NamespaceSupport::processName(), QFtpPI::processReply(), QDeclarativeGridScaledImage::QDeclarativeGridScaledImage(), qExtractSecurityPolicyFromString(), qGetTableInfo(), QLinuxInputKeyboardHandler::QLinuxInputKeyboardHandler(), QLinuxInputMouseHandler::QLinuxInputMouseHandler(), QMacSettingsPrivate::QMacSettingsPrivate(), qParseOpts(), qSplitTableName(), QSslSocketBackendPrivate::QSslCipher_from_SSL_CIPHER(), qt_format_text(), qt_parsePrinterDesc(), qt_parsePrintersConf(), qt_parseQconfig(), qt_parseSpoolInterface(), qt_resource_fixResourceRoot(), qt_set_x11_resources(), qt_split_namespace(), qTextAfterOffsetFromString(), qTextAtOffsetFromString(), qTextBeforeOffsetFromString(), QTextHtmlImporter::QTextHtmlImporter(), QWinSettingsPrivate::QWinSettingsPrivate(), QWSKbPrivate::QWSKbPrivate(), QWSLinuxInputKbPrivate::QWSLinuxInputKbPrivate(), QWSLinuxInputMousePrivate::QWSLinuxInputMousePrivate(), QWSTtyKbPrivate::QWSTtyKbPrivate(), QTextStreamPrivate::read(), readSymLink(), QFtpPI::readyRead(), QPSQLDriver::record(), QDeclarativeStringConverters::rectFFromString(), QTextDocumentPrivate::remove_string(), QCoreApplication::removeLibraryPath(), QInternalMimeData::renderDataHelper(), QDeclarativeImportsPrivate::resolvedUri(), QAxServerBase::Save(), section(), QDateTimeParser::sectionText(), QLineControl::selectedText(), set_text(), QUrlPrivate::setAuthority(), QCalendarDateValidator::setFormat(), QUndoCommand::setText(), QUrl::setUrl(), simplified(), QDeclarativeStringConverters::sizeFFromString(), QFileSystemEngine::slowCanonicalized(), split(), QXmlNamespaceSupport::splitName(), QFSCompleter::splitPath(), QCompleter::splitPath(), splitSpaceSemicolon(), QSettingsPrivate::stringToVariant(), QPatternist::AbstractFloat< isDouble >::stringValue(), QSqlDriver::stripDelimitersImplementation(), QAbstractSpinBoxPrivate::stripped(), QDomCharacterDataPrivate::substringData(), QFileSystemEntry::suffix(), QPainter::testRenderHint(), QAudioDeviceInfoInternal::testSettings(), QClipboard::text(), QAccessibleLineEdit::text(), QLineControl::textAfterSelection(), textForRange(), QImage::textLanguages(), QImage::textList(), QFileDialogPrivate::toInternal(), QPatternist::XQueryTokenizer::tokenizeCharacterReference(), QPatternist::XQueryTokenizer::tokenizeNCName(), QPatternist::XQueryTokenizer::tokenizeNCNameOrQName(), QPatternist::XQueryTokenizer::tokenizeNumberLiteral(), QPatternist::Tokenizer::tokenToString(), QNetworkCookie::toRawForm(), QPatternist::Decimal::toString(), totalDigitsForDecimal(), totalDigitsForSignedLongLong(), QMenuPrivate::updateActionRects(), QAuthenticatorPrivate::updateCredentials(), QFileInfoGatherer::updateFile(), QDeclarativeStringConverters::vector3DFromString(), QCommonStylePrivate::viewItemDrawText(), QTextOdfWriter::writeBlock(), xdndObtainData(), and QDeclarativeInfo::~QDeclarativeInfo().

3707 {
3708  if (d == &shared_null || position >= d->size)
3709  return QString();
3710  if (n < 0)
3711  n = d->size - position;
3712  if (position < 0) {
3713  n += position;
3714  position = 0;
3715  }
3716  if (n + position > d->size)
3717  n = d->size - position;
3718  if (position == 0 && n == d->size)
3719  return *this;
3720  return QString((const QChar*) d->data + position, n);
3721 }
static qreal position(QGraphicsObject *item, QDeclarativeAnchorLine::AnchorLine anchorLine)
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
static Data shared_null
Definition: qstring.h:616
Data * d
Definition: qstring.h:618
ushort * data
Definition: qstring.h:606
QString()
Constructs a null string.
Definition: qstring.h:879

◆ midRef()

QStringRef QString::midRef ( int  position,
int  n = -1 
) const

Returns a substring reference to n characters of this string, starting at the specified position.

Since
4.4

If the position exceeds the length of the string, an empty reference is returned.

If there are less than n characters available in the string, starting at the given position, or if n is -1 (default), the function returns all characters from the specified position onwards.

Example:

QString x = "Nine pineapples";
QStringRef y = x.midRef(5, 4); // y == "pine"
QStringRef z = x.midRef(5); // z == "pineapples"
See also
mid(), leftRef(), rightRef()

Definition at line 9099 of file qstring.cpp.

Referenced by QSslSocketBackendPrivate::isMatchingHostname(), and parseServerList().

9100 {
9101  if (d == &shared_null || position >= d->size)
9102  return QStringRef();
9103  if (n < 0)
9104  n = d->size - position;
9105  if (position < 0) {
9106  n += position;
9107  position = 0;
9108  }
9109  if (n + position > d->size)
9110  n = d->size - position;
9111  return QStringRef(this, position, n);
9112 }
static qreal position(QGraphicsObject *item, QDeclarativeAnchorLine::AnchorLine anchorLine)
static Data shared_null
Definition: qstring.h:616
Data * d
Definition: qstring.h:618
friend class QStringRef
Definition: qstring.h:644

◆ multiArg()

QString QString::multiArg ( int  numArgs,
const QString **  args 
) const
private

Definition at line 7434 of file qstring.cpp.

Referenced by arg().

7435 {
7436  QString result;
7437  QMap<int, int> numbersUsed;
7438  const QChar *uc = (const QChar *) d->data;
7439  const int len = d->size;
7440  const int end = len - 1;
7441  int lastNumber = -1;
7442  int i = 0;
7443 
7444  // populate the numbersUsed map with the %n's that actually occur in the string
7445  while (i < end) {
7446  if (uc[i] == QLatin1Char('%')) {
7447  int number = getEscape(uc, &i, len);
7448  if (number != -1) {
7449  numbersUsed.insert(number, -1);
7450  continue;
7451  }
7452  }
7453  ++i;
7454  }
7455 
7456  // assign an argument number to each of the %n's
7457  QMap<int, int>::iterator j = numbersUsed.begin();
7458  QMap<int, int>::iterator jend = numbersUsed.end();
7459  int arg = 0;
7460  while (j != jend && arg < numArgs) {
7461  *j = arg++;
7462  lastNumber = j.key();
7463  ++j;
7464  }
7465 
7466  // sanity
7467  if (numArgs > arg) {
7468  qWarning("QString::arg: %d argument(s) missing in %s", numArgs - arg, toLocal8Bit().data());
7469  numArgs = arg;
7470  }
7471 
7472  i = 0;
7473  while (i < len) {
7474  if (uc[i] == QLatin1Char('%') && i != end) {
7475  int number = getEscape(uc, &i, len, lastNumber);
7476  int arg = numbersUsed[number];
7477  if (number != -1 && arg != -1) {
7478  result += *args[arg];
7479  continue;
7480  }
7481  }
7482  result += uc[i++];
7483  }
7484  return result;
7485 }
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qstring.cpp:6448
iterator end()
Returns an STL-style iterator pointing to the imaginary character after the last character in the str...
Definition: qstring.h:894
const Key key(const T &value) const
Returns the first key with value value.
Definition: qmap.h:844
The QString class provides a Unicode character string.
Definition: qstring.h:83
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
QChar * data()
Returns a pointer to the data stored in the QString.
Definition: qstring.h:710
Q_CORE_EXPORT void qWarning(const char *,...)
static int getEscape(const QChar *uc, int *pos, int len, int maxNumber=999)
Definition: qstring.cpp:7408
QByteArray toLocal8Bit() const Q_REQUIRED_RESULT
Returns the local 8-bit representation of the string as a QByteArray.
Definition: qstring.cpp:4049
Data * d
Definition: qstring.h:618
iterator begin()
Returns an STL-style iterator pointing to the first item in the map.
Definition: qmap.h:372
ushort * data
Definition: qstring.h:606
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
Definition: qstring.cpp:7186
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the map...
Definition: qmap.h:375
iterator insert(const Key &key, const T &value)
Inserts a new item with the key key and a value of value.
Definition: qmap.h:559
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ normalized() [1/2]

QString QString::normalized ( QString::NormalizationForm  mode) const

Returns the string in the given Unicode normalization mode.

Definition at line 6635 of file qstring.cpp.

Referenced by QMacPasteboardMimeFileUri::convertFromMime(), QMacPasteboardMimeUrl::convertFromMime(), QMacPasteboardMimeFileUri::convertToMime(), QMacPasteboardMimeUrl::convertToMime(), getFullPath(), locale_decode(), and locale_encode().

6636 {
6637  return normalized(mode, UNICODE_DATA_VERSION);
6638 }
#define UNICODE_DATA_VERSION
QString normalized(NormalizationForm mode) const Q_REQUIRED_RESULT
Returns the string in the given Unicode normalization mode.
Definition: qstring.cpp:6635

◆ normalized() [2/2]

QString QString::normalized ( QString::NormalizationForm  mode,
QChar::UnicodeVersion  version 
) const

Returns the string in the given Unicode normalization mode, according to the given version of the Unicode standard.

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

Definition at line 6703 of file qstring.cpp.

6704 {
6705  QString copy = *this;
6706  qt_string_normalize(&copy, mode, version, 0);
6707  return copy;
6708 }
The QString class provides a Unicode character string.
Definition: qstring.h:83
void qt_string_normalize(QString *data, QString::NormalizationForm mode, QChar::UnicodeVersion version, int from)
Definition: qstring.cpp:6710

◆ number() [1/7]

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

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

Definition at line 6448 of file qstring.cpp.

Referenced by QFileDialogPrivate::_q_createDirectory(), QFtpPrivate::_q_startNextCommand(), QNetworkManagerEngine::activationFinished(), QNetworkManagerEngine::activeConnectionPropertiesChanged(), QFontDatabasePrivate::addAppFont(), addressFromSockaddr(), QConnmanEngine::addServiceConfiguration(), QDeclarativeParser::Variant::asScript(), QAccessibleTextWidget::attributes(), QUrlPrivate::authority(), breakpointMapToScriptValue(), QPatternist::XsdTypeChecker::checkConstrainingFacetsSignedInteger(), QPatternist::XsdTypeChecker::checkConstrainingFacetsUnsignedInteger(), QCoreApplicationPrivate::checkReceiverThread(), classIDL(), QGraphicsWidget::close(), QPdfBaseEnginePrivate::closePrintDevice(), QDeclarativeStateGroup::componentComplete(), QNetworkManagerEngine::connectionFromId(), QFtp::connectToHost(), QCoreWlanEngine::connectToId(), QDeclarativeBindingCompilerPrivate::contextName(), convert(), QWindowsMimeHtml::convertFromMime(), QAxServerBase::create(), QPatternist::AbstractDateTime::create(), QDeclarativeEnginePrivate::createCache(), QUrlPrivate::createErrorString(), createForMib(), decodeMSG(), QPatternist::Expression::description(), QNetworkManagerEngine::disconnectFromId(), QPatternist::Cardinality::displayName(), QGenericEngine::doRequestUpdate(), QMacStylePrivate::drawColorlessButton(), QGtkStyle::drawComplexControl(), QPlastiqueStyle::drawControl(), QCleanlooksStyle::drawControl(), QGtkStyle::drawPrimitive(), QDeclarativeCompiledData::dump(), QGridLayoutEngine::dump(), QPatternist::XsdSchemaDebugger::dumpParticle(), QTextHtmlExporter::emitBlock(), QTextHtmlExporter::emitBlockAttributes(), QTextHtmlExporter::emitCharFormatStyle(), QTextHtmlExporter::emitFragment(), QTextHtmlExporter::emitFrameStyle(), QTextHtmlExporter::emitTable(), QTextHtmlExporter::emitTextFrame(), QTextHtmlExporter::emitTextLength(), encodeText(), QtopiaPrintEngine::end(), QDeclarativeComponent::errorString(), QEgl::errorString(), QPatternist::GenerateIDFN::evaluateSingleton(), QPatternist::CodepointsToStringFN::evaluateSingleton(), QScriptEdit::extraAreaPaintEvent(), QWSSoundServerPrivate::feedDevice(), QXmlStreamWriterPrivate::findNamespace(), QPatternist::formatData(), QTest::formatResult(), QDB2Driver::formatValue(), QSqlDriver::formatValue(), QIBaseDriver::formatValue(), QOCIDriver::formatValue(), QODBCDriver::formatValue(), QPSQLDriver::formatValue(), QPatternist::HexBinary::fromLexical(), QHostInfoAgent::fromName(), QDeclarativeRectangle::generateBorderedRect(), QDeclarativeRectangle::generateRoundedRect(), getFmtString(), QNetworkManagerEngine::getInterfaceFromId(), QScanThread::getSsidFromNetworkName(), QGestureManager::getState(), getValue(), QPatternist::ColoringMessageHandler::handleMessage(), QNetworkManagerEngine::hasIdentifier(), QTreeModel::headerData(), QColorDialogPrivate::init(), QTreeModel::insertColumns(), QTextCursor::insertImage(), QNetworkManagerEngine::interfacePropertiesChanged(), QLibraryPrivate::isPlugin(), QTextList::itemText(), QTextCodecPlugin::keys(), loadSingleEngine(), QScriptDebuggerConsoleWidget::message(), QScriptDebugOutputWidget::message(), QScriptStdMessageHandler::message(), QProgressBar::minimumSizeHint(), QCalendarWidget::minimumSizeHint(), multiArg(), QNetworkManagerEngine::newAccessPoint(), QDeclarativeJS::numberToString(), object_name_for_button(), QDB2Driver::open(), QPSQLDriver::open(), QDebug::operator<<(), QSqlRelationalTableModel::orderByClause(), QStaticTextPrivate::paintText(), QNetworkManagerEngine::parseConnection(), QNlaThread::parseQuerySet(), pixelToPoint(), QSvgIconEnginePrivate::pmcKey(), QNetworkDiskCachePrivate::prepareLayout(), QDB2Driver::primaryIndex(), QODBCDriver::primaryIndex(), printPage(), QPatternist::AccelTree::printStats(), QFtp::put(), qDBusNewConnection(), QFontEngineQPF::QFontEngineQPF(), QSvgPaintEngine::qfontToSvg(), qMakePreparedStmtId(), QSvgPaintEngine::qpenToSvg(), qReplacePlaceholderMarkers(), QScriptDebuggerBackendPrivate::qsassert(), qt_create_internal_window(), qt_mac_constructQIconFromIconRef(), qt_reg_winclass(), qt_socket_getPortAndAddress(), QDB2Driver::record(), QODBCDriver::record(), registerFont(), QNetworkManagerEngine::removeAccessPoint(), QNetworkManagerEngine::removeConnection(), resolveGdi32(), QPatternist::SystemPropertyFN::retrieveProperty(), QDoubleSpinBoxPrivate::round(), QScanThread::run(), runningUnderDebugger(), QNativeWifiEngine::scanComplete(), scriptMapToScriptValue(), QDateTimeParser::sectionName(), QWSSoundServerClient::sendDeviceError(), QWSSoundServerClient::sendDeviceReady(), QWSSoundServerClient::sendSoundCompleted(), QConnmanEngine::serviceFromId(), QConnmanEngine::servicePropertyChangedContext(), QNetworkManagerEngine::sessionStateForId(), QNetworkDiskCache::setCacheDirectory(), QTreeModel::setColumnCount(), QHttpHeader::setContentLength(), QLibrary::setFileNameAndVersion(), QFtp::setProxy(), QIBaseResult::size(), sm_performSaveYourself(), QHttpPGHRequest::start(), QFtpPI::startNextCmd(), QCoreWlanEngine::startTime(), QDateTimeParser::stateName(), QPatternist::YearMonthDuration::stringValue(), QPatternist::Duration::stringValue(), QPatternist::Integer::stringValue(), QPatternist::DayTimeDuration::stringValue(), QPatternist::AbstractFloat< isDouble >::stringValue(), QPatternist::DerivedInteger< DerivedType >::stringValue(), QDB2Driver::tables(), QODBCDriver::tables(), QCalendarDayValidator::text(), QAccessibleDisplay::text(), QAccessibleItemRow::text(), QAccessibleScrollBar::text(), QAccessibleSlider::text(), QAccessibleDial::text(), QCalendarMonthValidator::text(), QCalendarYearValidator::text(), QUrlPrivate::toEncoded(), QTextHtmlExporter::toHtml(), QDeclarativeError::toString(), QScriptContext::toString(), QEglProperties::toString(), QDate::toString(), QScriptDebuggerValue::toString(), QTest::toString(), QSettingsGroup::toString(), QPatternist::Decimal::toString(), QDeclarativeObjectScriptClass::tostring(), QDateTime::toString(), QFont::toString(), toString(), totalDigitsForSignedLongLong(), totalDigitsForUnsignedLongLong(), translate_color(), QNetworkDiskCachePrivate::uniqueFileName(), QNetworkManagerEngine::updateAccessPoint(), QPrintPreviewDialogPrivate::updateNavActions(), QCalendarWidgetPrivate::updateNavigationBar(), QPrintPreviewDialogPrivate::updatePageNumLabel(), UpdateRegistry(), QFontDialogPrivate::updateSizes(), variantToString(), QSettingsPrivate::variantToString(), WinMain(), QTextOdfWriter::writeBlock(), QTextOdfWriter::writeCharacterFormat(), QTextOdfWriter::writeFrame(), QTextOdfWriter::writeListFormat(), QX11EmbedWidget::x11Event(), QPatternist::AbstractDateTime::zoneOffsetToString(), QColorDialog::~QColorDialog(), QDB2Result::~QDB2Result(), QEventDispatcherWin32Private::~QEventDispatcherWin32Private(), and QODBCResult::~QODBCResult().

6449 {
6450  QString s;
6451  s.setNum(n, base);
6452  return s;
6453 }
The QString class provides a Unicode character string.
Definition: qstring.h:83
static const uint base
Definition: qurl.cpp:268
QString & setNum(short, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qstring.h:729

◆ number() [2/7]

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

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

Definition at line 6458 of file qstring.cpp.

6459 {
6460  QString s;
6461  s.setNum(n, base);
6462  return s;
6463 }
The QString class provides a Unicode character string.
Definition: qstring.h:83
static const uint base
Definition: qurl.cpp:268
QString & setNum(short, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qstring.h:729

◆ number() [3/7]

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

Returns a string equivalent of the number n according to the specified base.

The base is 10 by default and must be between 2 and 36. For bases other than 10, n is treated as an unsigned integer.

long a = 63;
QString s = QString::number(a, 16); // s == "3f"
QString t = QString::number(a, 16).toUpper(); // t == "3F"
See also
setNum()

Definition at line 6426 of file qstring.cpp.

6427 {
6428  QString s;
6429  s.setNum(n, base);
6430  return s;
6431 }
The QString class provides a Unicode character string.
Definition: qstring.h:83
static const uint base
Definition: qurl.cpp:268
QString & setNum(short, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qstring.h:729

◆ number() [4/7]

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

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

Definition at line 6438 of file qstring.cpp.

6439 {
6440  QString s;
6441  s.setNum(n, base);
6442  return s;
6443 }
The QString class provides a Unicode character string.
Definition: qstring.h:83
static const uint base
Definition: qurl.cpp:268
QString & setNum(short, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qstring.h:729

◆ number() [5/7]

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

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

Definition at line 6468 of file qstring.cpp.

6469 {
6470  QString s;
6471  s.setNum(n, base);
6472  return s;
6473 }
The QString class provides a Unicode character string.
Definition: qstring.h:83
static const uint base
Definition: qurl.cpp:268
QString & setNum(short, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qstring.h:729

◆ number() [6/7]

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

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

Definition at line 6478 of file qstring.cpp.

6479 {
6480  QString s;
6481  s.setNum(n, base);
6482  return s;
6483 }
The QString class provides a Unicode character string.
Definition: qstring.h:83
static const uint base
Definition: qurl.cpp:268
QString & setNum(short, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qstring.h:729

◆ number() [7/7]

QString QString::number ( double  n,
char  format = 'g',
int  precision = 6 
)
static

Returns a string equivalent of the number n, formatted according to the specified format and precision.

See Argument Formats for details.

Unlike QLocale::toString(), this function does not honor the user's locale settings.

See also
setNum(), QLocale::toString()

Definition at line 6501 of file qstring.cpp.

6502 {
6503  QString s;
6504  s.setNum(n, f, prec);
6505  return s;
6506 }
The QString class provides a Unicode character string.
Definition: qstring.h:83
QString & setNum(short, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qstring.h:729

◆ operator!=() [1/4]

bool QString::operator!= ( const QString other) const
inline

Returns true if this string is not equal to string other; otherwise returns false.

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 localeAwareCompare().

Definition at line 406 of file qstring.h.

406 { return !operator==(s); }
bool operator==(const QString &s) const
Returns true if string other is equal to this string; otherwise returns false.
Definition: qstring.cpp:2368

◆ operator!=() [2/4]

bool QString::operator!= ( const QLatin1String s) const
inline

Definition at line 413 of file qstring.h.

413 { return !operator==(s); }
bool operator==(const QString &s) const
Returns true if string other is equal to this string; otherwise returns false.
Definition: qstring.cpp:2368

◆ operator!=() [3/4]

bool QString::operator!= ( const char *  s) const
inline

Definition at line 925 of file qstring.h.

926 { return !qStringComparisonHelper(*this, s); }
friend bool qStringComparisonHelper(const QString &s1, const char *s2)
Definition: qstring.h:916

◆ operator!=() [4/4]

bool QString::operator!= ( const QByteArray s) const
inline

Definition at line 978 of file qstring.h.

979 { return !qStringComparisonHelper(*this, s.constData()); }
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
friend bool qStringComparisonHelper(const QString &s1, const char *s2)
Definition: qstring.h:916

◆ operator+=() [1/8]

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

Definition at line 265 of file qstring.h.

Referenced by QByteArray::operator+=().

265  {
266  if (d->ref != 1 || d->size + 1 > d->alloc)
267  realloc(grow(d->size + 1));
268  d->data[d->size++] = c.unicode();
269  d->data[d->size] = '\0';
270  return *this;
271  }
void realloc()
Definition: qstring.cpp:1472
ushort unicode() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qchar.h:251
QBasicAtomicInt ref
Definition: qstring.h:604
Data * d
Definition: qstring.h:618
ushort * data
Definition: qstring.h:606
static int grow(int)
Definition: qstring.cpp:822

◆ operator+=() [2/8]

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

Definition at line 273 of file qstring.h.

273 { return append(QChar(c)); }
unsigned char c[8]
Definition: qnumeric_p.h:62
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
QString & append(QChar c)
Definition: qstring.cpp:1777

◆ operator+=() [3/8]

QString & QString::operator+= ( const QString other)
inline

Appends the string other onto the end of this string and returns a reference to this string.

Example:

QString x = "free";
QString y = "dom";
x += y;
// x == "freedom"

This operation is typically very fast (constant time), because QString preallocates extra space at the end of the string data so it can grow without reallocating the entire string each time.

See also
append(), prepend()

Definition at line 274 of file qstring.h.

274 { return append(s); }
QString & append(QChar c)
Definition: qstring.cpp:1777

◆ operator+=() [4/8]

QString& QString::operator+= ( const QStringRef s)
inline

Definition at line 275 of file qstring.h.

275 { return append(s); }
QString & append(QChar c)
Definition: qstring.cpp:1777

◆ operator+=() [5/8]

QString& QString::operator+= ( const QLatin1String s)
inline

Definition at line 276 of file qstring.h.

276 { return append(s); }
QString & append(QChar c)
Definition: qstring.cpp:1777

◆ operator+=() [6/8]

QT_ASCII_CAST_WARN QString& QString::operator+= ( const char *  s)
inline

Definition at line 440 of file qstring.h.

441  { return append(QString::fromAscii(s)); }
static QString fromAscii(const char *, int size=-1)
Returns a QString initialized with the first size characters from the string str. ...
Definition: qstring.cpp:4276
QString & append(QChar c)
Definition: qstring.cpp:1777

◆ operator+=() [7/8]

QT_ASCII_CAST_WARN QString& QString::operator+= ( const QByteArray s)
inline

Definition at line 442 of file qstring.h.

443  { return append(QString::fromAscii(s.constData(), qstrnlen(s.constData(), s.size()))); }
static QString fromAscii(const char *, int size=-1)
Returns a QString initialized with the first size characters from the string str. ...
Definition: qstring.cpp:4276
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
QString & append(QChar c)
Definition: qstring.cpp:1777
uint qstrnlen(const char *str, uint maxlen)
Definition: qbytearray.h:82
int size() const
Returns the number of bytes in this byte array.
Definition: qbytearray.h:402

◆ operator+=() [8/8]

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

Definition at line 444 of file qstring.h.

445  { return append(QChar::fromAscii(c)); }
unsigned char c[8]
Definition: qnumeric_p.h:62
QString & append(QChar c)
Definition: qstring.cpp:1777
static QChar fromAscii(char c)
Converts the ASCII character c to its equivalent QChar.
Definition: qchar.cpp:1521

◆ operator<() [1/4]

bool QString::operator< ( const QString other) const

Returns true if this string is lexically less than string other; otherwise returns false.

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 using the QString::localeAwareCompare() function.

Definition at line 2436 of file qstring.cpp.

2437 {
2438  return ucstrcmp(constData(), length(), other.constData(), other.length()) < 0;
2439 }
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
static int ucstrcmp(const QChar *a, int alen, const QChar *b, int blen)
Definition: qstring.cpp:211
const QChar * constData() const
Returns a pointer to the data stored in the QString.
Definition: qstring.h:712

◆ operator<() [2/4]

bool QString::operator< ( const QLatin1String s) const

Definition at line 2444 of file qstring.cpp.

2445 {
2446  const ushort *uc = d->data;
2447  const ushort *e = uc + d->size;
2448  const uchar *c = (uchar *) other.latin1();
2449 
2450  if (!c || *c == 0)
2451  return false;
2452 
2453  while (*c) {
2454  if (uc == e || *uc != *c)
2455  break;
2456  ++uc;
2457  ++c;
2458  }
2459  return (uc == e ? *c : *uc < *c);
2460 }
unsigned char c[8]
Definition: qnumeric_p.h:62
unsigned char uchar
Definition: qglobal.h:994
Data * d
Definition: qstring.h:618
ushort * data
Definition: qstring.h:606
unsigned short ushort
Definition: qglobal.h:995

◆ operator<() [3/4]

bool QString::operator< ( const char *  s) const
inline

Definition at line 927 of file qstring.h.

928 { return *this < QString::fromAscii(s); }
static QString fromAscii(const char *, int size=-1)
Returns a QString initialized with the first size characters from the string str. ...
Definition: qstring.cpp:4276

◆ operator<() [4/4]

QT_ASCII_CAST_WARN bool QString::operator< ( const QByteArray s) const
inline

Definition at line 456 of file qstring.h.

457  { return *this < QString::fromAscii(s.constData(), s.size()); }
static QString fromAscii(const char *, int size=-1)
Returns a QString initialized with the first size characters from the string str. ...
Definition: qstring.cpp:4276
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
int size() const
Returns the number of bytes in this byte array.
Definition: qbytearray.h:402

◆ operator<=() [1/4]

bool QString::operator<= ( const QString other) const
inline

Returns true if this string is lexically less than or equal to string other; otherwise returns false.

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 localeAwareCompare().

Definition at line 407 of file qstring.h.

407 { return !operator>(s); }
bool operator>(const QString &s) const
Returns true if this string is lexically greater than string other; otherwise returns false...
Definition: qstring.h:405

◆ operator<=() [2/4]

bool QString::operator<= ( const QLatin1String s) const
inline

Definition at line 414 of file qstring.h.

414 { return !operator>(s); }
bool operator>(const QString &s) const
Returns true if this string is lexically greater than string other; otherwise returns false...
Definition: qstring.h:405

◆ operator<=() [3/4]

bool QString::operator<= ( const char *  s2) const
inline

Definition at line 931 of file qstring.h.

932 { return *this <= QString::fromAscii(s); }
static QString fromAscii(const char *, int size=-1)
Returns a QString initialized with the first size characters from the string str. ...
Definition: qstring.cpp:4276

◆ operator<=() [4/4]

QT_ASCII_CAST_WARN bool QString::operator<= ( const QByteArray s) const
inline

Definition at line 460 of file qstring.h.

461  { return *this <= QString::fromAscii(s.constData(), s.size()); }
static QString fromAscii(const char *, int size=-1)
Returns a QString initialized with the first size characters from the string str. ...
Definition: qstring.cpp:4276
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
int size() const
Returns the number of bytes in this byte array.
Definition: qbytearray.h:402

◆ operator=() [1/7]

QString & QString::operator= ( QChar  c)

◆ operator=() [2/7]

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

Assigns other to this string and returns a reference to this string.

Definition at line 1508 of file qstring.cpp.

1509 {
1510  other.d->ref.ref();
1511  if (!d->ref.deref())
1512  QString::free(d);
1513  d = other.d;
1514  return *this;
1515 }
QBasicAtomicInt ref
Definition: qstring.h:604
static void free(Data *)
Definition: qstring.cpp:1311
Data * d
Definition: qstring.h:618

◆ operator=() [3/7]

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

Definition at line 718 of file qstring.h.

719 {
720  *this = fromLatin1(s.latin1());
721  return *this;
722 }
const char * latin1() const
Returns the Latin-1 string stored in this object.
Definition: qstring.h:661
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188

◆ operator=() [4/7]

QT_ASCII_CAST_WARN QString& QString::operator= ( const char *  ch)
inline

Definition at line 424 of file qstring.h.

425  { return (*this = fromAscii(ch)); }
static QString fromAscii(const char *, int size=-1)
Returns a QString initialized with the first size characters from the string str. ...
Definition: qstring.cpp:4276

◆ operator=() [5/7]

QT_ASCII_CAST_WARN QString& QString::operator= ( const QByteArray a)
inline

Definition at line 426 of file qstring.h.

427  { return (*this = fromAscii(a.constData(), qstrnlen(a.constData(), a.size()))); }
static QString fromAscii(const char *, int size=-1)
Returns a QString initialized with the first size characters from the string str. ...
Definition: qstring.cpp:4276
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
uint qstrnlen(const char *str, uint maxlen)
Definition: qbytearray.h:82
int size() const
Returns the number of bytes in this byte array.
Definition: qbytearray.h:402

◆ operator=() [6/7]

QT_ASCII_CAST_WARN QString& QString::operator= ( char  c)
inline

Definition at line 428 of file qstring.h.

429  { return (*this = QChar::fromAscii(c)); }
unsigned char c[8]
Definition: qnumeric_p.h:62
static QChar fromAscii(char c)
Converts the ASCII character c to its equivalent QChar.
Definition: qchar.cpp:1521

◆ operator=() [7/7]

QString & QString::operator= ( const Null )
inline
Warning
This function is not part of the public interface.

Definition at line 504 of file qstring.h.

504 { *this = QString(); return *this; }
QString()
Constructs a null string.
Definition: qstring.h:879

◆ operator==() [1/4]

bool QString::operator== ( const QString other) const

Returns true if string other is equal to this string; otherwise returns false.

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 localeAwareCompare().

Definition at line 2368 of file qstring.cpp.

2369 {
2370  if (d->size != other.d->size)
2371  return false;
2372 
2373  return qMemEquals(d->data, other.d->data, d->size);
2374 }
static bool qMemEquals(const quint16 *a, const quint16 *b, int length)
Definition: qstring.cpp:273
Data * d
Definition: qstring.h:618
ushort * data
Definition: qstring.h:606

◆ operator==() [2/4]

bool QString::operator== ( const QLatin1String s) const

Definition at line 2379 of file qstring.cpp.

2380 {
2381  const ushort *uc = d->data;
2382  const ushort *e = uc + d->size;
2383  const uchar *c = (uchar *)other.latin1();
2384 
2385  if (!c)
2386  return isEmpty();
2387 
2388  while (*c) {
2389  if (uc == e || *uc != *c)
2390  return false;
2391  ++uc;
2392  ++c;
2393  }
2394  return (uc == e);
2395 }
unsigned char c[8]
Definition: qnumeric_p.h:62
unsigned char uchar
Definition: qglobal.h:994
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
Data * d
Definition: qstring.h:618
ushort * data
Definition: qstring.h:606
unsigned short ushort
Definition: qglobal.h:995

◆ operator==() [3/4]

bool QString::operator== ( const char *  s) const
inline

Definition at line 923 of file qstring.h.

924 { return qStringComparisonHelper(*this, s); }
friend bool qStringComparisonHelper(const QString &s1, const char *s2)
Definition: qstring.h:916

◆ operator==() [4/4]

bool QString::operator== ( const QByteArray s) const
inline

Definition at line 976 of file qstring.h.

977 { return qStringComparisonHelper(*this, s.constData()); }
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
friend bool qStringComparisonHelper(const QString &s1, const char *s2)
Definition: qstring.h:916

◆ operator>() [1/4]

bool QString::operator> ( const QString other) const
inline

Returns true if this string is lexically greater than string other; otherwise returns false.

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 localeAwareCompare().

Definition at line 405 of file qstring.h.

405 { return s < *this; }

◆ operator>() [2/4]

bool QString::operator> ( const QLatin1String s) const

Definition at line 2558 of file qstring.cpp.

2559 {
2560  const ushort *uc = d->data;;
2561  const ushort *e = uc + d->size;
2562  const uchar *c = (uchar *) other.latin1();
2563 
2564  if (!c || *c == '\0')
2565  return !isEmpty();
2566 
2567  while (*c) {
2568  if (uc == e || *uc != *c)
2569  break;
2570  ++uc;
2571  ++c;
2572  }
2573  return (uc == e ? false : *uc > *c);
2574 }
unsigned char c[8]
Definition: qnumeric_p.h:62
unsigned char uchar
Definition: qglobal.h:994
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
Data * d
Definition: qstring.h:618
ushort * data
Definition: qstring.h:606
unsigned short ushort
Definition: qglobal.h:995

◆ operator>() [3/4]

bool QString::operator> ( const char *  s2) const
inline

Definition at line 929 of file qstring.h.

930 { return *this > QString::fromAscii(s); }
static QString fromAscii(const char *, int size=-1)
Returns a QString initialized with the first size characters from the string str. ...
Definition: qstring.cpp:4276

◆ operator>() [4/4]

QT_ASCII_CAST_WARN bool QString::operator> ( const QByteArray s) const
inline

Definition at line 458 of file qstring.h.

459  { return *this > QString::fromAscii(s.constData(), s.size()); }
static QString fromAscii(const char *, int size=-1)
Returns a QString initialized with the first size characters from the string str. ...
Definition: qstring.cpp:4276
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
int size() const
Returns the number of bytes in this byte array.
Definition: qbytearray.h:402

◆ operator>=() [1/4]

bool QString::operator>= ( const QString other) const
inline

Returns true if this string is lexically greater than or equal to string other; otherwise returns false.

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 localeAwareCompare().

Definition at line 408 of file qstring.h.

408 { return !operator<(s); }
bool operator<(const QString &s) const
Returns true if this string is lexically less than string other; otherwise returns false...
Definition: qstring.cpp:2436

◆ operator>=() [2/4]

bool QString::operator>= ( const QLatin1String s) const
inline

Definition at line 415 of file qstring.h.

415 { return !operator<(s); }
bool operator<(const QString &s) const
Returns true if this string is lexically less than string other; otherwise returns false...
Definition: qstring.cpp:2436

◆ operator>=() [3/4]

bool QString::operator>= ( const char *  s2) const
inline

Definition at line 933 of file qstring.h.

934 { return *this >= QString::fromAscii(s); }
static QString fromAscii(const char *, int size=-1)
Returns a QString initialized with the first size characters from the string str. ...
Definition: qstring.cpp:4276

◆ operator>=() [4/4]

QT_ASCII_CAST_WARN bool QString::operator>= ( const QByteArray s) const
inline

Definition at line 462 of file qstring.h.

463  { return *this >= QString::fromAscii(s.constData(), s.size()); }
static QString fromAscii(const char *, int size=-1)
Returns a QString initialized with the first size characters from the string str. ...
Definition: qstring.cpp:4276
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
int size() const
Returns the number of bytes in this byte array.
Definition: qbytearray.h:402

◆ operator[]() [1/4]

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

Definition at line 700 of file qstring.h.

701 { Q_ASSERT(uint(i) < uint(size())); return d->data[i]; }
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
int size() const
Returns the number of characters in this string.
Definition: qstring.h:102
unsigned int uint
Definition: qglobal.h:996
Data * d
Definition: qstring.h:618
ushort * data
Definition: qstring.h:606

◆ operator[]() [2/4]

QCharRef QString::operator[] ( int  position)
inline

Returns the character at the specified position in the string as a modifiable reference.

Example:

QString str;
if (str[0] == QChar('?'))
str[0] = QChar('_');

The return value is of type QCharRef, a helper class for QString. When you get an object of type QCharRef, you can use it as if it were a QChar &. If you assign to it, the assignment will apply to the character in the QString from which you got the reference.

See also
at()

Definition at line 884 of file qstring.h.

885 { Q_ASSERT(i >= 0); return QCharRef(*this, i); }
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
friend class QCharRef
Definition: qstring.h:641

◆ operator[]() [3/4]

const QChar QString::operator[] ( uint  i) const
inline

Definition at line 702 of file qstring.h.

703 { Q_ASSERT(i < uint(size())); return d->data[i]; }
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
int size() const
Returns the number of characters in this string.
Definition: qstring.h:102
unsigned int uint
Definition: qglobal.h:996
Data * d
Definition: qstring.h:618
ushort * data
Definition: qstring.h:606

◆ operator[]() [4/4]

QCharRef QString::operator[] ( uint  i)
inline

Definition at line 886 of file qstring.h.

887 { return QCharRef(*this, i); }
friend class QCharRef
Definition: qstring.h:641

◆ prepend() [1/5]

QString& QString::prepend ( QChar  c)
inline

Definition at line 261 of file qstring.h.

Referenced by _q_escapeIdentifier(), QSettingsPrivate::actualKey(), QCoreApplication::addLibraryPath(), QPSQLDriverPrivate::appendTables(), QCoreApplication::applicationDirPath(), QCoreApplication::arguments(), QTransformedScreen::connect(), QMacPasteboardMimeVCard::convertFromMime(), QAbstractFileEngineIterator::currentFilePath(), QScriptDebuggerLocalsModel::data(), decimalForm(), QLocalePrivate::doubleToString(), QResourcePrivate::ensureInitialized(), QDB2Driver::escapeIdentifier(), QIBaseDriver::escapeIdentifier(), QOCIDriver::escapeIdentifier(), QSQLite2Driver::escapeIdentifier(), QTDSDriver::escapeIdentifier(), QMYSQLDriver::escapeIdentifier(), QPSQLDriver::escapeIdentifier(), QODBCDriver::escapeIdentifier(), QTDSDriver::formatValue(), QNetworkAccessFtpBackend::ftpDone(), getFmtString(), getImage(), QFileSystemEngine::getLinkTarget(), getPixmap(), QFileIconProviderPrivate::getWinIcon(), QTextControl::insertFromMimeData(), QTextList::itemText(), QMessageBox::keyPressEvent(), QFSFileEnginePrivate::longFileName(), QLocalePrivate::longLongToString(), operator+(), parseCSStoXMLAttrs(), parseStopNode(), QTextHtmlParserNode::parseStyleAttribute(), QCss::Parser::parseTerm(), QProcessPrivate::pipeWriterBytesToWrite(), QTextStreamPrivate::putNumber(), QTextStreamPrivate::putString(), qDBusGenerateMetaObjectXml(), qDBusInterfaceFromMetaObject(), QFontEngineQPF::QFontEngineQPF(), QMacSettingsPrivate::QMacSettingsPrivate(), qQuote(), qt_create_commandline(), QTextHtmlImporter::QTextHtmlImporter(), qTopLevelDomain(), QFactoryLoader::refreshAll(), QSettings::remove(), QCoreApplication::removeLibraryPath(), section(), QSqlRelationalTableModel::selectStatement(), QSqlDriver::sqlStatement(), QIBaseDriver::tables(), QTextStreamPrivate::ungetChar(), QLocalePrivate::unsLongLongToString(), QSpinBoxValidator::validate(), QSettingsPrivate::variantToString(), QTextOdfWriter::writeInlineCharacter(), and QDeclarativeInfo::~QDeclarativeInfo().

261 { return insert(0, c); }
QString & insert(int i, QChar c)
Definition: qstring.cpp:1671

◆ prepend() [2/5]

QString & QString::prepend ( const QString str)
inline

Prepends the string str to the beginning of this string and returns a reference to this string.

Example:

QString x = "ship";
QString y = "air";
x.prepend(y);
// x == "airship"
See also
append(), insert()

Definition at line 262 of file qstring.h.

262 { return insert(0, s); }
QString & insert(int i, QChar c)
Definition: qstring.cpp:1671

◆ prepend() [3/5]

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

Definition at line 263 of file qstring.h.

263 { return insert(0, s); }
QString & insert(int i, QChar c)
Definition: qstring.cpp:1671

◆ prepend() [4/5]

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

Definition at line 432 of file qstring.h.

433  { return prepend(QString::fromAscii(s)); }
static QString fromAscii(const char *, int size=-1)
Returns a QString initialized with the first size characters from the string str. ...
Definition: qstring.cpp:4276
QString & prepend(QChar c)
Definition: qstring.h:261

◆ prepend() [5/5]

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

Definition at line 434 of file qstring.h.

435  { return prepend(QString::fromAscii(s.constData(), qstrnlen(s.constData(), s.size()))); }
static QString fromAscii(const char *, int size=-1)
Returns a QString initialized with the first size characters from the string str. ...
Definition: qstring.cpp:4276
QString & prepend(QChar c)
Definition: qstring.h:261
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
uint qstrnlen(const char *str, uint maxlen)
Definition: qbytearray.h:82
int size() const
Returns the number of bytes in this byte array.
Definition: qbytearray.h:402

◆ push_back() [1/2]

void QString::push_back ( QChar  ch)
inline

Appends the given ch character onto the end of this string.

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

Definition at line 481 of file qstring.h.

481 { append(c); }
unsigned char c[8]
Definition: qnumeric_p.h:62
QString & append(QChar c)
Definition: qstring.cpp:1777

◆ push_back() [2/2]

void QString::push_back ( const QString other)
inline

This function is provided for STL compatibility, appending the given other string onto the end of this string.

It is equivalent to append(other).

See also
append()

Definition at line 482 of file qstring.h.

482 { append(s); }
QString & append(QChar c)
Definition: qstring.cpp:1777

◆ push_front() [1/2]

void QString::push_front ( QChar  ch)
inline

Prepends the given ch character to the beginning of this string.

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

Definition at line 483 of file qstring.h.

483 { prepend(c); }
unsigned char c[8]
Definition: qnumeric_p.h:62
QString & prepend(QChar c)
Definition: qstring.h:261

◆ push_front() [2/2]

void QString::push_front ( const QString other)
inline

This function is provided for STL compatibility, prepending the given other string to the beginning of this string.

It is equivalent to prepend(other).

See also
prepend()

Definition at line 484 of file qstring.h.

484 { prepend(s); }
QString & prepend(QChar c)
Definition: qstring.h:261

◆ realloc() [1/2]

void QString::realloc ( )
private

Definition at line 1472 of file qstring.cpp.

Referenced by append(), detach(), replace(), reserve(), resize(), and utf16().

1473 {
1474  realloc(d->size);
1475 }
void realloc()
Definition: qstring.cpp:1472
Data * d
Definition: qstring.h:618

◆ realloc() [2/2]

void QString::realloc ( int  alloc)
private

Definition at line 1437 of file qstring.cpp.

1438 {
1439  if (d->ref != 1 || d->data != d->array) {
1440  Data *x = static_cast<Data *>(qMalloc(sizeof(Data) + alloc * sizeof(QChar)));
1441  Q_CHECK_PTR(x);
1442  x->size = qMin(alloc, d->size);
1443  ::memcpy(x->array, d->data, x->size * sizeof(QChar));
1444  x->array[x->size] = 0;
1445  x->asciiCache = 0;
1446  x->ref = 1;
1447  x->alloc = alloc;
1448  x->clean = d->clean;
1449  x->simpletext = d->simpletext;
1450  x->righttoleft = d->righttoleft;
1451  x->capacity = d->capacity;
1452  x->data = x->array;
1453  if (!d->ref.deref())
1454  QString::free(d);
1455  d = x;
1456  } else {
1457 #ifdef QT3_SUPPORT
1458  if (d->asciiCache) {
1459  QMutexLocker locker(asciiCacheMutex());
1460  Q_ASSERT(asciiCache);
1461  asciiCache->remove(d);
1462  }
1463 #endif
1464  Data *p = static_cast<Data *>(qRealloc(d, sizeof(Data) + alloc * sizeof(QChar)));
1465  Q_CHECK_PTR(p);
1466  d = p;
1467  d->alloc = alloc;
1468  d->data = d->array;
1469  }
1470 }
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
ushort capacity
Definition: qstring.h:611
ushort clean
Definition: qstring.h:607
Q_CORE_EXPORT void * qMalloc(size_t size)
Definition: qmalloc.cpp:53
Q_CORE_EXPORT void * qRealloc(void *ptr, size_t size)
Definition: qmalloc.cpp:63
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
QBasicAtomicInt ref
Definition: qstring.h:604
static void free(Data *)
Definition: qstring.cpp:1311
Data * d
Definition: qstring.h:618
ushort * data
Definition: qstring.h:606
#define Q_CHECK_PTR(p)
Definition: qglobal.h:1853
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
ushort array[1]
Definition: qstring.h:614
ushort righttoleft
Definition: qstring.h:609
ushort simpletext
Definition: qstring.h:608
ushort asciiCache
Definition: qstring.h:610

◆ remove() [1/4]

QString & QString::remove ( int  position,
int  n 
)

Removes n characters from the string, starting at the given position index, and returns a reference to the string.

If the specified position index is within the string, but position + n is beyond the end of the string, the string is truncated at the specified position.

QString s = "Montreal";
s.remove(1, 4);
// s == "Meal"
See also
insert(), replace()

Definition at line 1867 of file qstring.cpp.

Referenced by QScriptDebuggerLocalsWidgetPrivate::_q_onCompletionTaskFinished(), QScriptDebuggerConsoleWidgetPrivate::_q_onCompletionTaskFinished(), QPrintPreviewDialogPrivate::_q_zoomFactorChanged(), cleanPath(), composeHelper(), QTextStreamPrivate::consume(), QScriptDebuggerConsole::consumeInput(), createUseNode(), QKeySequencePrivate::decodeString(), QDomCharacterDataPrivate::deleteData(), QAccessibleSimpleEditableTextInterface::deleteText(), elliditide(), filterDisplayOffset(), filterTransformation(), fixedCDataSection(), fixedComment(), fixedPIData(), fixedPubidLiteral(), fixedSystemLiteral(), QSpinBox::fixup(), QDoubleSpinBox::fixup(), QTest::formatResult(), QPatternist::DerivedInteger< DerivedType >::fromLexical(), QGtkStylePrivate::getThemeName(), QMessageBoxPrivate::hideSpecial(), QSQLiteResultPrivate::initColumns(), QLineControl::internalDelete(), QLineControl::internalRedo(), QLineControl::internalUndo(), QXmlSimpleReaderPrivate::isExpandedEntityValueTooLarge(), QFSFileEnginePrivate::longFileName(), QWSServerPrivate::newMouseHandler(), QSettingsPrivate::normalizedKey(), QAxClientSite::OnPosRectChange(), QSQLiteDriver::open(), QTest::outputMessage(), QTextHtmlParser::parseEntity(), QCss::Parser::parseSimpleSelector(), QCss::Parser::parseTerm(), qExtractSecurityPolicyFromString(), qt_accStripAmp(), qt_mac_menu_merge_action(), qt_parseSpoolInterface(), qt_setWindowTitle_helperHelper(), qt_strippedText(), qt_tildeExpansion(), qt_wce_insert_action(), qt_wce_rename_menu_item(), qt_win_get_open_file_name(), qt_win_get_open_file_names(), qt_win_get_save_file_name(), qt_win_make_OFN(), readLink(), QDir::relativeFilePath(), removeOptionalQuotes(), QLineControl::removeSelectedText(), QFileSystemEntry::resolveFilePath(), QFileDialog::selectFile(), QNetworkCookieJar::setCookiesFromUrl(), QPluginLoader::setFileName(), QSvgNode::styleProperty(), QStyleSheetStyle::styleRules(), QMenuPrivate::QMacMenuPrivate::syncAction(), QSpinBox::textFromValue(), QDoubleSpinBox::textFromValue(), QmlJSDebugger::AbstractLiveEditTool::titleForItem(), QSystemLocalePrivate::toCurrencyString(), QUrl::toLocalFile(), QCss::Parser::unquotedLexem(), QSpinBoxPrivate::validateAndInterpret(), QDoubleSpinBoxPrivate::validateAndInterpret(), and xic_draw_callback().

1868 {
1869  if (pos < 0) // count from end of string
1870  pos += d->size;
1871  if (pos < 0 || pos >= d->size) {
1872  // range problems
1873  } else if (len >= d->size - pos) {
1874  resize(pos); // truncate
1875  } else if (len > 0) {
1876  detach();
1877  memmove(d->data + pos, d->data + pos + len,
1878  (d->size - pos - len + 1) * sizeof(ushort));
1879  d->size -= len;
1880  }
1881  return *this;
1882 }
void detach()
Definition: qstring.h:714
Data * d
Definition: qstring.h:618
void resize(int size)
Sets the size of the string to size characters.
Definition: qstring.cpp:1353
ushort * data
Definition: qstring.h:606
unsigned short ushort
Definition: qglobal.h:995

◆ remove() [2/4]

QString & QString::remove ( QChar  ch,
Qt::CaseSensitivity  cs = Qt::CaseSensitive 
)

Removes every occurrence of the character ch in this string, and returns a reference to this string.

If cs is Qt::CaseSensitive (default), the search is case sensitive; otherwise the search is case insensitive.

Example:

QString t = "Ali Baba";
// t == "li Bb"

This is the same as replace(ch, "", cs).

See also
replace()

Definition at line 1920 of file qstring.cpp.

1921 {
1922  int i = 0;
1923  ushort c = ch.unicode();
1924  if (cs == Qt::CaseSensitive) {
1925  while (i < d->size)
1926  if (d->data[i] == ch)
1927  remove(i, 1);
1928  else
1929  i++;
1930  } else {
1931  c = foldCase(c);
1932  while (i < d->size)
1933  if (foldCase(d->data[i]) == c)
1934  remove(i, 1);
1935  else
1936  i++;
1937  }
1938  return *this;
1939 }
unsigned char c[8]
Definition: qnumeric_p.h:62
ushort unicode() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qchar.h:251
int size() const
Returns the number of characters in this string.
Definition: qstring.h:102
Data * d
Definition: qstring.h:618
static uint foldCase(const ushort *ch, const ushort *start)
Definition: qchar.cpp:1380
ushort * data
Definition: qstring.h:606
unsigned short ushort
Definition: qglobal.h:995

◆ remove() [3/4]

QString & QString::remove ( const QString str,
Qt::CaseSensitivity  cs = Qt::CaseSensitive 
)

Removes every occurrence of the given str string in this string, and returns a reference to this string.

If cs is Qt::CaseSensitive (default), the search is case sensitive; otherwise the search is case insensitive.

This is the same as replace(str, "", cs).

See also
replace()

Definition at line 1895 of file qstring.cpp.

1896 {
1897  if (str.d->size) {
1898  int i = 0;
1899  while ((i = indexOf(str, i, cs)) != -1)
1900  remove(i, str.d->size);
1901  }
1902  return *this;
1903 }
int indexOf(QChar c, int from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.cpp:2838
Data * d
Definition: qstring.h:618

◆ remove() [4/4]

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

Removes every occurrence of the regular expression rx in the string, and returns a reference to the string.

For example:

QString r = "Telephone";
r.remove(QRegExp("[aeiou]."));
// r == "The"
See also
indexOf(), lastIndexOf(), replace()

Definition at line 295 of file qstring.h.

296  { return replace(rx, QString()); }
QString & replace(int i, int len, QChar after)
Definition: qstring.cpp:2005
QString()
Constructs a null string.
Definition: qstring.h:879

◆ repeated()

QString QString::repeated ( int  times) const

Returns a copy of this string repeated the specified number of times.

Since
4.5

If times is less than 1, an empty string is returned.

Example:

QString str("ab");
str.repeated(4); // returns "abababab"

Definition at line 6657 of file qstring.cpp.

6658 {
6659  if (d->size == 0)
6660  return *this;
6661 
6662  if (times <= 1) {
6663  if (times == 1)
6664  return *this;
6665  return QString();
6666  }
6667 
6668  const int resultSize = times * d->size;
6669 
6670  QString result;
6671  result.reserve(resultSize);
6672  if (result.d->alloc != resultSize)
6673  return QString(); // not enough memory
6674 
6675  memcpy(result.d->data, d->data, d->size * sizeof(ushort));
6676 
6677  int sizeSoFar = d->size;
6678  ushort *end = result.d->data + sizeSoFar;
6679 
6680  const int halfResultSize = resultSize >> 1;
6681  while (sizeSoFar <= halfResultSize) {
6682  memcpy(end, result.d->data, sizeSoFar * sizeof(ushort));
6683  end += sizeSoFar;
6684  sizeSoFar <<= 1;
6685  }
6686  memcpy(end, result.d->data, (resultSize - sizeSoFar) * sizeof(ushort));
6687  result.d->data[resultSize] = '\0';
6688  result.d->size = resultSize;
6689  return result;
6690 }
iterator end()
Returns an STL-style iterator pointing to the imaginary character after the last character in the str...
Definition: qstring.h:894
The QString class provides a Unicode character string.
Definition: qstring.h:83
void reserve(int size)
Attempts to allocate memory for at least size characters.
Definition: qstring.h:881
Data * d
Definition: qstring.h:618
ushort * data
Definition: qstring.h:606
unsigned short ushort
Definition: qglobal.h:995
QString()
Constructs a null string.
Definition: qstring.h:879

◆ replace() [1/12]

QString & QString::replace ( int  i,
int  len,
QChar  after 
)

Definition at line 2005 of file qstring.cpp.

Referenced by _q_escapeIdentifier(), QUnixPrintWidgetPrivate::_q_printerChanged(), QFileDialogPrivate::_q_useNameFilter(), QDeclarativeImportsPrivate::add(), QDeclarativeImportDatabase::addImportPath(), QStyleSheetStyleSelector::attribute(), QAccessibleTextWidget::attributes(), QDir::cleanPath(), QDateTimeEditPrivate::clearSection(), comify(), QWindowsMimeText::convertToMime(), createSvgNode(), QScriptDebuggerLocalsModel::data(), decomposeHelper(), QSvgText::draw(), QTextHtmlExporter::emitBlock(), encodeText(), QDeclarativeDirParser::errors(), QDB2Driver::escapeIdentifier(), QIBaseDriver::escapeIdentifier(), QOCIDriver::escapeIdentifier(), QSQLite2Driver::escapeIdentifier(), QTDSDriver::escapeIdentifier(), QMYSQLDriver::escapeIdentifier(), QPSQLDriver::escapeIdentifier(), QODBCDriver::escapeIdentifier(), QPatternist::ReplaceFN::evaluateSingleton(), QSqlResult::exec(), find_translation(), findInBlock(), QMacPasteboardMimeAny::flavorFor(), QTextStreamPrivate::flushWriteBuffer(), QSqlDriver::formatValue(), QMYSQLDriver::formatValue(), QPSQLDriver::formatValue(), QBBSystemLocaleData::getCorrectFormat(), QComboMenuDelegate::getStyleOption(), QApplicationPrivate::globalEventProcessor(), QSvgSwitch::init(), QXmlSimpleReaderPrivate::insertXmlRef(), QLineControl::internalDelete(), QLineControl::internalInsert(), launchWebBrowser(), QAxServerBase::Load(), QLibraryInfo::location(), QFSFileEnginePrivate::longFileName(), QSharedMemoryPrivate::makePlatformSafeKey(), mapToLowerCase(), QProgressBar::minimumSizeHint(), QPatternist::XsdTypeChecker::normalizedValue(), QPSQLDriver::open(), QSplitter::operator>>(), QGraphicsSimpleTextItem::paint(), QDateTimeParser::parse(), QPatternist::PatternPlatform::parsePattern(), QDateTimeParser::parseSection(), QProcessPrivate::pipeWriterBytesToWrite(), QHttpNetworkConnectionPrivate::prepareRequest(), QCss::Scanner::preprocess(), qDBusGenerateMetaObjectXml(), qDBusInterfaceFromMetaObject(), QDeclarativeScriptEngine::QDeclarativeScriptEngine(), QFontEngineQPF::QFontEngineQPF(), qQuote(), qt_accStripAmp(), qt_create_commandline(), qt_mac_extract_filter(), qt_mac_menu_merge_action(), qt_setWindowTitle_helperHelper(), qt_tildeExpansion(), qt_win_get_existing_directory(), quoteNewline(), readSymLink(), QLineControl::removeSelectedText(), QByteArray::replace(), replace(), QDomCharacterDataPrivate::replaceData(), replacePercentN(), QAccessibleSimpleEditableTextInterface::replaceText(), QDeclarativeXMLHttpRequest::requestFromUrl(), QDeclarativeImportsPrivate::resolvedUri(), QDeclarativeTypeData::resolveTypes(), QAxServerBase::Save(), QAction::setText(), QUrl::setUrl(), QDesktopServices::storageLocation(), stripTextDecl(), tabTextFor(), QAccessibleMdiSubWindow::text(), QGraphicsSimpleTextItemPrivate::updateBoundingRect(), QMdiSubWindowPrivate::updateInternalWindowTitle(), QDeclarativeTextPrivate::updateLayout(), QFontDialogPrivate::updateStyles(), WinMain(), QDBusMetaObjectGenerator::write(), QXmlStreamWriter::writeCDATA(), and xic_draw_callback().

2006 {
2007  return replace(pos, len, &after, 1);
2008 }
QString & replace(int i, int len, QChar after)
Definition: qstring.cpp:2005

◆ replace() [2/12]

QString & QString::replace ( int  i,
int  len,
const QChar s,
int  slen 
)

Definition at line 1983 of file qstring.cpp.

1984 {
1985  if (pos < 0 || pos > d->size)
1986  return *this;
1987  if (pos + len > d->size)
1988  len = d->size - pos;
1989 
1990  uint index = pos;
1991  replace_helper(&index, 1, len, unicode, size);
1992  return *this;
1993 }
int size() const
Returns the number of characters in this string.
Definition: qstring.h:102
const QChar * unicode() const
Returns a &#39;\0&#39;-terminated Unicode representation of the string.
Definition: qstring.h:706
void replace_helper(uint *indices, int nIndices, int blen, const QChar *after, int alen)
Definition: qstring.cpp:2039
unsigned int uint
Definition: qglobal.h:996
Data * d
Definition: qstring.h:618
quint16 index

◆ replace() [3/12]

QString & QString::replace ( int  position,
int  n,
const QString after 
)

Replaces n characters beginning at index position with the string after and returns a reference to this string.

Example:

QString x = "Say yes!";
QString y = "no";
x.replace(4, 3, y);
// x == "Say no!"
See also
insert(), remove()

Definition at line 1970 of file qstring.cpp.

1971 {
1972  QString copy = after;
1973  return replace(pos, len, copy.constData(), copy.length());
1974 }
QString & replace(int i, int len, QChar after)
Definition: qstring.cpp:2005
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
The QString class provides a Unicode character string.
Definition: qstring.h:83
const QChar * constData() const
Returns a pointer to the data stored in the QString.
Definition: qstring.h:712

◆ replace() [4/12]

QString & QString::replace ( QChar  before,
QChar  after,
Qt::CaseSensitivity  cs = Qt::CaseSensitive 
)

Definition at line 2230 of file qstring.cpp.

2231 {
2232  ushort a = after.unicode();
2233  ushort b = before.unicode();
2234  if (d->size) {
2235  detach();
2236  ushort *i = d->data;
2237  const ushort *e = i + d->size;
2238  if (cs == Qt::CaseSensitive) {
2239  for (; i != e; ++i)
2240  if (*i == b)
2241  *i = a;
2242  } else {
2243  b = foldCase(b);
2244  for (; i != e; ++i)
2245  if (foldCase(*i) == b)
2246  *i = a;
2247  }
2248  }
2249  return *this;
2250 }
ushort unicode() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qchar.h:251
long ASN1_INTEGER_get ASN1_INTEGER * a
void detach()
Definition: qstring.h:714
Data * d
Definition: qstring.h:618
static uint foldCase(const ushort *ch, const ushort *start)
Definition: qchar.cpp:1380
ushort * data
Definition: qstring.h:606
unsigned short ushort
Definition: qglobal.h:995

◆ replace() [5/12]

QString & QString::replace ( const QChar before,
int  blen,
const QChar after,
int  alen,
Qt::CaseSensitivity  cs = Qt::CaseSensitive 
)

Definition at line 2121 of file qstring.cpp.

2124 {
2125  if (d->size == 0) {
2126  if (blen)
2127  return *this;
2128  } else {
2129  if (cs == Qt::CaseSensitive && before == after && blen == alen)
2130  return *this;
2131  }
2132  if (alen == 0 && blen == 0)
2133  return *this;
2134 
2135  QStringMatcher matcher(before, blen, cs);
2136 
2137  int index = 0;
2138  while (1) {
2139  uint indices[1024];
2140  uint pos = 0;
2141  while (pos < 1023) {
2142  index = matcher.indexIn(*this, index);
2143  if (index == -1)
2144  break;
2145  indices[pos++] = index;
2146  index += blen;
2147  // avoid infinite loop
2148  if (!blen)
2149  index++;
2150  }
2151  if (!pos)
2152  break;
2153 
2154  replace_helper(indices, pos, blen, after, alen);
2155 
2156  if (index == -1)
2157  break;
2158  // index has to be adjusted in case we get back into the loop above.
2159  index += pos*(alen-blen);
2160  }
2161 
2162  return *this;
2163 }
The QStringMatcher class holds a sequence of characters that can be quickly matched in a Unicode stri...
void replace_helper(uint *indices, int nIndices, int blen, const QChar *after, int alen)
Definition: qstring.cpp:2039
unsigned int uint
Definition: qglobal.h:996
Data * d
Definition: qstring.h:618
quint16 index

◆ replace() [6/12]

QString & QString::replace ( const QLatin1String before,
const QLatin1String after,
Qt::CaseSensitivity  cs = Qt::CaseSensitive 
)

Definition at line 2267 of file qstring.cpp.

2270 {
2271  int alen = qstrlen(after.latin1());
2272  QVarLengthArray<ushort> a(alen);
2273  for (int i = 0; i < alen; ++i)
2274  a[i] = (uchar)after.latin1()[i];
2275  int blen = qstrlen(before.latin1());
2276  QVarLengthArray<ushort> b(blen);
2277  for (int i = 0; i < blen; ++i)
2278  b[i] = (uchar)before.latin1()[i];
2279  return replace((const QChar *)b.data(), blen, (const QChar *)a.data(), alen, cs);
2280 }
QString & replace(int i, int len, QChar after)
Definition: qstring.cpp:2005
long ASN1_INTEGER_get ASN1_INTEGER * a
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
unsigned char uchar
Definition: qglobal.h:994
const char * latin1() const
Returns the Latin-1 string stored in this object.
Definition: qstring.h:661
uint qstrlen(const char *str)
Definition: qbytearray.h:79

◆ replace() [7/12]

QString & QString::replace ( const QLatin1String before,
const QString after,
Qt::CaseSensitivity  cs = Qt::CaseSensitive 
)

Definition at line 2297 of file qstring.cpp.

2300 {
2301  int blen = qstrlen(before.latin1());
2302  QVarLengthArray<ushort> b(blen);
2303  for (int i = 0; i < blen; ++i)
2304  b[i] = (uchar)before.latin1()[i];
2305  return replace((const QChar *)b.data(), blen, after.constData(), after.d->size, cs);
2306 }
QString & replace(int i, int len, QChar after)
Definition: qstring.cpp:2005
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
unsigned char uchar
Definition: qglobal.h:994
const char * latin1() const
Returns the Latin-1 string stored in this object.
Definition: qstring.h:661
Data * d
Definition: qstring.h:618
uint qstrlen(const char *str)
Definition: qbytearray.h:79
const QChar * constData() const
Returns a pointer to the data stored in the QString.
Definition: qstring.h:712

◆ replace() [8/12]

QString & QString::replace ( const QString before,
const QLatin1String after,
Qt::CaseSensitivity  cs = Qt::CaseSensitive 
)

Definition at line 2323 of file qstring.cpp.

2326 {
2327  int alen = qstrlen(after.latin1());
2328  QVarLengthArray<ushort> a(alen);
2329  for (int i = 0; i < alen; ++i)
2330  a[i] = (uchar)after.latin1()[i];
2331  return replace(before.constData(), before.d->size, (const QChar *)a.data(), alen, cs);
2332 }
QString & replace(int i, int len, QChar after)
Definition: qstring.cpp:2005
long ASN1_INTEGER_get ASN1_INTEGER * a
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
unsigned char uchar
Definition: qglobal.h:994
const char * latin1() const
Returns the Latin-1 string stored in this object.
Definition: qstring.h:661
Data * d
Definition: qstring.h:618
uint qstrlen(const char *str)
Definition: qbytearray.h:79
const QChar * constData() const
Returns a pointer to the data stored in the QString.
Definition: qstring.h:712

◆ replace() [9/12]

QString & QString::replace ( const QString before,
const QString after,
Qt::CaseSensitivity  cs = Qt::CaseSensitive 
)

Definition at line 2031 of file qstring.cpp.

2032 {
2033  return replace(before.constData(), before.size(), after.constData(), after.size(), cs);
2034 }
QString & replace(int i, int len, QChar after)
Definition: qstring.cpp:2005
int size() const
Returns the number of characters in this string.
Definition: qstring.h:102
const QChar * constData() const
Returns a pointer to the data stored in the QString.
Definition: qstring.h:712

◆ replace() [10/12]

QString & QString::replace ( QChar  c,
const QString after,
Qt::CaseSensitivity  cs = Qt::CaseSensitive 
)

Definition at line 2176 of file qstring.cpp.

2177 {
2178  if (after.d->size == 0)
2179  return remove(ch, cs);
2180 
2181  if (after.d->size == 1)
2182  return replace(ch, after.d->data[0], cs);
2183 
2184  if (d->size == 0)
2185  return *this;
2186 
2187  ushort cc = (cs == Qt::CaseSensitive ? ch.unicode() : ch.toCaseFolded().unicode());
2188 
2189  int index = 0;
2190  while (1) {
2191  uint indices[1024];
2192  uint pos = 0;
2193  if (cs == Qt::CaseSensitive) {
2194  while (pos < 1023 && index < d->size) {
2195  if (d->data[index] == cc)
2196  indices[pos++] = index;
2197  index++;
2198  }
2199  } else {
2200  while (pos < 1023 && index < d->size) {
2201  if (QChar::toCaseFolded(d->data[index]) == cc)
2202  indices[pos++] = index;
2203  index++;
2204  }
2205  }
2206  if (!pos)
2207  break;
2208 
2209  replace_helper(indices, pos, 1, after.constData(), after.d->size);
2210 
2211  if (index == -1)
2212  break;
2213  // index has to be adjusted in case we get back into the loop above.
2214  index += pos*(after.d->size - 1);
2215  }
2216  return *this;
2217 }
QString & replace(int i, int len, QChar after)
Definition: qstring.cpp:2005
QChar toCaseFolded() const
Returns the case folded equivalent of the character.
Definition: qchar.cpp:1406
int size() const
Returns the number of characters in this string.
Definition: qstring.h:102
void replace_helper(uint *indices, int nIndices, int blen, const QChar *after, int alen)
Definition: qstring.cpp:2039
unsigned int uint
Definition: qglobal.h:996
Data * d
Definition: qstring.h:618
ushort * data
Definition: qstring.h:606
unsigned short ushort
Definition: qglobal.h:995
quint16 index
const QChar * constData() const
Returns a pointer to the data stored in the QString.
Definition: qstring.h:712

◆ replace() [11/12]

QString & QString::replace ( QChar  c,
const QLatin1String after,
Qt::CaseSensitivity  cs = Qt::CaseSensitive 
)

Definition at line 2349 of file qstring.cpp.

2350 {
2351  int alen = qstrlen(after.latin1());
2352  QVarLengthArray<ushort> a(alen);
2353  for (int i = 0; i < alen; ++i)
2354  a[i] = (uchar)after.latin1()[i];
2355  return replace(&c, 1, (const QChar *)a.data(), alen, cs);
2356 }
QString & replace(int i, int len, QChar after)
Definition: qstring.cpp:2005
long ASN1_INTEGER_get ASN1_INTEGER * a
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
unsigned char uchar
Definition: qglobal.h:994
const char * latin1() const
Returns the Latin-1 string stored in this object.
Definition: qstring.h:661
uint qstrlen(const char *str)
Definition: qbytearray.h:79

◆ replace() [12/12]

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

Definition at line 3072 of file qstring.cpp.

3073 {
3074  QRegExp rx2(rx);
3075 
3076  if (isEmpty() && rx2.indexIn(*this) == -1)
3077  return *this;
3078 
3079  realloc();
3080 
3081  int index = 0;
3082  int numCaptures = rx2.captureCount();
3083  int al = after.length();
3085 
3086  if (numCaptures > 0) {
3087  const QChar *uc = after.unicode();
3088  int numBackRefs = 0;
3089 
3090  for (int i = 0; i < al - 1; i++) {
3091  if (uc[i] == QLatin1Char('\\')) {
3092  int no = uc[i + 1].digitValue();
3093  if (no > 0 && no <= numCaptures)
3094  numBackRefs++;
3095  }
3096  }
3097 
3098  /*
3099  This is the harder case where we have back-references.
3100  */
3101  if (numBackRefs > 0) {
3102  QVarLengthArray<QStringCapture, 16> captures(numBackRefs);
3103  int j = 0;
3104 
3105  for (int i = 0; i < al - 1; i++) {
3106  if (uc[i] == QLatin1Char('\\')) {
3107  int no = uc[i + 1].digitValue();
3108  if (no > 0 && no <= numCaptures) {
3109  QStringCapture capture;
3110  capture.pos = i;
3111  capture.len = 2;
3112 
3113  if (i < al - 2) {
3114  int secondDigit = uc[i + 2].digitValue();
3115  if (secondDigit != -1 && ((no * 10) + secondDigit) <= numCaptures) {
3116  no = (no * 10) + secondDigit;
3117  ++capture.len;
3118  }
3119  }
3120 
3121  capture.no = no;
3122  captures[j++] = capture;
3123  }
3124  }
3125  }
3126 
3127  while (index <= length()) {
3128  index = rx2.indexIn(*this, index, caretMode);
3129  if (index == -1)
3130  break;
3131 
3132  QString after2(after);
3133  for (j = numBackRefs - 1; j >= 0; j--) {
3134  const QStringCapture &capture = captures[j];
3135  after2.replace(capture.pos, capture.len, rx2.cap(capture.no));
3136  }
3137 
3138  replace(index, rx2.matchedLength(), after2);
3139  index += after2.length();
3140 
3141  // avoid infinite loop on 0-length matches (e.g., QRegExp("[a-z]*"))
3142  if (rx2.matchedLength() == 0)
3143  ++index;
3144 
3145  caretMode = QRegExp::CaretWontMatch;
3146  }
3147  return *this;
3148  }
3149  }
3150 
3151  /*
3152  This is the simple and optimized case where we don't have
3153  back-references.
3154  */
3155  while (index != -1) {
3156  struct {
3157  int pos;
3158  int length;
3159  } replacements[2048];
3160 
3161  int pos = 0;
3162  int adjust = 0;
3163  while (pos < 2047) {
3164  index = rx2.indexIn(*this, index, caretMode);
3165  if (index == -1)
3166  break;
3167  int ml = rx2.matchedLength();
3168  replacements[pos].pos = index;
3169  replacements[pos++].length = ml;
3170  index += ml;
3171  adjust += al - ml;
3172  // avoid infinite loop
3173  if (!ml)
3174  index++;
3175  }
3176  if (!pos)
3177  break;
3178  replacements[pos].pos = d->size;
3179  int newlen = d->size + adjust;
3180 
3181  // to continue searching at the right position after we did
3182  // the first round of replacements
3183  if (index != -1)
3184  index += adjust;
3185  QString newstring;
3186  newstring.reserve(newlen + 1);
3187  QChar *newuc = newstring.data();
3188  QChar *uc = newuc;
3189  int copystart = 0;
3190  int i = 0;
3191  while (i < pos) {
3192  int copyend = replacements[i].pos;
3193  int size = copyend - copystart;
3194  memcpy(uc, d->data + copystart, size * sizeof(QChar));
3195  uc += size;
3196  memcpy(uc, after.d->data, al * sizeof(QChar));
3197  uc += al;
3198  copystart = copyend + replacements[i].length;
3199  i++;
3200  }
3201  memcpy(uc, d->data + copystart, (d->size - copystart) * sizeof(QChar));
3202  newstring.resize(newlen);
3203  *this = newstring;
3204  caretMode = QRegExp::CaretWontMatch;
3205  }
3206  return *this;
3207 }
void realloc()
Definition: qstring.cpp:1472
int digitValue() const
Returns the numeric value of the digit, or -1 if the character is not a digit.
Definition: qchar.cpp:817
The QRegExp class provides pattern matching using regular expressions.
Definition: qregexp.h:61
QString & replace(int i, int len, QChar after)
Definition: qstring.cpp:2005
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
The QString class provides a Unicode character string.
Definition: qstring.h:83
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
QChar * data()
Returns a pointer to the data stored in the QString.
Definition: qstring.h:710
void reserve(int size)
Attempts to allocate memory for at least size characters.
Definition: qstring.h:881
int size() const
Returns the number of characters in this string.
Definition: qstring.h:102
const QChar * unicode() const
Returns a &#39;\0&#39;-terminated Unicode representation of the string.
Definition: qstring.h:706
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
Data * d
Definition: qstring.h:618
void resize(int size)
Sets the size of the string to size characters.
Definition: qstring.cpp:1353
ushort * data
Definition: qstring.h:606
quint16 index
CaretMode
The CaretMode enum defines the different meanings of the caret (^) in a regular expression.
Definition: qregexp.h:71
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ replace_helper()

void QString::replace_helper ( uint indices,
int  nIndices,
int  blen,
const QChar after,
int  alen 
)
private
Warning
This function is not part of the public interface.

Definition at line 2039 of file qstring.cpp.

Referenced by replace().

2040 {
2041  // copy *after in case it lies inside our own d->data area
2042  // (which we could possibly invalidate via a realloc or corrupt via memcpy operations.)
2043  QChar *afterBuffer = const_cast<QChar *>(after);
2044  if (after >= reinterpret_cast<QChar *>(d->data) && after < reinterpret_cast<QChar *>(d->data) + d->size) {
2045  afterBuffer = static_cast<QChar *>(qMalloc(alen*sizeof(QChar)));
2046  Q_CHECK_PTR(afterBuffer);
2047  ::memcpy(afterBuffer, after, alen*sizeof(QChar));
2048  }
2049 
2050  QT_TRY {
2051  if (blen == alen) {
2052  // replace in place
2053  detach();
2054  for (int i = 0; i < nIndices; ++i)
2055  memcpy(d->data + indices[i], afterBuffer, alen * sizeof(QChar));
2056  } else if (alen < blen) {
2057  // replace from front
2058  detach();
2059  uint to = indices[0];
2060  if (alen)
2061  memcpy(d->data+to, after, alen*sizeof(QChar));
2062  to += alen;
2063  uint movestart = indices[0] + blen;
2064  for (int i = 1; i < nIndices; ++i) {
2065  int msize = indices[i] - movestart;
2066  if (msize > 0) {
2067  memmove(d->data + to, d->data + movestart, msize * sizeof(QChar));
2068  to += msize;
2069  }
2070  if (alen) {
2071  memcpy(d->data + to, afterBuffer, alen*sizeof(QChar));
2072  to += alen;
2073  }
2074  movestart = indices[i] + blen;
2075  }
2076  int msize = d->size - movestart;
2077  if (msize > 0)
2078  memmove(d->data + to, d->data + movestart, msize * sizeof(QChar));
2079  resize(d->size - nIndices*(blen-alen));
2080  } else {
2081  // replace from back
2082  int adjust = nIndices*(alen-blen);
2083  int newLen = d->size + adjust;
2084  int moveend = d->size;
2085  resize(newLen);
2086 
2087  while (nIndices) {
2088  --nIndices;
2089  int movestart = indices[nIndices] + blen;
2090  int insertstart = indices[nIndices] + nIndices*(alen-blen);
2091  int moveto = insertstart + alen;
2092  memmove(d->data + moveto, d->data + movestart,
2093  (moveend - movestart)*sizeof(QChar));
2094  memcpy(d->data + insertstart, afterBuffer, alen*sizeof(QChar));
2095  moveend = movestart-blen;
2096  }
2097  }
2098  } QT_CATCH(const std::bad_alloc &) {
2099  if (afterBuffer != after)
2100  qFree(afterBuffer);
2101  QT_RETHROW;
2102  }
2103  if (afterBuffer != after)
2104  qFree(afterBuffer);
2105 }
Q_CORE_EXPORT void qFree(void *ptr)
Definition: qmalloc.cpp:58
Q_CORE_EXPORT void * qMalloc(size_t size)
Definition: qmalloc.cpp:53
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
#define QT_RETHROW
Definition: qglobal.h:1539
unsigned int uint
Definition: qglobal.h:996
void detach()
Definition: qstring.h:714
#define QT_CATCH(A)
Definition: qglobal.h:1537
Data * d
Definition: qstring.h:618
void resize(int size)
Sets the size of the string to size characters.
Definition: qstring.cpp:1353
ushort * data
Definition: qstring.h:606
#define Q_CHECK_PTR(p)
Definition: qglobal.h:1853
#define QT_TRY
Definition: qglobal.h:1536

◆ reserve()

void QString::reserve ( int  size)
inline

Attempts to allocate memory for at least size characters.

If you know in advance how large the string will be, you can call this function, and if you resize the string often you are likely to get better performance. If size is an underestimate, the worst that will happen is that the QString will be a bit slower.

The sole purpose of this function is to provide a means of fine tuning QString's memory usage. In general, you will rarely ever need to call this function. If you want to change the size of the string, call resize().

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 large enough to make a call to reserve() worthwhile:

QString result;
int maxSize;
bool condition;
QChar nextChar;
result.reserve(maxSize);
while (condition)
result.append(nextChar);
result.squeeze();
See also
squeeze(), capacity()

Definition at line 881 of file qstring.h.

Referenced by QDBusConnectionPrivate::activateCall(), QTextHtmlImporter::appendNodeText(), QXmlStreamReaderPrivate::clearTextBuffer(), QPatternist::ColoringMessageHandler::colorifyDescription(), Qt::escape(), QRegExp::escape(), QPatternist::escape(), QPatternist::TranslateFN::evaluateSingleton(), QMYSQLDriver::formatValue(), QXmlStreamReaderPrivate::getChar_helper(), QDBusConnectionPrivate::handleSignal(), QScriptSyntaxHighlighter::highlightBlock(), QXmlStreamReaderPrivate::init(), QSettingsPrivate::iniUnescapedKey(), QCss::ValueExtractor::lengthValue(), QCss::Symbol::lexem(), QSqlResultPrivate::namedToPositionalBinding(), QScriptEnginePrivate::newRegExp(), QPatternist::XQueryTokenizer::nextToken(), QPatternist::XQueryTokenizer::normalizeEOL(), operator+=(), QDeclarativeStyledTextPrivate::parse(), QPatternist::ReplaceFN::parseReplacement(), QSqlResultPrivate::positionalToNamedBinding(), QDBusConnectionPrivate::prepareHook(), qIsEffectiveTLD(), qReplacePlaceholderMarkers(), QtPrivate::QStringList_join(), qt_ACE_do(), QXmlFormatterPrivate::QXmlFormatterPrivate(), QConfFileSettingsPrivate::readIniSection(), QSqlRelationalTableModelPrivate::relationField(), repeated(), replace(), QSqlDriver::sqlStatement(), QPatternist::HexBinary::stringValue(), QTextBlock::text(), QTextHtmlExporter::toHtml(), QPatternist::XQueryTokenizer::tokenizeStringLiteral(), QProcessEnvironmentPrivate::toList(), typeNameToXml(), QXmlSerializer::writeEscaped(), QXmlStreamWriterPrivate::writeEscaped(), QXmlSerializer::writeEscapedAttribute(), and QPatternist::AbstractDateTime::zoneOffsetToString().

881 { if (d->ref != 1 || asize > d->alloc) realloc(asize); d->capacity = 1;}
void realloc()
Definition: qstring.cpp:1472
ushort capacity
Definition: qstring.h:611
QBasicAtomicInt ref
Definition: qstring.h:604
Data * d
Definition: qstring.h:618

◆ resize()

void QString::resize ( int  size)

Sets the size of the string to size characters.

If size is greater than the current size, the string is extended to make it size characters long with the extra characters added to the end. The new characters are uninitialized.

If size is less than the current size, characters are removed from the end.

Example:

QString s = "Hello world";
s.resize(5);
// s == "Hello"
s.resize(8);
// s == "Hello???" (where ? stands for any character)

If you want to append a certain number of identical characters to the string, use operator+=() as follows rather than resize():

QString t = "Hello";
t += QString(10, 'X');
// t == "HelloXXXXXXXXXX"

If you want to expand the string so that it reaches a certain width and fill the new positions with a particular character, use the leftJustified() function:

If size is negative, it is equivalent to passing zero.

QString r = "Hello";
r = r.leftJustified(10, ' ');
// r == "Hello "
See also
truncate(), reserve()

Definition at line 1353 of file qstring.cpp.

Referenced by _q_parseUnixDir(), QXmlStreamPrivateTagStack::addToStringStorage(), append(), chop(), QXmlStreamReaderPrivate::clearTextBuffer(), QTextDocumentPrivate::compressPieceTable(), QWindowsMimeText::convertFromMime(), QBuiltInMimes::convertFromMime(), QGb18030Codec::convertToUnicode(), QIsciiCodec::convertToUnicode(), QGbkCodec::convertToUnicode(), QUtf32::convertToUnicode(), QGb2312Codec::convertToUnicode(), QPatternist::CompressedWhitespace::decompress(), expand(), QXmlStreamReaderPrivate::fastScanContentCharList(), QXmlStreamReaderPrivate::fastScanName(), QXmlStreamReaderPrivate::fastScanNMTOKEN(), fill(), QTextStreamPrivate::fillReadBuffer(), fromStdWString(), QXmlStreamReaderPrivate::getChar_helper(), getEnglishName(), QSettingsPrivate::iniUnescapedStringList(), leftJustified(), QResourceRoot::name(), operator+=(), operator>>(), QTextDocumentPrivate::plainText(), qt_ACE_do(), qt_nameprep(), QtWndProc(), QXmlFormatterPrivate::QXmlFormatterPrivate(), remove(), replace(), replace_helper(), rightJustified(), QXmlStreamReaderPrivate::scanString(), QXmlStreamReaderPrivate::scanUntil(), setUnicode(), toLower(), toPunycodeHelper(), QTextDecoder::toUnicode(), toUpper(), truncate(), updateValue(), and QXIMInputContext::x11FilterEvent().

1354 {
1355  if (size < 0)
1356  size = 0;
1357 
1358  if (size == 0 && !d->capacity) {
1359  Data *x = &shared_empty;
1360  x->ref.ref();
1361  if (!d->ref.deref())
1362  QString::free(d);
1363  d = x;
1364  } else {
1365  if (d->ref != 1 || size > d->alloc ||
1366  (!d->capacity && size < d->size && size < d->alloc >> 1))
1367  realloc(grow(size));
1368  if (d->alloc >= size) {
1369  d->size = size;
1370  if (d->data == d->array) {
1371  d->array[size] = '\0';
1372  }
1373  }
1374  }
1375 }
void realloc()
Definition: qstring.cpp:1472
ushort capacity
Definition: qstring.h:611
QBasicAtomicInt ref
Definition: qstring.h:604
static void free(Data *)
Definition: qstring.cpp:1311
int size() const
Returns the number of characters in this string.
Definition: qstring.h:102
Data * d
Definition: qstring.h:618
ushort * data
Definition: qstring.h:606
ushort array[1]
Definition: qstring.h:614
static int grow(int)
Definition: qstring.cpp:822
static Data shared_empty
Definition: qstring.h:617

◆ right()

QString QString::right ( int  n) const

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

The entire string is returned if n is greater than size() or less than zero.

QString x = "Pineapple";
QString y = x.right(5); // y == "apple"
See also
left(), mid(), endsWith()

Definition at line 3682 of file qstring.cpp.

Referenced by _q_escapeIdentifier(), QKeySequence::assign(), computeElidedText(), QNativeWifiEngine::disconnectFromId(), DumpIDL(), QFileSystemEngine::fillPermissions(), QPatternist::NamePool::fromClarkName(), QUrl::fromLocalFile(), getLocations(), QGtkStylePrivate::getThemeName(), QLCDNumberPrivate::internalSetString(), isUncRoot(), loadEngine(), menuItemEntry(), QGtkStyle::pixelMetric(), qIsEffectiveTLD(), qSplitTableAndOwner(), QFileDialogPrivate::qt_mac_filedialog_event_proc(), QFileDialogPrivate::qt_mac_filedialog_filter_proc(), qt_set_x11_resources(), qTopLevelDomain(), QUrlPrivate::setUserInfo(), QMenuPrivate::QMacMenuPrivate::syncAction(), and UpdateRegistry().

3683 {
3684  if (n >= d->size || n < 0)
3685  return *this;
3686  return QString((const QChar*) d->data + d->size - n, n);
3687 }
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
Data * d
Definition: qstring.h:618
ushort * data
Definition: qstring.h:606
QString()
Constructs a null string.
Definition: qstring.h:879

◆ rightJustified()

QString QString::rightJustified ( int  width,
QChar  fill = QLatin1Char(' '),
bool  truncate = false 
) const

Returns a string of size() width that contains the fill character followed by the string.

For example:

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

If truncate is false and the size() of the string is more than width, then the returned string is a copy of the string.

If truncate is true and the size() of the string is more than width, then the resulting string is truncated at position width.

QString str = "Pineapple";
str = str.rightJustified(5, '.', true); // str == "Pinea"
See also
leftJustified()

Definition at line 5357 of file qstring.cpp.

Referenced by getFmtString(), QLCDNumberPrivate::internalSetString(), and vsprintf().

5358 {
5359  QString result;
5360  int len = length();
5361  int padlen = width - len;
5362  if (padlen > 0) {
5363  result.resize(len+padlen);
5364  QChar *uc = (QChar*)result.d->data;
5365  while (padlen--)
5366  * uc++ = fill;
5367  if (len)
5368  memcpy(uc, d->data, sizeof(QChar)*len);
5369  } else {
5370  if (truncate)
5371  result = left(width);
5372  else
5373  result = *this;
5374  }
5375  return result;
5376 }
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
The QString class provides a Unicode character string.
Definition: qstring.h:83
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
void truncate(int pos)
Truncates the string at the given position index.
Definition: qstring.cpp:4603
QString left(int n) const Q_REQUIRED_RESULT
Returns a substring that contains the n leftmost characters of the string.
Definition: qstring.cpp:3664
Data * d
Definition: qstring.h:618
void resize(int size)
Sets the size of the string to size characters.
Definition: qstring.cpp:1353
ushort * data
Definition: qstring.h:606
QString & fill(QChar c, int size=-1)
Sets every character in the string to character ch.
Definition: qstring.cpp:4641

◆ rightRef()

QStringRef QString::rightRef ( int  n) const

Returns a substring reference to the n rightmost characters of the string.

Since
4.4

If n is greater than size() or less than zero, a reference to the entire string is returned.

QString x = "Pineapple";
QStringRef y = x.rightRef(5); // y == "apple"
See also
right(), leftRef(), midRef(), endsWith()

Definition at line 9068 of file qstring.cpp.

9069 {
9070  if (n >= d->size || n < 0)
9071  n = d->size;
9072  return QStringRef(this, d->size - n, n);
9073 }
Data * d
Definition: qstring.h:618
friend class QStringRef
Definition: qstring.h:644

◆ section() [1/3]

QString QString::section ( QChar  sep,
int  start,
int  end = -1,
SectionFlags  flags = SectionDefault 
) const
inline

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 behavior, e.g. whether to be case sensitive, whether to skip empty fields and how to deal with leading and trailing separators; see SectionFlags.

QString str;
QString csv = "forename,middlename,surname,phone";
QString path = "/usr/local/bin/myapp"; // First field is empty
str = csv.section(',', 2, 2); // str == "surname"
str = path.section('/', 3, 4); // str == "bin/myapp"
str = path.section('/', 3, 3, flag); // str == "myapp"

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.

str = csv.section(',', -3, -2); // str == "middlename,surname"
str = path.section('/', -1); // str == "myapp"
See also
split()

Definition at line 781 of file qstring.h.

Referenced by EGLNullWSScreen::connect(), QConnmanEngine::connectToId(), QDeclarativeListViewPrivate::createItem(), QConnmanEngine::disconnectFromId(), QConnmanEngine::isRoamingAllowed(), qt_init(), QVNCIntegration::QVNCIntegration(), section(), QSqlRelationalTableModel::selectStatement(), and QDeclarativeListViewPrivate::updateCurrentSection().

782 { return section(QString(asep), astart, aend, aflags); }
QString section(QChar sep, int start, int end=-1, SectionFlags flags=SectionDefault) const
This function returns a section of the string.
Definition: qstring.h:781
QString()
Constructs a null string.
Definition: qstring.h:879

◆ section() [2/3]

QString QString::section ( const QString in_sep,
int  start,
int  end = -1,
SectionFlags  flags = SectionDefault 
) const

Definition at line 3526 of file qstring.cpp.

3527 {
3528  QStringList sections = split(sep, KeepEmptyParts,
3530  if (sections.isEmpty())
3531  return QString();
3532  if (!(flags & SectionSkipEmpty)) {
3533  if (start < 0)
3534  start += sections.count();
3535  if (end < 0)
3536  end += sections.count();
3537  } else {
3538  int skip = 0;
3539  for (int k=0; k<sections.size(); ++k) {
3540  if (sections.at(k).isEmpty())
3541  skip++;
3542  }
3543  if (start < 0)
3544  start += sections.count() - skip;
3545  if (end < 0)
3546  end += sections.count() - skip;
3547  }
3548  int x = 0;
3549  QString ret;
3550  int first_i = start, last_i = end;
3551  for (int i = 0; x <= end && i < sections.size(); ++i) {
3552  QString section = sections.at(i);
3553  const bool empty = section.isEmpty();
3554  if (x >= start) {
3555  if(x == start)
3556  first_i = i;
3557  if(x == end)
3558  last_i = i;
3559  if(x > start)
3560  ret += sep;
3561  ret += section;
3562  }
3563  if (!empty || !(flags & SectionSkipEmpty))
3564  x++;
3565  }
3566  if((flags & SectionIncludeLeadingSep) && first_i)
3567  ret.prepend(sep);
3568  if((flags & SectionIncludeTrailingSep) && last_i < sections.size()-1)
3569  ret += sep;
3570  return ret;
3571 }
QString section(QChar sep, int start, int end=-1, SectionFlags flags=SectionDefault) const
This function returns a section of the string.
Definition: qstring.h:781
iterator end()
Returns an STL-style iterator pointing to the imaginary character after the last character in the str...
Definition: qstring.h:894
QString & prepend(QChar c)
Definition: qstring.h:261
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
The QString class provides a Unicode character string.
Definition: qstring.h:83
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
QStringList split(const QString &sep, SplitBehavior behavior=KeepEmptyParts, Qt::CaseSensitivity cs=Qt::CaseSensitive) const Q_REQUIRED_RESULT
Splits the string into substrings wherever sep occurs, and returns the list of those strings...
Definition: qstring.cpp:6526
QString()
Constructs a null string.
Definition: qstring.h:879

◆ section() [3/3]

QString QString::section ( const QRegExp reg,
int  start,
int  end = -1,
SectionFlags  flags = SectionDefault 
) const

Definition at line 3597 of file qstring.cpp.

3598 {
3599  const QChar *uc = unicode();
3600  if(!uc)
3601  return QString();
3602 
3603  QRegExp sep(reg);
3604  sep.setCaseSensitivity((flags & SectionCaseInsensitiveSeps) ? Qt::CaseInsensitive
3605  : Qt::CaseSensitive);
3606 
3607  QList<qt_section_chunk> sections;
3608  int n = length(), m = 0, last_m = 0, last_len = 0;
3609  while ((m = sep.indexIn(*this, m)) != -1) {
3610  sections.append(qt_section_chunk(last_len, QString(uc + last_m, m - last_m)));
3611  last_m = m;
3612  last_len = sep.matchedLength();
3613  m += qMax(sep.matchedLength(), 1);
3614  }
3615  sections.append(qt_section_chunk(last_len, QString(uc + last_m, n - last_m)));
3616 
3617  if(start < 0)
3618  start += sections.count();
3619  if(end < 0)
3620  end += sections.count();
3621 
3622  QString ret;
3623  int x = 0;
3624  int first_i = start, last_i = end;
3625  for (int i = 0; x <= end && i < sections.size(); ++i) {
3626  const qt_section_chunk &section = sections.at(i);
3627  const bool empty = (section.length == section.string.length());
3628  if (x >= start) {
3629  if(x == start)
3630  first_i = i;
3631  if(x == end)
3632  last_i = i;
3633  if(x != start)
3634  ret += section.string;
3635  else
3636  ret += section.string.mid(section.length);
3637  }
3638  if (!empty || !(flags & SectionSkipEmpty))
3639  x++;
3640  }
3641  if((flags & SectionIncludeLeadingSep) && first_i < sections.size()) {
3642  const qt_section_chunk &section = sections.at(first_i);
3643  ret.prepend(section.string.left(section.length));
3644  }
3645  if((flags & SectionIncludeTrailingSep) && last_i+1 <= sections.size()-1) {
3646  const qt_section_chunk &section = sections.at(last_i+1);
3647  ret += section.string.left(section.length);
3648  }
3649  return ret;
3650 }
QString section(QChar sep, int start, int end=-1, SectionFlags flags=SectionDefault) const
This function returns a section of the string.
Definition: qstring.h:781
iterator end()
Returns an STL-style iterator pointing to the imaginary character after the last character in the str...
Definition: qstring.h:894
The QRegExp class provides pattern matching using regular expressions.
Definition: qregexp.h:61
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
QString & prepend(QChar c)
Definition: qstring.h:261
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
The QString class provides a Unicode character string.
Definition: qstring.h:83
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
QString left(int n) const Q_REQUIRED_RESULT
Returns a substring that contains the n leftmost characters of the string.
Definition: qstring.cpp:3664
const QChar * unicode() const
Returns a &#39;\0&#39;-terminated Unicode representation of the string.
Definition: qstring.h:706
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
QString mid(int position, int n=-1) const Q_REQUIRED_RESULT
Returns a string that contains n characters of this string, starting at the specified position index...
Definition: qstring.cpp:3706
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
QString()
Constructs a null string.
Definition: qstring.h:879
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ setNum() [1/10]

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

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

Definition at line 729 of file qstring.h.

Referenced by number(), QLabel::setNum(), and setNum().

730 { return setNum(qlonglong(n), base); }
static const uint base
Definition: qurl.cpp:268
QString & setNum(short, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qstring.h:729
qint64 qlonglong
Definition: qglobal.h:951

◆ setNum() [2/10]

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

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

Definition at line 731 of file qstring.h.

732 { return setNum(qulonglong(n), base); }
static const uint base
Definition: qurl.cpp:268
QString & setNum(short, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qstring.h:729
quint64 qulonglong
Definition: qglobal.h:952

◆ setNum() [3/10]

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

Sets the string to the printed value of n in the specified base, and returns a reference to the string.

The base is 10 by default and must be between 2 and 36. For bases other than 10, n is treated as an unsigned integer.

QString str;
str.setNum(1234); // str == "1234"

The formatting always uses QLocale::C, i.e., English/UnitedStates. To get a localized string representation of a number, use QLocale::toString() with the appropriate locale.

Definition at line 733 of file qstring.h.

734 { return setNum(qlonglong(n), base); }
static const uint base
Definition: qurl.cpp:268
QString & setNum(short, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qstring.h:729
qint64 qlonglong
Definition: qglobal.h:951

◆ setNum() [4/10]

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

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

Definition at line 735 of file qstring.h.

736 { return setNum(qulonglong(n), base); }
static const uint base
Definition: qurl.cpp:268
QString & setNum(short, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qstring.h:729
quint64 qulonglong
Definition: qglobal.h:952

◆ setNum() [5/10]

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

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

Definition at line 737 of file qstring.h.

738 { return setNum(qlonglong(n), base); }
static const uint base
Definition: qurl.cpp:268
QString & setNum(short, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qstring.h:729
qint64 qlonglong
Definition: qglobal.h:951

◆ setNum() [6/10]

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

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

Definition at line 739 of file qstring.h.

740 { return setNum(qulonglong(n), base); }
static const uint base
Definition: qurl.cpp:268
QString & setNum(short, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qstring.h:729
quint64 qulonglong
Definition: qglobal.h:952

◆ setNum() [7/10]

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

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

Definition at line 6307 of file qstring.cpp.

6308 {
6309 #if defined(QT_CHECK_RANGE)
6310  if (base < 2 || base > 36) {
6311  qWarning("QString::setNum: Invalid base (%d)", base);
6312  base = 10;
6313  }
6314 #endif
6315  QLocale locale(QLocale::C);
6316  *this = locale.d()->longLongToString(n, -1, base);
6317  return *this;
6318 }
static const uint base
Definition: qurl.cpp:268
Q_CORE_EXPORT void qWarning(const char *,...)

◆ setNum() [8/10]

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

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

Definition at line 6323 of file qstring.cpp.

6324 {
6325 #if defined(QT_CHECK_RANGE)
6326  if (base < 2 || base > 36) {
6327  qWarning("QString::setNum: Invalid base (%d)", base);
6328  base = 10;
6329  }
6330 #endif
6331  QLocale locale(QLocale::C);
6332  *this = locale.d()->unsLongLongToString(n, -1, base);
6333  return *this;
6334 }
static const uint base
Definition: qurl.cpp:268
Q_CORE_EXPORT void qWarning(const char *,...)

◆ setNum() [9/10]

QString & QString::setNum ( float  n,
char  format = 'g',
int  precision = 6 
)
inline

Sets the string to the printed value of n, formatted according to the given format and precision, and returns a reference to the string.

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

Definition at line 741 of file qstring.h.

742 { return setNum(double(n),f,prec); }
QString & setNum(short, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qstring.h:729

◆ setNum() [10/10]

QString & QString::setNum ( double  n,
char  format = 'g',
int  precision = 6 
)

Sets the string to the printed value of n, formatted according to the given format and precision, and returns a reference to the string.

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

The format can be 'f', 'F', 'e', 'E', 'g' or 'G' (see the arg() function documentation for an explanation of the formats).

Unlike QLocale::toString(), this function doesn't honor the user's locale settings.

Definition at line 6364 of file qstring.cpp.

6365 {
6367  uint flags = 0;
6368 
6369  if (qIsUpper(f))
6371  f = qToLower(f);
6372 
6373  switch (f) {
6374  case 'f':
6376  break;
6377  case 'e':
6379  break;
6380  case 'g':
6382  break;
6383  default:
6384 #if defined(QT_CHECK_RANGE)
6385  qWarning("QString::setNum: Invalid format char '%c'", f);
6386 #endif
6387  break;
6388  }
6389 
6390  QLocale locale(QLocale::C);
6391  *this = locale.d()->doubleToString(n, prec, form, -1, flags);
6392  return *this;
6393 }
Q_CORE_EXPORT void qWarning(const char *,...)
unsigned int uint
Definition: qglobal.h:996
bool qIsUpper(char ch)
Definition: qstring.cpp:362
char qToLower(char ch)
Definition: qstring.cpp:372

◆ setRawData()

QString & QString::setRawData ( const QChar unicode,
int  size 
)

Resets the QString to use the first size Unicode characters in the array unicode.

Since
4.7

The data in unicode is not copied. The caller must be able to guarantee that unicode will not be deleted or modified as long as the QString (or an unmodified copy of it) exists.

This function can be used instead of fromRawData() to re-use existings QString objects to save memory re-allocations.

See also
fromRawData()

Definition at line 7707 of file qstring.cpp.

7708 {
7709  if (d->ref != 1 || (d->data == d->array && d->alloc)) {
7710  *this = fromRawData(unicode, size);
7711  } else {
7712 #ifdef QT3_SUPPORT
7713  if (d->asciiCache) {
7714  QMutexLocker locker(asciiCacheMutex());
7715  Q_ASSERT(asciiCache);
7716  asciiCache->remove(d);
7717  }
7718 #endif
7719  if (unicode) {
7720  d->data = (ushort *)unicode;
7721  } else {
7722  d->data = d->array;
7723  size = 0;
7724  }
7725  d->alloc = d->size = size;
7726  *d->array = '\0';
7727  d->clean = d->asciiCache = d->simpletext = d->righttoleft = d->capacity = 0;
7728  }
7729  return *this;
7730 }
ushort capacity
Definition: qstring.h:611
ushort clean
Definition: qstring.h:607
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
static QString fromRawData(const QChar *, int size)
Constructs a QString that uses the first size Unicode characters in the array unicode.
Definition: qstring.cpp:7673
QBasicAtomicInt ref
Definition: qstring.h:604
int size() const
Returns the number of characters in this string.
Definition: qstring.h:102
Data * d
Definition: qstring.h:618
ushort * data
Definition: qstring.h:606
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
unsigned short ushort
Definition: qglobal.h:995
ushort array[1]
Definition: qstring.h:614
ushort righttoleft
Definition: qstring.h:609
ushort simpletext
Definition: qstring.h:608
ushort asciiCache
Definition: qstring.h:610

◆ setUnicode()

QString & QString::setUnicode ( const QChar unicode,
int  size 
)

Resizes the string to size characters and copies unicode into the string.

If unicode is 0, nothing is copied, but the string is still resized to size.

See also
unicode(), setUtf16()

Definition at line 4377 of file qstring.cpp.

Referenced by setUtf16().

4378 {
4379  resize(size);
4380  if (unicode && size)
4381  memcpy(d->data, unicode, size * sizeof(QChar));
4382  return *this;
4383 }
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
int size() const
Returns the number of characters in this string.
Definition: qstring.h:102
Data * d
Definition: qstring.h:618
void resize(int size)
Sets the size of the string to size characters.
Definition: qstring.cpp:1353
ushort * data
Definition: qstring.h:606

◆ setUtf16()

QString & QString::setUtf16 ( const ushort unicode,
int  size 
)
inline

Resizes the string to size characters and copies unicode into the string.

If unicode is 0, nothing is copied, but the string is still resized to size.

Note that unlike fromUtf16(), this function does not consider BOMs and possibly differing byte ordering.

See also
utf16(), setUnicode()

Definition at line 882 of file qstring.h.

Referenced by vsprintf().

883 { return setUnicode(reinterpret_cast<const QChar *>(autf16), asize); }
QString & setUnicode(const QChar *unicode, int size)
Resizes the string to size characters and copies unicode into the string.
Definition: qstring.cpp:4377

◆ simplified()

QString QString::simplified ( ) const

Returns a string that has whitespace removed from the start and the end, and that has each sequence of internal whitespace replaced with a single space.

Whitespace means any character for which QChar::isSpace() returns true. This includes the ASCII characters '\t', '\n', '\v', '\f', '\r', and ' '.

Example:

QString str = " lots\t of\nwhitespace\r\n ";
str = str.simplified();
// str == "lots of whitespace";
See also
trimmed()

Definition at line 4415 of file qstring.cpp.

Referenced by QPatternist::AccelTreeBuilder< true >::attribute(), comify(), QSvgText::draw(), QPatternist::Base64Binary::fromLexical(), QPatternist::XsdTypeChecker::fromLexical(), QPatternist::DerivedString< TypeToken >::fromLexical(), QImageReaderPrivate::getText(), QPatternist::XsdTypeChecker::normalizedValue(), QIBaseDriver::open(), QMYSQLDriver::open(), QSplitter::operator>>(), QHostAddressPrivate::parse(), QDateTimeParser::parse(), QXmlStreamReaderPrivate::parse(), QPatternist::XsdSchemaParser::parseGlobalElement(), QHttpResponseHeader::parseLine(), QHttpRequestHeader::parseLine(), QIBaseDriver::primaryIndex(), QTDSDriver::primaryIndex(), QFtpPI::processReply(), QTextHtmlImporter::processSpecialNodes(), QPatternist::AttributeConstructor::processValue(), QPatternist::XsdValidatingInstanceReader::qNameAttribute(), qODBCWarn(), qParseOpts(), qt_parseEtcLpPrinters(), qt_parsePrinterDesc(), qt_parsePrintersConf(), qt_parseQconfig(), qt_parseSpoolInterface(), qt_perhapsAddPrinter(), qt_set_x11_resources(), qt_strip_filters(), QPatternist::XsdSchemaParser::readNameAttribute(), QPngHandlerPrivate::readPngTexts(), QPatternist::XsdSchemaParser::readQNameAttribute(), QIBaseResult::record(), QIBaseDriver::record(), QTDSDriver::record(), set_text(), QImageWriter::setText(), styleStringHelper(), QIBaseDriver::tables(), QTDSDriver::tables(), QPatternist::AnyURI::toQUrl(), and QPatternist::XsdValidatingInstanceReader::validateElementComplexType().

4416 {
4417  if (d->size == 0)
4418  return *this;
4419 
4420  const QChar * const start = reinterpret_cast<QChar *>(d->data);
4421  const QChar *from = start;
4422  const QChar *fromEnd = start + d->size;
4423  forever {
4424  QChar ch = *from;
4425  if (!ch.isSpace())
4426  break;
4427  if (++from == fromEnd) {
4428  // All-whitespace string
4429  shared_empty.ref.ref();
4430  return QString(&shared_empty, 0);
4431  }
4432  }
4433  // This loop needs no underflow check, as we already determined that
4434  // the string contains non-whitespace. If the string has exactly one
4435  // non-whitespace, it will be checked twice - we can live with that.
4436  while (fromEnd[-1].isSpace())
4437  fromEnd--;
4438  // The rest of the function depends on the fact that we already know
4439  // that the last character in the source is no whitespace.
4440  const QChar *copyFrom = from;
4441  int copyCount;
4442  forever {
4443  if (++from == fromEnd) {
4444  // Only leading and/or trailing whitespace, if any at all
4445  return mid(copyFrom - start, from - copyFrom);
4446  }
4447  QChar ch = *from;
4448  if (!ch.isSpace())
4449  continue;
4450  if (ch != QLatin1Char(' ')) {
4451  copyCount = from - copyFrom;
4452  break;
4453  }
4454  ch = *++from;
4455  if (ch.isSpace()) {
4456  copyCount = from - copyFrom - 1;
4457  break;
4458  }
4459  }
4460  // 'from' now points at the non-trailing whitespace which made the
4461  // string not simplified in the first place. 'copyCount' is the number
4462  // of already simplified characters - at least one, obviously -
4463  // without a trailing space.
4464  QString result((fromEnd - from) + copyCount, Qt::Uninitialized);
4465  QChar *to = reinterpret_cast<QChar *>(result.d->data);
4466  ::memcpy(to, copyFrom, copyCount * 2);
4467  to += copyCount;
4468  fromEnd--;
4469  QChar ch;
4470  forever {
4471  *to++ = QLatin1Char(' ');
4472  do {
4473  ch = *++from;
4474  } while (ch.isSpace());
4475  if (from == fromEnd)
4476  break;
4477  do {
4478  *to++ = ch;
4479  ch = *++from;
4480  if (from == fromEnd)
4481  goto done;
4482  } while (!ch.isSpace());
4483  }
4484  done:
4485  *to++ = ch;
4486  result.truncate(to - reinterpret_cast<QChar *>(result.d->data));
4487  return result;
4488 }
The QString class provides a Unicode character string.
Definition: qstring.h:83
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
QBasicAtomicInt ref
Definition: qstring.h:604
bool isSpace() const
Returns true if the character is a separator character (Separator_* categories); otherwise returns fa...
Definition: qchar.cpp:609
Data * d
Definition: qstring.h:618
ushort * data
Definition: qstring.h:606
QString mid(int position, int n=-1) const Q_REQUIRED_RESULT
Returns a string that contains n characters of this string, starting at the specified position index...
Definition: qstring.cpp:3706
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
QString()
Constructs a null string.
Definition: qstring.h:879
static Data shared_empty
Definition: qstring.h:617
#define forever
This macro is provided for convenience for writing infinite loops.
Definition: qglobal.h:2452

◆ size()

int QString::size ( ) const
inline

Returns the number of characters in this string.

The last character in the string is at position size() - 1. In addition, QString ensures that the character at position size() is always '\0', so that you can use the return value of data() and constData() as arguments to functions that expect '\0'-terminated strings.

Example:

QString str = "World";
int n = str.size(); // n == 5
str.data()[0]; // returns 'W'
str.data()[4]; // returns 'd'
str.data()[5]; // returns '\0'
See also
isEmpty(), resize()

Definition at line 102 of file qstring.h.

Referenced by QDateTimeEditPrivate::_q_editorCursorPositionChanged(), QAbstractSpinBoxPrivate::_q_editorCursorPositionChanged(), _q_resolveEntryAndCreateLegacyEngine_recursive(), QWindowsFileSystemWatcherEngine::addPaths(), QXmlStreamPrivateTagStack::addToStringStorage(), append(), QTextHtmlImporter::appendNodeText(), QConcatenable< QString >::appendTo(), QStringRef::appendTo(), QTextHtmlParser::applyAttributes(), at(), QStringRef::at(), QDirModelPrivate::children(), QConfFileSettingsPrivate::children(), QMacSettingsPrivate::children(), QXmlStreamReaderPrivate::clearSym(), QDateTimeEditPrivate::closestSection(), QPatternist::ColoringMessageHandler::colorifyDescription(), comify(), QScriptCompletionTaskPrivate::completeScriptExpression(), QTextDocumentPrivate::compressPieceTable(), QVNCScreen::connect(), QMultiScreen::connect(), QTransformedScreen::connect(), QTextStreamPrivate::consume(), containsProhibitedOuptut(), QDialog::contextMenuEvent(), QAbstractConcatenable::convertFromAscii(), QStringBuilder< A, B >::convertTo(), count(), QStringRef::count(), QCalendarDateValidator::countRepeat(), countRepeat(), QScriptDebuggerConsolePrivate::createJob(), QScriptDeclarativeClass::createPersistentIdentifier(), QLocalePrivate::dateTimeToString(), QPatternist::CompressedWhitespace::decompress(), QDeclarativeJS::TextWriter::doReplace(), driveSpec(), elliditide(), QSettings::endArray(), QSettings::endGroup(), endsWith(), QStringRef::endsWith(), QScriptDebuggerCodeView::event(), QSQLiteResult::exec(), QODBCResult::exec(), QXmlStreamReaderPrivate::fastScanContentCharList(), QXmlStreamReaderPrivate::fastScanName(), QXmlStreamReaderPrivate::fastScanNMTOKEN(), QXmlInputSource::fetchData(), fileName(), QFileSystemEngine::fillMetaData(), QTextStreamPrivate::fillReadBuffer(), QDateTimeParser::findAmPm(), QDateTimeParser::findDay(), QFileSystemEntry::findFileNameSeparators(), QFileSystemEntry::findLastSeparator(), QDateTimeParser::findMonth(), QResourceRoot::findNode(), fixedCharData(), fixedXmlName(), QTextStreamPrivate::flushWriteBuffer(), fromLatin1_helper(), fromRawData(), QDateTime::fromString(), fromUcs4(), fromUtf16(), QWindowsAccessible::get_accDescription(), QWindowsAccessible::get_accHelp(), QWindowsAccessible::get_accKeyboardShortcut(), QWindowsAccessible::get_accName(), QTextStreamPrivate::getChar(), QXmlStreamReaderPrivate::getChar(), QXmlStreamReaderPrivate::getChar_helper(), getFmtString(), QFileSystemEngine::getLinkTarget(), getLocations(), getVariables(), QRawFont::glyphIndexesForString(), hasUnquotedAP(), QStringMatcher::indexIn(), indexOf(), QStringRef::indexOf(), iniChopTrailingSpaces(), QSettingsPrivate::iniEscapedKey(), QSettingsPrivate::iniEscapedString(), QSettingsPrivate::iniUnescapedStringList(), QTextDocumentPrivate::insert(), isDirPath(), QXmlSimpleReaderPrivate::isExpandedEntityValueTooLarge(), QMYSQLDriver::isIdentifierEscapedImplementation(), QODBCDriver::isIdentifierEscapedImplementation(), QSqlDriver::isIdentifierEscapedImplementation(), QUrl::isParentOf(), XPThemeData::isValid(), QAbstractSpinBox::keyPressEvent(), lastIndexOf(), QStringRef::lastIndexOf(), macToQtFormat(), mapToLowerCase(), QDirIteratorPrivate::matchesFilters(), QMacPasteboardMimeAny::mimeFor(), QLastResortMimes::mimeForFormat(), QSqlResultPrivate::namedToPositionalBinding(), QFileSystemEngine::nativeAbsoluteFilePath(), QSettingsPrivate::normalizedKey(), operator+=(), QByteArray::operator<(), QByteArray::operator<=(), QStringRef::operator=(), QStringRef::operator==(), QByteArray::operator>(), QByteArray::operator>=(), operator[](), QDateTimeParser::parse(), QXmlStreamReaderPrivate::parse(), QTextHtmlParser::parseAttributes(), parseCombinedArgString(), QDateTimeParser::parseFormat(), parseIp6(), QDateTimeParser::parseSection(), QTextHtmlParser::parseTag(), QXmlStreamReaderPrivate::peekChar(), QGtkStyle::pixelMetric(), populate_database(), QSqlResultPrivate::positionalToNamedBinding(), QDateTimeParser::potentialValue(), QSQLiteResult::prepare(), QSqlResult::prepare(), QCss::Scanner::preprocess(), QXmlNamespaceSupport::processName(), QPatternist::NamespaceSupport::processName(), QXmlStreamReaderPrivate::putReplacement(), QXmlStreamReaderPrivate::putReplacementInAttributeValue(), QTextStreamPrivate::putString(), QXmlStreamReaderPrivate::putString(), QXmlStreamReaderPrivate::putStringLiteral(), qHash(), QIconTheme::QIconTheme(), qIsEffectiveTLD(), QString(), QtPrivate::QStringList_join(), QStringMatcher::QStringMatcher(), QStringRef::QStringRef(), qt_ACE_do(), qt_is_idn_enabled(), qt_mac_removeMnemonics(), qt_nameprep(), qt_readEscapedFormatString(), qt_repeatCount(), qt_string_count(), qt_strippedText(), qt_u_strToCase(), qt_win_get_save_file_name(), qTopLevelDomain(), QtWndProc(), QXmlStreamAttribute::QXmlStreamAttribute(), QTextStreamPrivate::read(), QXmlStreamReader::readElementText(), readLink(), QTextStreamPrivate::readPtr(), readSymLink(), QSqlRelationalTableModelPrivate::relationField(), QDir::relativeFilePath(), remove(), replace(), resize(), rotateSlashesDotsAndMiddots(), QWhatsThisPrivate::say(), QTextStreamPrivate::scan(), QXmlStreamReaderPrivate::scanString(), QXmlStreamReaderPrivate::scanUntil(), QDateTimeEditPrivate::sectionAt(), QDateTimeParser::sectionMaxSize(), QTextStream::seek(), QSettings::setArrayIndex(), QStringMatcher::setCaseSensitivity(), QWSRegionCommand::setData(), QCalendarDateValidator::setFormat(), QStringMatcher::setPattern(), setRawData(), QWorkspacePrivate::showMaximizeControls(), QConcatenable< QString >::size(), QDateTimeParser::skipToNextSection(), QFileSystemEngine::slowCanonicalized(), split(), QXmlNamespaceSupport::splitName(), startsWith(), QStringRef::startsWith(), QSettingsPrivate::stringToVariant(), QPatternist::AbstractFloat< isDouble >::stringValue(), QAbstractSpinBoxPrivate::stripped(), QAccessibleMenu::text(), timeFormatContainsAP(), QFileDialogPrivate::toInternal(), QTextDocument::toPlainText(), QUrl::toPunycode(), toPunycodeHelper(), toSQLTCHAR(), QPatternist::Decimal::toString(), truncate(), tryDriveUNCFallback(), QSystemLocalePrivate::uiLanguages(), unquote(), QDateTimeEditPrivate::updateEdit(), QAbstractSpinBoxPrivate::updateEdit(), QSpinBoxValidator::validate(), QRegExpValidator::validate(), QDateTimeEditPrivate::validateAndInterpret(), QDoubleSpinBoxPrivate::validateAndInterpret(), QSystemLocalePrivate::winToQtFormat(), QTextStreamPrivate::write(), QXmlStreamWriterPrivate::writeEscaped(), and xpmHash().

102 { return d->size; }
Data * d
Definition: qstring.h:618

◆ split() [1/3]

QStringList QString::split ( const QString sep,
SplitBehavior  behavior = KeepEmptyParts,
Qt::CaseSensitivity  cs = Qt::CaseSensitive 
) const

Splits the string into substrings wherever sep occurs, and returns the list of those strings.

If sep does not match anywhere in the string, split() returns a single-element list containing this string.

cs specifies whether sep should be matched case sensitively or case insensitively.

If behavior is QString::SkipEmptyParts, empty entries don't appear in the result. By default, empty entries are kept.

Example:

QString str = "a,,b,c";
QStringList list1 = str.split(",");
// list1: [ "a", "", "b", "c" ]
// list2: [ "a", "b", "c" ]
See also
QStringList::join(), section()

Definition at line 6526 of file qstring.cpp.

Referenced by QScript::__setupPackage__(), QScriptEngine::availableExtensions(), QCss::StyleSelector::basicSelectorMatches(), Maemo::conn_settings_notify_func(), EGLNullWSScreen::connect(), QQnxScreen::connect(), QVNCScreen::connect(), QVFbScreen::connect(), QMultiScreen::connect(), PvrEglScreen::connect(), QLinuxFbScreen::connect(), QLinuxFbIntegration::connect(), QDirectFBScreen::connect(), convertWithPalette(), QPlatformIntegrationFactory::create(), QScriptDebuggerConsolePrivate::createJob(), createSvgNode(), QScriptDebuggerLocalsModel::data(), determineScreenSize(), QGtkStylePrivate::extract_filter(), familyList(), QWSSoundServerPrivate::feedDevice(), QDeclarativeStateGroupPrivate::findTransition(), QDate::fromString(), QFont::fromString(), QDateTime::fromString(), QImageReaderPrivate::getText(), QGtkStylePrivate::getThemeName(), QScriptToolTipJob::handleResponse(), QGuiPlatformPlugin::iconThemeSearchPaths(), QScriptEngine::importExtension(), QDirModel::index(), QDeclarativePropertyPrivate::initProperty(), QPatternist::XSLTTokenizer::insideTemplate(), QLibrary::isLibrary(), QPatternist::XPathHelper::isQName(), QDBusUtil::isValidBusName(), QDBusUtil::isValidInterfaceName(), QDBusUtil::isValidObjectPath(), QPatternist::XsdTypeChecker::isValidString(), QDBusUtil::isValidUniqueConnectionName(), QMetaEnum::keysToValue(), QStringList::lastIndexOf(), libGreaterThan(), libraryPathList(), QCoreApplication::libraryPaths(), QSystemLibrary::load(), QAxServerBase::Load(), QLibraryInfo::location(), QResourceRoot::mappingRootSubdir(), QFileSystemModelPrivate::node(), QDBusConnection::objectRegisteredAt(), QIBaseDriver::open(), QSQLiteDriver::open(), QDB2Driver::open(), QMYSQLDriver::open(), QWSServer::openKeyboard(), QWSServer::openMouse(), operator<<(), QHttpHeader::parse(), parseAnimateColorNode(), QPatternist::XsdSchemaParser::parseAny(), QPatternist::XsdSchemaParser::parseAnyAttribute(), QPatternist::XsdSchemaParser::parseGlobalElement(), parseIp4(), parseIp6(), QHttpRequestHeader::parseLine(), QPatternist::XsdSchemaParser::parseSchema(), QHostAddress::parseSubnet(), QPatternist::XsdSchemaParser::parseUnion(), QGtkStyle::pixelMetric(), QTDSDriver::primaryIndex(), QFtpPI::processReply(), qDBusGenerateMetaObjectXml(), qDBusInterfaceFromMetaObject(), QDeclarativeImportDatabase::QDeclarativeImportDatabase(), qExtractSecurityPolicyFromString(), qGetODBCVersion(), QLinuxInputKeyboardHandler::QLinuxInputKeyboardHandler(), qOpenGLVersionFlagsFromString(), qParseOpts(), qSplitTableQualifier(), QSslSocketBackendPrivate::QSslCipher_from_SSL_CIPHER(), qt_clean_filter_list(), qt_getDefaultFromHomePrinters(), QApplicationPrivate::qt_mac_apply_settings(), QFileDialogPrivate::qt_mac_filedialog_event_proc(), QFileDialogPrivate::qt_mac_filedialog_filter_proc(), qt_make_filter_list(), qt_parsePrinterDesc(), qt_parsePrintersConf(), qt_tildeExpansion(), qt_win_extract_filter(), qTopLevelDomain(), QWin32PrintEnginePrivate::queryDefault(), QWSKbPrivate::QWSKbPrivate(), QWSLinuxInputKbPrivate::QWSLinuxInputKbPrivate(), QWSLinuxInputMousePrivate::QWSLinuxInputMousePrivate(), QWSPcMouseHandlerPrivate::QWSPcMouseHandlerPrivate(), QWSTslibMouseHandlerPrivate::QWSTslibMouseHandlerPrivate(), QWSTtyKbPrivate::QWSTtyKbPrivate(), rasterFallbacksMask(), QPatternist::XsdSchemaParser::readBlockingConstraintAttribute(), QPatternist::XsdSchemaParser::readDerivationConstraintAttribute(), registerFont(), QDBusConnection::registerObject(), QDir::relativeFilePath(), QAxServerBase::Save(), section(), set_text(), QSslSocket::setCiphers(), QDirectFBScreenPrivate::setFlipFlags(), QScriptExtensionPlugin::setupPackage(), QDirPrivate::splitFilters(), QFSCompleter::splitPath(), QCompleter::splitPath(), QPatternist::XPathHelper::splitQName(), QProcessPrivate::startDetached(), QProcessPrivate::startProcess(), stringToList(), QFileDialogPrivate::typedFiles(), uncShareExists(), QDBusConnection::unregisterObject(), QPatternist::XsdValidatingInstanceReader::validate(), QPatternist::XsdValidatingInstanceReader::validateAttribute(), QPatternist::XsdValidatingInstanceReader::validateElementSimpleType(), QPatternist::XsdTypeChecker::valuesAreEqual(), and QApplicationPrivate::x11_apply_settings().

6527 {
6528  QStringList list;
6529  int start = 0;
6530  int extra = 0;
6531  int end;
6532  while ((end = indexOf(sep, start + extra, cs)) != -1) {
6533  if (start != end || behavior == KeepEmptyParts)
6534  list.append(mid(start, end - start));
6535  start = end + sep.size();
6536  extra = (sep.size() == 0 ? 1 : 0);
6537  }
6538  if (start != size() || behavior == KeepEmptyParts)
6539  list.append(mid(start));
6540  return list;
6541 }
iterator end()
Returns an STL-style iterator pointing to the imaginary character after the last character in the str...
Definition: qstring.h:894
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
int size() const
Returns the number of characters in this string.
Definition: qstring.h:102
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
int indexOf(QChar c, int from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.cpp:2838
QString mid(int position, int n=-1) const Q_REQUIRED_RESULT
Returns a string that contains n characters of this string, starting at the specified position index...
Definition: qstring.cpp:3706

◆ split() [2/3]

QStringList QString::split ( const QChar sep,
SplitBehavior  behavior = KeepEmptyParts,
Qt::CaseSensitivity  cs = Qt::CaseSensitive 
) const

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

Definition at line 6546 of file qstring.cpp.

6547 {
6548  QStringList list;
6549  int start = 0;
6550  int end;
6551  while ((end = indexOf(sep, start, cs)) != -1) {
6552  if (start != end || behavior == KeepEmptyParts)
6553  list.append(mid(start, end - start));
6554  start = end + 1;
6555  }
6556  if (start != size() || behavior == KeepEmptyParts)
6557  list.append(mid(start));
6558  return list;
6559 }
iterator end()
Returns an STL-style iterator pointing to the imaginary character after the last character in the str...
Definition: qstring.h:894
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
int size() const
Returns the number of characters in this string.
Definition: qstring.h:102
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
int indexOf(QChar c, int from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.cpp:2838
QString mid(int position, int n=-1) const Q_REQUIRED_RESULT
Returns a string that contains n characters of this string, starting at the specified position index...
Definition: qstring.cpp:3706

◆ split() [3/3]

QStringList QString::split ( const QRegExp rx,
SplitBehavior  behavior = KeepEmptyParts 
) const

Splits the string into substrings wherever the regular expression rx matches, and returns the list of those strings.

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

If rx does not match anywhere in the string, split() returns a single-element list containing this string.

Here's an example where we extract the words in a sentence using one or more whitespace characters as the separator:

QString str;
str = "Some text\n\twith strange whitespace.";
list = str.split(QRegExp("\\s+"));
// list: [ "Some", "text", "with", "strange", "whitespace." ]

Here's a similar example, but this time we use any sequence of non-word characters as the separator:

str = "This time, a normal English sentence.";
list = str.split(QRegExp("\\W+"), QString::SkipEmptyParts);
// list: [ "This", "time", "a", "normal", "English", "sentence" ]

Here's a third example where we use a zero-length assertion, \b (word boundary), to split the string into an alternating sequence of non-word and word tokens:

str = "Now: this sentence fragment.";
list = str.split(QRegExp("\\b"));
// list: [ "", "Now", ": ", "this", " ", "sentence", " ", "fragment", "." ]
See also
QStringList::join(), section()

Definition at line 6591 of file qstring.cpp.

6592 {
6593  QRegExp rx2(rx);
6594  QStringList list;
6595  int start = 0;
6596  int extra = 0;
6597  int end;
6598  while ((end = rx2.indexIn(*this, start + extra)) != -1) {
6599  int matchedLen = rx2.matchedLength();
6600  if (start != end || behavior == KeepEmptyParts)
6601  list.append(mid(start, end - start));
6602  start = end + matchedLen;
6603  extra = (matchedLen == 0) ? 1 : 0;
6604  }
6605  if (start != size() || behavior == KeepEmptyParts)
6606  list.append(mid(start));
6607  return list;
6608 }
iterator end()
Returns an STL-style iterator pointing to the imaginary character after the last character in the str...
Definition: qstring.h:894
The QRegExp class provides pattern matching using regular expressions.
Definition: qregexp.h:61
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
int size() const
Returns the number of characters in this string.
Definition: qstring.h:102
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
QString mid(int position, int n=-1) const Q_REQUIRED_RESULT
Returns a string that contains n characters of this string, starting at the specified position index...
Definition: qstring.cpp:3706

◆ sprintf()

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

Safely builds a formatted string from the format string cformat and an arbitrary list of arguments.

The lc escape sequence expects a unicode character of type ushort (as returned by QChar::unicode()). The ls escape sequence expects a pointer to a zero-terminated array of unicode characters of type ushort (as returned by QString::utf16()).

Note
This function expects a UTF-8 string for s and Latin-1 for the format string.

The format string supports most of the conversion specifiers provided by printf() in the standard C++ library. It doesn't honor the length modifiers (e.g. h for short, ll for long long). If you need those, use the standard snprintf() function instead:

size_t BufSize;
char buf[BufSize];
::snprintf(buf, BufSize, "%lld", 123456789LL);
Warning
We do not recommend using QString::sprintf() in new Qt code. Instead, consider using QTextStream or arg(), both of which support Unicode strings seamlessly and are type-safe. Here's an example that uses QTextStream:
QString result;
QTextStream(&result) << "pi = " << 3.14;
// result == "pi = 3.14"

For QObject::tr(){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.

See also
arg()

Definition at line 5567 of file qstring.cpp.

Referenced by QVNCScreenPrivate::configure(), decodeMSG(), QHashData::destroyAndFree(), double2string(), int2string(), QColor::name(), QMapData::node_delete(), qt_parseEtcLpPrinters(), QHostAddress::toString(), and write_xpm_image().

5568 {
5569  va_list ap;
5570  va_start(ap, cformat);
5571  QString &s = vsprintf(cformat, ap);
5572  va_end(ap);
5573  return s;
5574 }
The QString class provides a Unicode character string.
Definition: qstring.h:83
QString & vsprintf(const char *format, va_list ap)
Equivalent method to sprintf(), but takes a va_list ap instead a list of variable arguments...
Definition: qstring.cpp:5587

◆ squeeze()

void QString::squeeze ( )
inline

Releases any memory not required to store the character data.

The sole purpose of this function is to provide a means of fine tuning QString's memory usage. In general, you will rarely ever need to call this function.

See also
reserve(), capacity()

Definition at line 114 of file qstring.h.

Referenced by QTextDocumentPrivate::compressPieceTable(), QSettingsPrivate::iniUnescapedStringList(), QSqlResultPrivate::namedToPositionalBinding(), QSqlResultPrivate::positionalToNamedBinding(), and qReplacePlaceholderMarkers().

114 { if (d->size < d->alloc || d->ref != 1) realloc(); d->capacity = 0;}
void realloc()
Definition: qstring.cpp:1472
ushort capacity
Definition: qstring.h:611
QBasicAtomicInt ref
Definition: qstring.h:604
Data * d
Definition: qstring.h:618

◆ startsWith() [1/4]

bool QString::startsWith ( const QString s,
Qt::CaseSensitivity  cs = Qt::CaseSensitive 
) const

Returns true if the string starts with s; otherwise returns false.

If cs is Qt::CaseSensitive (default), the search is case sensitive; otherwise the search is case insensitive.

QString str = "Bananas";
str.startsWith("Ban"); // returns true
str.startsWith("Car"); // returns false
See also
endsWith()

Definition at line 3734 of file qstring.cpp.

Referenced by QFileDialogPrivate::_q_autoCompleteFileName(), QCompleterPrivate::_q_fileSystemModelDirectoryLoaded(), _q_parseUnixDir(), QFontComboBoxPrivate::_q_updateModel(), QFileDialogPrivate::_q_updateOkButton(), QFtpPI::abort(), QNSOpenSavePanelDelegate::acceptableExtensionsForSave, QIcdEngine::addConfiguration(), addFontToDatabase(), QLocalServerPrivate::addListener(), QResource::addSearchPath(), QTextCodec::availableCodecs(), QTextCodec::availableMibs(), QCss::StyleSelector::basicSelectorMatches(), QUnsortedModelEngine::buildIndices(), QWindowsMimeText::canConvertToMime(), QDir::cd(), QMacSettingsPrivate::children(), cleanPath(), QODBCDriver::cleanup(), QDeclarativeStringConverters::colorFromString(), QDeclarativeConnectionsParser::compile(), QScriptDebuggerConsoleCommandManager::completions(), QVNCScreen::connect(), QVFbScreen::connect(), QMultiScreen::connect(), QTransformedScreen::connect(), QLinuxFbScreen::connect(), QLocalSocket::connectToServer(), QScriptDebuggerConsole::consumeInput(), QMacPasteboardMimeHTMLText::convertFromMime(), QTextCodecPlugin::create(), createImageNode(), QDBusMetaObject::createMetaObject(), QDeclarativeListModelParser::definesEmptyList(), QLocalSocketPrivate::destroyPipeHandles(), QTranslatorPrivate::do_load(), QIcdEngine::doRequestUpdate(), QSvgText::draw(), QResourcePrivate::ensureChildren(), QResourcePrivate::ensureInitialized(), QConfFileSettingsPrivate::ensureSectionParsed(), QDB2Driver::escapeIdentifier(), QIBaseDriver::escapeIdentifier(), QSQLite2Driver::escapeIdentifier(), QTDSDriver::escapeIdentifier(), QMYSQLDriver::escapeIdentifier(), QPSQLDriver::escapeIdentifier(), QODBCDriver::escapeIdentifier(), extractEncodingDecl(), familyList(), QSortedModelEngine::filter(), QCompletionEngine::filterHistory(), QDeclarativeImportedNamespace::find(), QNetworkAuthenticationCache::findClosestMatch(), QDateTimeParser::findDay(), QDateTimeParser::findMonth(), QResourceRoot::findNode(), fixIfRelativeUncPath(), QMacPasteboardMimeTiff::flavorFor(), QMacPasteboardMimeUrl::flavorFor(), QMacPasteboardMimeVCard::flavorFor(), QWindowsMimeText::formatsForMime(), QDirectFBPixmapData::fromFile(), QDirectFbBlitterPlatformPixmap::fromFile(), QUrl::fromLocalFile(), QSslCertificate::fromPath(), QDateTime::fromString(), QFileInfoGatherer::getFileInfos(), getFmtString(), getImage(), QFileSystemEngine::getLinkTarget(), getLocations(), getPixmap(), getVariables(), QInternalMimeData::hasFormatHelper(), QUrl::host(), QDirModel::index(), QSQLite2ResultPrivate::init(), QPatternist::XSLTTokenizer::insideSequenceConstructor(), isCustomMimeType(), isDirPath(), QMYSQLDriver::isIdentifierEscapedImplementation(), QODBCDriver::isIdentifierEscapedImplementation(), QSqlDriver::isIdentifierEscapedImplementation(), QPatternist::LangFN::isLangMatch(), QStyleSheetStyle::isNaturalChild(), isParentDomain(), QUrl::isParentOf(), isParentPath(), isPrefixOf(), isSignalPropertyName(), isUncRoot(), QDBusUtil::isValidBusName(), QDBusUtil::isValidObjectPath(), QDBusUtil::isValidUniqueConnectionName(), launchWebBrowser(), QLocalServerPrivate::listen(), QLibraryPrivate::load_sys(), QFSFileEnginePrivate::longFileName(), QAbstractItemModel::match(), QXlibMime::mimeAtomForFormat(), QMacPasteboardMimeAny::mimeFor(), QLastResortMimes::mimeForFormat(), QDirModelPrivate::name(), nameToType(), QFileSystemEngine::nativeAbsoluteFilePath(), QFileSystemModelPrivate::node(), QSQLiteDriver::open(), QStringRef::operator=(), QNSOpenSavePanelDelegate::panel:shouldShowFilename:, parseColorValue(), QDeclarativeBindingCompilerPrivate::parseName(), QFSCompleter::pathFromIndex(), QGtkStyle::pixelMetric(), QHttpNetworkConnectionPrivate::prepareRequest(), QFtpPI::processReply(), QGlobalNetworkProxy::proxyForQuery(), QDBusAbstractInterface::QDBusAbstractInterface(), qDBusGenerateMetaObjectXml(), qDBusInterfaceFromMetaObject(), QDeclarativeGridScaledImage::QDeclarativeGridScaledImage(), qDecodeOCIType(), qGetColumnType(), QLinuxInputKeyboardHandler::QLinuxInputKeyboardHandler(), QLinuxInputMouseHandler::QLinuxInputMouseHandler(), qmlsqldatabase_executeSql_readonly(), qmlxmlhttprequest_setRequestHeader(), qOpenGLVersionFlagsFromString(), QSslSocketBackendPrivate::QSslCipher_from_SSL_CIPHER(), qt_create_commandline(), qt_mac_menu_merge_action(), qt_parseEtcLpPrinters(), qt_parseSpoolInterface(), qt_resource_fixResourceRoot(), qt_tildeExpansion(), QVNCIntegration::QVNCIntegration(), QWinSettingsPrivate::QWinSettingsPrivate(), QWSKbPrivate::QWSKbPrivate(), QWSLinuxInputKbPrivate::QWSLinuxInputKbPrivate(), QWSLinuxInputMousePrivate::QWSLinuxInputMousePrivate(), QWSTtyKbPrivate::QWSTtyKbPrivate(), readConf(), readLink(), readSourceFile(), QPatternist::XsdSchemaParser::readXPathAttribute(), QDir::relativeFilePath(), removeOptionalQuotes(), QLocalServerPrivate::removeServer(), QInternalMimeData::renderDataHelper(), QSslSocketPrivate::resetDefaultCiphers(), QDeclarativeImportsPrivate::resolvedUri(), QFileSystemEntry::resolveFilePath(), QDeclarativeImportDatabase::resolvePlugin(), QColor::setColorFromString(), QNetworkCookieJar::setCookiesFromUrl(), QCalendarDateValidator::setFormat(), QDeclarativeXmlListModel::setQuery(), QDeclarativeXmlListModelRole::setQuery(), QTextBrowserPrivate::setSource(), shouldWatchService(), QFtpDTP::socketReadyRead(), QFSCompleter::splitPath(), QCompleter::splitPath(), QFtpPI::startNextCmd(), QSettingsPrivate::stringListToVariantList(), QSettingsPrivate::stringToVariant(), QAbstractSpinBoxPrivate::stripped(), stripTextDecl(), QSvgNode::styleProperty(), QStyleSheetStyle::styleRules(), QNetworkProxyFactory::systemProxyForQuery(), QAudioDeviceInfoInternal::testSettings(), QClipboard::text(), QmlJSDebugger::AbstractLiveEditTool::titleForItem(), QUrlPrivate::toEncoded(), QFileDialogPrivate::toInternal(), QNetworkCookie::toRawForm(), QUrl::toString(), totalDigitsForSignedLongLong(), QFileInfoGatherer::translateDriveName(), trimmed(), tryDriveUNCFallback(), QSpinBoxValidator::validate(), QSettingsPrivate::variantToString(), QTextOdfWriter::writeInlineCharacter(), QX11Data::xdndMimeAtomForFormat(), and xdndObtainData().

3735 {
3736  return qt_starts_with(isNull() ? 0 : unicode(), size(),
3737  s.isNull() ? 0 : s.unicode(), s.size(), cs);
3738 }
int size() const
Returns the number of characters in this string.
Definition: qstring.h:102
const QChar * unicode() const
Returns a &#39;\0&#39;-terminated Unicode representation of the string.
Definition: qstring.h:706
bool isNull() const
Returns true if this string is null; otherwise returns false.
Definition: qstring.h:505
static bool qt_starts_with(const QChar *haystack, int haystackLen, const QChar *needle, int needleLen, Qt::CaseSensitivity cs)
Definition: qstring.cpp:9673

◆ startsWith() [2/4]

bool QString::startsWith ( const QStringRef s,
Qt::CaseSensitivity  cs = Qt::CaseSensitive 
) const

Returns true if the string starts with the string reference s; otherwise returns false.

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

If cs is Qt::CaseSensitive (default), the search is case sensitive; otherwise the search is case insensitive.

See also
endsWith()

Definition at line 3779 of file qstring.cpp.

3780 {
3781  return qt_starts_with(isNull() ? 0 : unicode(), size(),
3782  s.isNull() ? 0 : s.unicode(), s.size(), cs);
3783 }
int size() const
Returns the number of characters referred to by the string reference.
Definition: qstring.h:1114
int size() const
Returns the number of characters in this string.
Definition: qstring.h:102
const QChar * unicode() const
Returns a &#39;\0&#39;-terminated Unicode representation of the string.
Definition: qstring.h:706
const QChar * unicode() const
Returns a Unicode representation of the string reference.
Definition: qstring.h:1153
bool isNull() const
Returns true if this string is null; otherwise returns false.
Definition: qstring.h:505
static bool qt_starts_with(const QChar *haystack, int haystackLen, const QChar *needle, int needleLen, Qt::CaseSensitivity cs)
Definition: qstring.cpp:9673
bool isNull() const
Returns true if string() returns a null pointer or a pointer to a null string; otherwise returns true...
Definition: qstring.h:1170

◆ startsWith() [3/4]

bool QString::startsWith ( const QLatin1String s,
Qt::CaseSensitivity  cs = Qt::CaseSensitive 
) const

Definition at line 3743 of file qstring.cpp.

3744 {
3745  return qt_starts_with(isNull() ? 0 : unicode(), size(), s, cs);
3746 }
int size() const
Returns the number of characters in this string.
Definition: qstring.h:102
const QChar * unicode() const
Returns a &#39;\0&#39;-terminated Unicode representation of the string.
Definition: qstring.h:706
bool isNull() const
Returns true if this string is null; otherwise returns false.
Definition: qstring.h:505
static bool qt_starts_with(const QChar *haystack, int haystackLen, const QChar *needle, int needleLen, Qt::CaseSensitivity cs)
Definition: qstring.cpp:9673

◆ startsWith() [4/4]

bool QString::startsWith ( const QChar c,
Qt::CaseSensitivity  cs = Qt::CaseSensitive 
) const

Definition at line 3757 of file qstring.cpp.

3758 {
3759  return d->size
3760  && (cs == Qt::CaseSensitive
3761  ? d->data[0] == c
3762  : foldCase(d->data[0]) == foldCase(c.unicode()));
3763 }
unsigned char c[8]
Definition: qnumeric_p.h:62
ushort unicode() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qchar.h:251
Data * d
Definition: qstring.h:618
static uint foldCase(const ushort *ch, const ushort *start)
Definition: qchar.cpp:1380
ushort * data
Definition: qstring.h:606

◆ swap()

void QString::swap ( QString other)
inline

Swaps string other with this string.

Since
4.8

This operation is very fast and never fails.

Definition at line 101 of file qstring.h.

101 { qSwap(d, other.d); }
void qSwap(T &value1, T &value2)
Definition: qglobal.h:2181
Data * d
Definition: qstring.h:618

◆ toAscii()

QByteArray QString::toAscii ( ) const

Returns an 8-bit representation of the string as a QByteArray.

If a codec has been set using QTextCodec::setCodecForCStrings(), it is used to convert Unicode to 8-bit char; otherwise this function does the same as toLatin1().

Note that, despite the name, this function does not necessarily return an US-ASCII (ANSI X3.4-1986) string and its result may not be US-ASCII compatible.

See also
fromAscii(), toLatin1(), toUtf8(), toLocal8Bit(), QTextCodec

Definition at line 4014 of file qstring.cpp.

Referenced by QXmlTestLogger::addBenchmarkResult(), QTestLogger::addBenchmarkResult(), QIcdEngine::addConfiguration(), QAccessibleWidget::addControllingSignal(), QByteArray::append(), Maemo::appendVariantToDBusMessage(), QMetaObject::connectSlotsByName(), QStringRef::constData(), createImageNode(), QBBRootWindow::createWindowGroup(), QIcdEngine::deleteConfiguration(), QNetworkSessionPrivateImpl::do_open(), QIcdEngine::doRequestUpdate(), QDB2Result::exec(), QTest::formatResult(), fromLatin1(), QBBGLContext::getProcAddress(), QByteArray::indexOf(), QByteArray::insert(), QByteArray::lastIndexOf(), QPatternist::XQueryTokenizer::lookupKeyword(), QTest::mouseEvent(), QAccessibleWidget::navigate(), QLinuxFbIntegrationPrivate::openTty(), QLinuxFbScreenPrivate::openTty(), PvrEglScreen::openTty(), QByteArray::operator+=(), QSplitter::operator>>(), QHttpNetworkConnectionPrivate::prepareRequest(), QTest::printBenchmarkResult(), qstring_to_xtp(), qt_getLprPrinters(), qt_parseEtcLpPrinters(), qt_parsePrintersConf(), QAccessibleWidget::relationTo(), QByteArray::replace(), QSQLite2Result::reset(), QCharRef::row(), subControlLayout(), QImage::textList(), QUrlPrivate::toEncoded(), toStdString(), and write_xbm_image().

4015 {
4016 #ifndef QT_NO_TEXTCODEC
4017  if (codecForCStrings)
4018  return codecForCStrings->fromUnicode(*this);
4019 #endif // QT_NO_TEXTCODEC
4020  return toLatin1();
4021 }
QByteArray fromUnicode(const QString &uc) const
Converts str from Unicode to the encoding of this codec, and returns the result in a QByteArray...
QByteArray toLatin1() const Q_REQUIRED_RESULT
Returns a Latin-1 representation of the string as a QByteArray.
Definition: qstring.cpp:3993
static QTextCodec * codecForCStrings
Definition: qstring.h:621

◆ toCaseFolded()

QString QString::toCaseFolded ( ) const

Returns the case folded equivalent of the string.

For most Unicode characters this is the same as toLower().

Definition at line 5441 of file qstring.cpp.

Referenced by qHash().

5442 {
5443  if (!d->size)
5444  return *this;
5445 
5446  const ushort *p = d->data;
5447  if (!p)
5448  return *this;
5449 
5450  const ushort *e = d->data + d->size;
5451 
5452  uint last = 0;
5453  while (p < e) {
5454  ushort folded = foldCase(*p, last);
5455  if (folded != *p) {
5456  QString s(*this);
5457  s.detach();
5458  ushort *pp = s.d->data + (p - d->data);
5459  const ushort *ppe = s.d->data + s.d->size;
5460  last = pp > s.d->data ? *(pp - 1) : 0;
5461  while (pp < ppe) {
5462  *pp = foldCase(*pp, last);
5463  ++pp;
5464  }
5465  return s;
5466  }
5467  p++;
5468  }
5469  return *this;
5470 }
The QString class provides a Unicode character string.
Definition: qstring.h:83
unsigned int uint
Definition: qglobal.h:996
Data * d
Definition: qstring.h:618
static uint foldCase(const ushort *ch, const ushort *start)
Definition: qchar.cpp:1380
ushort * data
Definition: qstring.h:606
unsigned short ushort
Definition: qglobal.h:995

◆ toDouble()

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

Returns the string converted to a double value.

Returns 0.0 if the conversion fails.

If a conversion error occurs, *{ok} is set to false; otherwise *{ok} is set to true.

QString str = "1234.56";
double val = str.toDouble(); // val == 1234.56

Various string formats for floating point numbers can be converted to double values:

bool ok;
double d;
d = QString( "1234.56e-02" ).toDouble(&ok); // ok == true, d == 12.3456

This function tries to interpret the string according to the current locale. The current locale is determined from the system at application startup and can be changed by calling QLocale::setDefault(). If the string cannot be interpreted according to the current locale, this function falls back on the "C" locale.

d = QString( "1234,56" ).toDouble(&ok); // ok == false
d = QString( "1234.56" ).toDouble(&ok); // ok == true, d == 1234.56
d = QString( "1234,56" ).toDouble(&ok); // ok == true, d == 1234.56
d = QString( "1234.56" ).toDouble(&ok); // ok == true, d == 1234.56

Due to the ambiguity between the decimal point and thousands group separator in various locales, this function does not handle thousands group separators. If you need to convert such numbers, see QLocale::toDouble().

d = QString( "1234,56" ).toDouble(&ok); // ok == false
See also
number() QLocale::setDefault() QLocale::toDouble() trimmed()

Definition at line 6227 of file qstring.cpp.

Referenced by QTextHtmlParserNode::applyCssDeclarations(), QPSQLResult::data(), QMYSQLResult::data(), QLCDNumber::display(), QAxBase::dynamicCallHelper(), QPatternist::AbstractFloat< isDouble >::fromLexical(), QCss::ValueExtractor::lengthValue(), parseOpacity(), QDeclarativeStringConverters::pointFFromString(), QWSPcMouseHandlerPrivate::QWSPcMouseHandlerPrivate(), QCss::Declaration::realValue(), QDeclarativeStringConverters::rectFFromString(), QDoubleSpinBoxPrivate::round(), setFloatAttribute(), setWidthAttribute(), QDeclarativeStringConverters::sizeFFromString(), toFloat(), QDeclarativeStringConverters::variantFromString(), and QDeclarativeStringConverters::vector3DFromString().

6228 {
6229  bool my_ok;
6230  QLocale def_locale;
6231  double result = def_locale.d()->stringToDouble(*this, &my_ok, QLocalePrivate::FailOnGroupSeparators);
6232  if (my_ok) {
6233  if (ok != 0)
6234  *ok = true;
6235  return result;
6236  }
6237 
6238  QLocale c_locale(QLocale::C);
6239  return c_locale.d()->stringToDouble(*this, ok, QLocalePrivate::FailOnGroupSeparators);
6240 }
double stringToDouble(const QString &num, bool *ok, GroupSeparatorMode group_sep_mode) const
Definition: qlocale.cpp:3092
const QLocalePrivate * d() const
Definition: qlocale.cpp:761

◆ toFloat()

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

Definition at line 6257 of file qstring.cpp.

Referenced by QPrintPreviewDialogPrivate::_q_zoomFactorChanged(), and QVNCScreen::connect().

6258 {
6259  bool myOk;
6260  double d = toDouble(&myOk);
6261  if (!myOk || d > QT_MAX_FLOAT || d < -QT_MAX_FLOAT) {
6262  if (ok != 0)
6263  *ok = false;
6264  return 0.0;
6265  }
6266  if (ok != 0)
6267  *ok = true;
6268  return (float) d;
6269 }
#define QT_MAX_FLOAT
Returns the string converted to a float value.
Definition: qstring.cpp:6255
Data * d
Definition: qstring.h:618
double toDouble(bool *ok=0) const
Returns the string converted to a double value.
Definition: qstring.cpp:6227

◆ toInt()

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

Returns the string converted to an int using base base, which is 10 by default and must be between 2 and 36, or 0.

Returns 0 if the conversion fails.

If a conversion error occurs, *{ok} is set to false; otherwise {ok} is set to true.

If base is 0, the C language convention is used: If the string begins with "0x", base 16 is used; if the string begins with "0", base 8 is used; otherwise, base 10 is used.

Example:

QString str = "FF";
bool ok;
int hex = str.toInt(&ok, 16); // hex == 255, ok == true
int dec = str.toInt(&ok, 10); // dec == 0, ok == false
See also
number(), toUInt(), toDouble()

Definition at line 6090 of file qstring.cpp.

Referenced by QFontDialogPrivate::_q_sizeChanged(), QFontDialogPrivate::_q_sizeHighlighted(), QHttpPrivate::_q_slotReadyRead(), QCalendarWidgetPrivate::_q_yearEditingFinished(), QTextHtmlParser::applyAttributes(), QTextCodec::availableMibs(), QCss::Declaration::borderImageValue(), EGLNullWSScreen::connect(), QQnxScreen::connect(), QVFbScreen::connect(), QVNCScreen::connect(), PvrEglScreen::connect(), QLinuxFbScreen::connect(), QLinuxFbIntegration::connect(), QDirectFBScreen::connect(), QMacPasteboardMimeVCard::convertFromMime(), QTextCodecPlugin::create(), QPatternist::AbstractDuration::create(), QPatternist::AbstractDateTime::create(), QMYSQLResult::data(), QKeySequencePrivate::decodeString(), QAxBase::dynamicCallHelper(), filterDisplayOffset(), filterTransformation(), QDate::fromString(), QTime::fromString(), QDateTime::fromString(), getDisplayId(), QSystemLocalePrivate::getLocaleInfo_int(), QBenchmarkValgrindUtils::getNewestFileName(), getNumTok(), QPSQLDriverPrivate::getPSQLVersion(), QBenchmarkValgrindUtils::haveValgrind(), QDeclarativeDebugServer::instance(), intValueHelper(), QAxServerBase::Invoke(), QLibrary::isLibrary(), QLibraryPrivate::isPlugin(), libGreaterThan(), QNativeSocketEnginePrivate::nativeBind(), QNativeSocketEnginePrivate::nativeConnect(), QNativeSocketEnginePrivate::nativeSendDatagram(), QWSServerPrivate::newMouseHandler(), QPSQLResult::numRowsAffected(), QSQLiteDriver::open(), QOCIDriver::open(), QScriptXmlParser::parse(), QDeclarativeDirParser::parse(), parseFont(), QDeclarativeStyledTextPrivate::parseFontAttributes(), QHttpResponseHeader::parseLine(), QPatternist::AbstractDateTime::parseZoneOffset(), QFtpPI::processReply(), QLinuxInputKeyboardHandler::QLinuxInputKeyboardHandler(), QLinuxInputMouseHandler::QLinuxInputMouseHandler(), qParseOpts(), qt_init(), qt_socket_setPortAndAddress(), QtWndProc(), QVFbIntegration::QVFbIntegration(), QVNCIntegration::QVNCIntegration(), QWSKbPrivate::QWSKbPrivate(), QWSLinuxInputKbPrivate::QWSLinuxInputKbPrivate(), QWSLinuxInputMousePrivate::QWSLinuxInputMousePrivate(), QWSPcMouseHandlerPrivate::QWSPcMouseHandlerPrivate(), QWSTslibMouseHandlerPrivate::QWSTslibMouseHandlerPrivate(), QWSTtyKbPrivate::QWSTtyKbPrivate(), read_xbm_header(), setIntAttribute(), setIntOption(), QHttpSocketEngine::slotSocketReadNotification(), QSystemLocalePrivate::toCurrencyString(), QPatternist::XQueryTokenizer::tokenizeCharacterReference(), tokenUntil(), QDateTime::toString(), and vsprintf().

6091 {
6092  qint64 v = toLongLong(ok, base);
6093  if (v < INT_MIN || v > INT_MAX) {
6094  if (ok)
6095  *ok = false;
6096  v = 0;
6097  }
6098  return v;
6099 }
qlonglong toLongLong(bool *ok=0, int base=10) const
Returns the string converted to a long long using base base, which is 10 by default and must be betwe...
Definition: qstring.cpp:5943
static const uint base
Definition: qurl.cpp:268
__int64 qint64
Definition: qglobal.h:942
#define INT_MAX

◆ toLatin1()

QByteArray QString::toLatin1 ( ) const

Returns a Latin-1 representation of the string as a QByteArray.

The returned byte array is undefined if the string contains non-Latin1 characters. Those characters may be suppressed or replaced with a question mark.

See also
fromLatin1(), toAscii(), toUtf8(), toLocal8Bit(), QTextCodec

Definition at line 3993 of file qstring.cpp.

Referenced by QAbstractSocketPrivate::_q_connectToNextAddress(), QHttpPrivate::_q_slotConnected(), QHttpPrivate::_q_slotReadyRead(), QHttpPrivate::_q_slotSendRequest(), QAbstractSocketPrivate::_q_startConnecting(), QXmlStreamReader::addData(), QGLShaderProgram::addShaderFromSourceCode(), QDBusMarshaller::append(), QDBusMarshaller::appendCrossMarshalling(), Maemo::appendVariantToDBusMessage(), QTextHtmlParser::applyAttributes(), QMacStylePrivate::aquaSizeConstrain(), QCoreApplication::arguments(), QStyleSheetStyleSelector::attribute(), QGLShaderProgram::attributeLocation(), QTextCodec::availableCodecs(), QGLShaderProgram::bindAttributeLocation(), buildMatchRule(), QAuthenticatorPrivate::calculateResponse(), QDBusAbstractInterface::callWithArgumentList(), QTextCodec::canEncode(), QUrlPrivate::canonicalHost(), checkHRESULT(), QGLContext::choosePixelFormat(), classIDL(), QGLShader::compileSourceCode(), QVFbScreen::connect(), QVNCScreen::connect(), QMultiScreen::connect(), QTransformedScreen::connect(), QLinuxFbScreen::connect(), QProxyScreen::connect(), QLinuxFbIntegration::connect(), QDBusConnection::connect(), QAbstractSocket::connectToHost(), QAbstractSocket::connectToHostImplementation(), QStringRef::constData(), QIconvCodec::convertFromUnicode(), QMacPasteboardMime::convertor(), QWSDisplay::convertSelection(), convertTypes(), QTextCodecPlugin::create(), createForName(), QmlJSDebugger::AbstractViewInspector::createQmlObject(), decodeMSG(), deleteChildGroups(), QAuthenticatorPrivate::digestMd5Response(), QNetworkSessionPrivateImpl::do_open(), QPainter::drawText(), QPdfEnginePrivate::drawTextItem(), QRasterPaintEngine::drawTextItem(), dumpRecursive(), QAxBase::dynamicCallHelper(), QtopiaPrintEngine::end(), QWSClient::errorHandler(), QXmlSimpleReader::feature(), QWSSoundServerPrivate::feedDevice(), QAbstractSocketPrivate::fetchConnectionParameters(), QNativeSocketEnginePrivate::fetchConnectionParameters(), QTextStreamPrivate::fillReadBuffer(), findEncoding(), QAxEventSink::findProperty(), findSlot(), QDBusMetaObjectGenerator::findType(), QMacPasteboardMime::flavorToMime(), fontExists(), QMimeDataWrapper::format(), QDropEvent::format(), fromLatin1(), QHostInfo::fromName(), QHostInfoAgent::fromName(), QHostInfoPrivate::fromName(), QXmlInputSource::fromRawData(), QFont::fromString(), fromUnicode(), QFontEngineWin::getCMap(), getNetWmState(), QWaylandReadbackGlxContext::getProcAddress(), QWaylandReadbackEglContext::getProcAddress(), QGLXContext::getProcAddress(), QWaylandXCompositeGLXContext::getProcAddress(), QGLContext::getProcAddress(), getWinLocaleName(), QApplicationPrivate::globalEventProcessor(), QMimeSourceWrapper::hasFormat(), hasValidSignal(), QSqlDatabasePrivate::init(), QNativeSocketEngine::initialize(), initializeDb(), QAxBase::initializeLicensedHelper(), QDeclarativePropertyPrivate::initProperty(), QAbstractSocketPrivate::initSocketLayer(), QSslSocketBackendPrivate::initSslContext(), QDeclarativeJS::integerFromString(), QAxServerBase::Invoke(), QLibraryPrivate::isPlugin(), QDBusUtil::isValidSignature(), QDBusUtil::isValidSingleSignature(), QMetaEnum::keysToValue(), QTcpServer::listen(), QResourcePrivate::load(), loadFc(), QFontDatabasePrivate::loadFromCache(), loadRaw(), loadWin(), QFontDatabase::loadXlfd(), QSystemTrayIconSys::locateSystemTray(), ShaderEffectItem::lookThroughShaderCode(), QHostInfo::lookupHost(), QScriptStdMessageHandler::message(), MetaObjectGenerator::metaObject(), MetaObjectGenerator::MetaObjectGenerator(), QXlibMime::mimeStringToAtom(), multicastMembershipHelper(), QNativeSocketEnginePrivate::nativeBind(), QNativeSocketEnginePrivate::nativeConnect(), QNativeSocketEnginePrivate::nativeListen(), QNativeSocketEnginePrivate::nativeReceiveDatagram(), QNativeSocketEnginePrivate::nativeSendDatagram(), QTDSDriver::open(), QWSPcMouseHandlerPrivate::openDevices(), QWSSoundServerPrivate::openFile(), operator<<(), QGtkPainter::paintCheckbox(), QGtkPainter::paintOption(), QDateTimeParser::parse(), QUrlPrivate::parse(), parseDateString(), QDateTimeParser::parseFormat(), QHttpResponseHeader::parseLine(), QHttpRequestHeader::parseLine(), QDBusMetaObjectGenerator::parseMethods(), QDBusMetaObjectGenerator::parseProperties(), QDBusMetaObjectGenerator::parseSignals(), Maemo::prepareDBusCall(), QFtpPI::processReply(), QFontEngineWin::properties(), QDBusAbstractInterfacePrivate::property(), qax_noSuchFunction(), qax_readClassInfo(), qax_readInterfaceInfo(), QTest::qCompare(), qDBusReplyFill(), qEncodeNtlmString(), qgl_use_font(), QGLXContext::QGLXContext(), QTest::qPrintDataTags(), QQnxMouseHandler::QQnxMouseHandler(), qStreamNtlmString(), qStringFromUcs2Le(), qt_ACE_do(), qt_create_commandline(), qt_get_screen(), qt_initIcu(), QApplicationPrivate::qt_mac_apply_settings(), qt_mac_display_change_callbk(), qt_u_strToCase(), qt_x11_set_fallback_font_family(), QTDSResult::QTDSResult(), QVFbKeyboardHandler::QVFbKeyboardHandler(), QVFbMouseHandler::QVFbMouseHandler(), QVFbScreenKeyboardHandler::QVFbScreenKeyboardHandler(), QVFbScreenMouseHandler::QVFbScreenMouseHandler(), QWaylandSelection::QWaylandSelection(), QWSLinuxTPMouseHandlerPrivate::QWSLinuxTPMouseHandlerPrivate(), QWSQnxKeyboardHandler::QWSQnxKeyboardHandler(), QXmlStreamReader::QXmlStreamReader(), QAudioInputPrivate::read(), MetaObjectGenerator::readClassInfo(), MetaObjectGenerator::readEnumInfo(), MetaObjectGenerator::readEventInfo(), MetaObjectGenerator::readEventInterface(), MetaObjectGenerator::readFuncsInfo(), MetaObjectGenerator::readInterfaceInfo(), QPatternist::XsdSchemaParser::readNamespaceAttribute(), QPatternist::XsdSchemaParser::readQNameAttribute(), MetaObjectGenerator::readVarsInfo(), QPatternist::XsdSchemaParser::readXPathAttribute(), registerComponent(), registerFont(), QWinSettingsPrivate::remove(), QDeclarativeEngineDebugService::resetBinding(), QWaylandClipboard::retrieveData(), QMimeSourceWrapper::retrieveData(), QPatternist::AccelTreeResourceLoader::retrieveUnparsedText(), QCharRef::row(), QDomDocumentPrivate::saveDocument(), QWSSoundServerClient::sendClientMessage(), QKeyMapper::sendKeyEvent(), QWSServerPrivate::sendQCopEvent(), QWinSettingsPrivate::set(), set_text(), QColor::setColorFromString(), QAxBase::setControl(), QXmlSimpleReader::setFeature(), QPainter::setFont(), QByteArray::setNum(), QTextBrowserPrivate::setSource(), Maemo::DBusDispatcher::setupDBus(), QXlibWindow::setWindowTitle(), sm_setProperty(), QFtpPI::startNextCmd(), QSettingsPrivate::stringToVariant(), QImageWriter::supportedImageFormats(), QImageReader::supportedImageFormats(), QUrl::swap(), QUrl::toAce(), toAscii(), QStringRef::toAscii(), QUrlPrivate::toEncoded(), QNetworkHeadersPrivate::toHttpDate(), QStringBuilder< QString, QString >::toLatin1(), toLocal8Bit(), QStringRef::toLocal8Bit(), QUrl::toPunycode(), QTest::toString(), translateWSAError(), QGLShaderProgram::uniformLocation(), QGLContext::updatePaintDevice(), MetaObjectGenerator::usertypeToString(), winIso639LangName(), QDBusMetaObjectGenerator::write(), QXmlStreamWriterPrivate::write(), QUdpSocket::writeDatagram(), QApplicationPrivate::x11_apply_settings(), QX11Data::xdndMimeStringToAtom(), and QWinSettingsPrivate::~QWinSettingsPrivate().

3994 {
3995  return toLatin1_helper(unicode(), length());
3996 }
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
static QByteArray toLatin1_helper(const QChar *data, int length)
Definition: qstring.cpp:3924
const QChar * unicode() const
Returns a &#39;\0&#39;-terminated Unicode representation of the string.
Definition: qstring.h:706

◆ toLocal8Bit()

QByteArray QString::toLocal8Bit ( ) const

Returns the local 8-bit representation of the string as a QByteArray.

The returned byte array is undefined if the string contains characters not supported by the local 8-bit encoding.

QTextCodec::codecForLocale() is used to perform the conversion from Unicode. If the locale encoding could not be determined, this function does the same as toLatin1().

If this string contains any characters that cannot be encoded in the locale, the returned byte array is undefined. Those characters may be suppressed or replaced by another.

See also
fromLocal8Bit(), toAscii(), toLatin1(), toUtf8(), QTextCodec

Definition at line 4049 of file qstring.cpp.

Referenced by QProcessPrivate::_q_notified(), QBasicUnixFontDatabase::addApplicationFont(), QLayout::addChildLayout(), QGraphicsLayoutPrivate::addChildLayoutItem(), QLayout::addChildWidget(), QSqlDatabasePrivate::addDatabase(), QZipWriterPrivate::addEntry(), QResource::addSearchPath(), QGridLayout::addWidget(), arg(), QAudioDeviceInfoInternal::availableDevices(), QCoreApplicationPrivate::checkReceiverThread(), checkWidget(), QPdfBaseEnginePrivate::closePrintDevice(), QDirectFBScreen::connect(), QWSSocket::connectToLocalFile(), QDeclarativeEnginePrivate::consoleLog(), QStringRef::constData(), QWindowsMimeText::convertFromMime(), QWindowsMimeURI::convertFromMime(), QMacPasteboardMimeVCard::convertFromMime(), QLayoutPrivate::createSpacerItem(), QGraphicsAnchorLayoutPrivate::dumpGraph(), dumpRecursive(), QApplicationPrivate::enterModal_sys(), err_info_about_objects(), QSqlQuery::exec(), QPSQLDriverPrivate::exec(), QMinimalWindowSurface::flush(), QTextStreamPrivate::flushWriteBuffer(), QFontconfigDatabase::fontEngine(), QBasicUnixFontDatabase::fontEngine(), QDirectFBPixmapData::fromFile(), QDirectFbBlitterPlatformPixmap::fromFile(), QApplicationPrivate::globalEventProcessor(), QAuServerNAS::init(), QWSServerSocket::init(), init_platform(), initializeDb(), QDirectFbIntegration::initializeDirectFB(), QSqlDatabasePrivate::invalidateDb(), QApplicationPrivate::leaveModal_sys(), loadSingleEngine(), locale_encode(), QXlibMime::mimeDataForAtom(), multiArg(), QIBaseDriver::open(), QAudioDeviceInfoInternal::open(), QTDSDriver::open(), QMYSQLDriver::open(), QAudioInputPrivate::open(), QPSQLDriver::open(), QWSTslibMouseHandlerPrivate::open(), QAudioOutputPrivate::open(), QDeclarativeInfo::operator<<(), QProcessEnvironmentPrivate::OrderedMutexLocker::OrderedMutexLocker(), QAuServerNAS::play(), QSqlQuery::prepare(), qDecodeOCIType(), qErrnoWarning(), QTest::qExec(), qGetInterfaceType(), QLayout::QLayout(), QLinuxInputKeyboardHandler::QLinuxInputKeyboardHandler(), QLinuxInputMouseHandler::QLinuxInputMouseHandler(), QLock::QLock(), qParseOpts(), QTest::qSignalDumperCallback(), QTest::qSignalDumperCallbackSlot(), qSqlWarning(), qt_adopted_thread_watcher_function(), qt_message(), qt_nograb(), qt_tildeExpansion(), QByteArray::qvsnprintf(), qws_dataDir(), QWSLinuxInputKbPrivate::QWSLinuxInputKbPrivate(), QWSLinuxInputMousePrivate::QWSLinuxInputMousePrivate(), QWSTtyKbPrivate::QWSTtyKbPrivate(), QWSUmKeyboardHandlerPrivate::QWSUmKeyboardHandlerPrivate(), QMYSQLDriver::record(), QResource::registerResource(), QCoreApplicationPrivate::removePostedEvent(), QGraphicsLayoutPrivate::reparentChildItems(), QTDSResult::reset(), QToolBarAreaLayout::saveState(), QWidget::setLayout(), setOptionFlag(), QPrinter::setPrinterName(), QThreadPrivate::start(), QProcessPrivate::startDetached(), QProcessPrivate::startProcess(), QIBaseDriver::subscribeToNotificationImplementation(), QAudioDeviceInfoInternal::testSettings(), WinMain(), QPatternist::ColorOutputPrivate::write(), and QX11Data::xdndMimeDataForAtom().

4050 {
4051 #ifndef QT_NO_TEXTCODEC
4053  return QTextCodec::codecForLocale()->fromUnicode(*this);
4054 #endif // QT_NO_TEXTCODEC
4055  return toLatin1();
4056 }
static QTextCodec * codecForLocale()
Returns a pointer to the codec most suitable for this locale.
QByteArray fromUnicode(const QString &uc) const
Converts str from Unicode to the encoding of this codec, and returns the result in a QByteArray...
QByteArray toLatin1() const Q_REQUIRED_RESULT
Returns a Latin-1 representation of the string as a QByteArray.
Definition: qstring.cpp:3993

◆ toLong()

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

Returns the string converted to a long using base base, which is 10 by default and must be between 2 and 36, or 0.

Returns 0 if the conversion fails.

If a conversion error occurs, *{ok} is set to false; otherwise {ok} is set to true.

If base is 0, the C language convention is used: If the string begins with "0x", base 16 is used; if the string begins with "0", base 8 is used; otherwise, base 10 is used.

Example:

QString str = "FF";
bool ok;
long hex = str.toLong(&ok, 16); // hex == 255, ok == true
long dec = str.toLong(&ok, 10); // dec == 0, ok == false
See also
number(), toULong(), toInt()

Definition at line 6027 of file qstring.cpp.

6028 {
6029  qint64 v = toLongLong(ok, base);
6030  if (v < LONG_MIN || v > LONG_MAX) {
6031  if (ok)
6032  *ok = false;
6033  v = 0;
6034  }
6035  return (long)v;
6036 }
qlonglong toLongLong(bool *ok=0, int base=10) const
Returns the string converted to a long long using base base, which is 10 by default and must be betwe...
Definition: qstring.cpp:5943
static const uint base
Definition: qurl.cpp:268
__int64 qint64
Definition: qglobal.h:942

◆ toLongLong()

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

Returns the string converted to a long long using base base, which is 10 by default and must be between 2 and 36, or 0.

Returns 0 if the conversion fails.

If a conversion error occurs, *{ok} is set to false; otherwise {ok} is set to true.

If base is 0, the C language convention is used: If the string begins with "0x", base 16 is used; if the string begins with "0", base 8 is used; otherwise, base 10 is used.

Example:

QString str = "FF";
bool ok;
qint64 hex = str.toLongLong(&ok, 16); // hex == 255, ok == true
qint64 dec = str.toLongLong(&ok, 10); // dec == 0, ok == false
See also
number(), toULongLong(), toInt()

Definition at line 5943 of file qstring.cpp.

Referenced by _q_parseDosDir(), _q_parseUnixDir(), QPSQLResult::data(), QMYSQLResult::data(), QBenchmarkValgrindUtils::extractResult(), QPatternist::Integer::fromLexical(), QPatternist::DerivedInteger< DerivedType >::fromLexical(), QNetworkAccessFtpBackend::ftpRawCommandReply(), QFtpPI::processReply(), toInt(), toLong(), and toShort().

5944 {
5945 #if defined(QT_CHECK_RANGE)
5946  if (base != 0 && (base < 2 || base > 36)) {
5947  qWarning("QString::toLongLong: Invalid base (%d)", base);
5948  base = 10;
5949  }
5950 #endif
5951 
5952  bool my_ok;
5953  QLocale def_locale;
5954  qint64 result = def_locale.d()->stringToLongLong(*this, base, &my_ok, QLocalePrivate::FailOnGroupSeparators);
5955  if (my_ok) {
5956  if (ok != 0)
5957  *ok = true;
5958  return result;
5959  }
5960 
5961  QLocale c_locale(QLocale::C);
5962  return c_locale.d()->stringToLongLong(*this, base, ok, QLocalePrivate::FailOnGroupSeparators);
5963 }
qint64 stringToLongLong(const QString &num, int base, bool *ok, GroupSeparatorMode group_sep_mode) const
Definition: qlocale.cpp:3105
static const uint base
Definition: qurl.cpp:268
Q_CORE_EXPORT void qWarning(const char *,...)
__int64 qint64
Definition: qglobal.h:942
const QLocalePrivate * d() const
Definition: qlocale.cpp:761

◆ toLower()

QString QString::toLower ( ) const

Returns a lowercase copy of the string.

QString str = "Qt by NOKIA";
str = str.toLower(); // str == "qt by nokia"

The case conversion will always happen in the 'C' locale. For locale dependent case folding use QLocale::toLower()

See also
toUpper(), QLocale::toLower()

Definition at line 5389 of file qstring.cpp.

Referenced by QFileSystemModelPrivate::_q_directoryChanged(), _q_parseDosDir(), QComboBoxPrivate::_q_returnPressed(), QHttpPrivate::_q_slotReadyRead(), QDeclarativeTypeLoader::absoluteFilePath(), QDeclarativeEngine::addImageProvider(), QWindowsFileSystemWatcherEngine::addPaths(), QUrlModel::addUrls(), QHttpHeader::allValues(), QTextHtmlParser::applyAttributes(), QCss::StyleSheet::buildIndexes(), QUrlPrivate::canonicalHost(), QLocalePrivate::codeToLanguage(), comify(), QPatternist::CaseInsensitiveStringComparator::compare(), QMacPasteboardMimeFileUri::convertFromMime(), QMacPasteboardMimeUrl::convertFromMime(), QMacPasteboardMimeFileUri::convertToMime(), QMacPasteboardMimeUrl::convertToMime(), QNetworkCookieJar::cookiesForUrl(), QVGGraphicsSystemPlugin::create(), ShivaVGGraphicsSystemPlugin::create(), QTraceGraphicsSystemPlugin::create(), QEglIntegrationPlugin::create(), QLinuxFbIntegrationPlugin::create(), QOpenKODEPlugin::create(), QWaylandIntegrationPlugin::create(), QXcbIntegrationPlugin::create(), QXlibIntegrationPlugin::create(), QGLGraphicsSystemPlugin::create(), QBBIntegrationPlugin::create(), QMinimalIntegrationPlugin::create(), QVFbIntegrationPlugin::create(), QVNCIntegrationPlugin::create(), EGLNullWSScreenPlugin::create(), DecorationDefault::create(), DecorationStyled::create(), DecorationWindows::create(), TslibMouseDriver::create(), QAhiScreenPlugin::create(), PvrEglScreenPlugin::create(), QCocoaIntegrationPlugin::create(), QUIKitIntegrationPlugin::create(), DirectFBScreenDriverPlugin::create(), GfxTransformedDriver::create(), QScreenLinuxFbPlugin::create(), ScreenVfbDriver::create(), GfxVncDriver::create(), QDirectFbIntegrationPlugin::create(), QPlatformIntegrationFactory::create(), QNetworkAccessHttpBackendFactory::create(), QNetworkAccessManager::createRequest(), QLocalePrivate::dateTimeToString(), QKeySequencePrivate::decodeString(), QSymSQLResult::exec(), QFileSystemEngine::fillPermissions(), find_translation(), QDateTimeParser::findDay(), QDateTimeParser::findMonth(), QDeclarativeXMLHttpRequest::finished(), QMacPasteboardMimeUnicodeText::flavorFor(), Maemo::ProxyConfPrivate::flush(), QUrl::fromUserInput(), getFontWeight(), QHttpHeader::hasKey(), QDeclarativeXMLHttpRequest::header(), QDirModel::index(), QSortedModelEngine::indexHint(), QFont::insertSubstitution(), QFont::insertSubstitutions(), QFactoryLoader::instance(), QHttpHeader::keys(), QFactoryLoader::library(), loadEngine(), loadSingleEngine(), QCompletionEngine::lookupCache(), macQueryInternal(), makeCacheKey(), QCompletionEngine::matchHint(), Qt::mightBeRichText(), QFileSystemModelPrivate::node(), QUrlPrivate::normalized(), QWSPcMouseHandlerPrivate::openDevices(), QDirSortItemComparator::operator()(), QSettingsKey::originalKeyPosition(), QDateTimeParser::parse(), parseBrushValue(), QTextHtmlParser::parseCloseTag(), parseHttpOptionHeader(), QDateTimeParser::parseSection(), parseStyleNode(), QTextHtmlParser::parseTag(), QNetworkAccessHttpBackend::postRequest(), QTDSDriver::primaryIndex(), QPSQLDriver::primaryIndex(), QApplicationPrivate::process_cmdline(), QSvgHandler::processingInstruction(), Q_GLOBAL_STATIC_WITH_ARGS(), qAxInit(), qExtractSecurityPolicyFromString(), QFontEngineQPF::QFontEngineQPF(), qGetColumnType(), qGetODBCVersion(), qGetTableInfo(), QMacSettingsPrivate::QMacSettingsPrivate(), qmlFilesInDirectory(), qt_init(), qt_mac_menu_merge_action(), qt_parseQconfig(), qt_set_x11_resources(), qTopLevelDomain(), QPSQLDriver::record(), QAxFactory::registerActiveObject(), QDir::relativeFilePath(), QHttpHeader::removeAllValues(), QWindowsFileSystemWatcherEngine::removePaths(), QFont::removeSubstitution(), QHttpHeader::removeValue(), QSslSocketPrivate::resetDefaultCiphers(), QCompletionEngine::saveInCache(), QAxBase::setControl(), QRegExpEngine::Box::setupHeuristics(), QHttpHeader::setValue(), QHttpSocketEngine::slotSocketReadNotification(), QSslSocketBackendPrivate::startHandshake(), QCss::StyleSelector::styleRulesForNode(), QFont::substitute(), QFont::substitutes(), QCss::Parser::testAndParseUri(), QLocale::toLower(), QFactoryLoader::updateDir(), QHttpHeader::value(), WinMain(), and QApplicationPrivate::x11_apply_settings().

5390 {
5391  const ushort *p = d->data;
5392  if (!p)
5393  return *this;
5394  if (!d->size)
5395  return *this;
5396 
5397  const ushort *e = d->data + d->size;
5398 
5399  // this avoids one out of bounds check in the loop
5400  if (QChar(*p).isLowSurrogate())
5401  ++p;
5402 
5403  while (p != e) {
5404  uint c = *p;
5405  if (QChar(c).isLowSurrogate() && QChar(*(p - 1)).isHighSurrogate())
5406  c = QChar::surrogateToUcs4(*(p - 1), c);
5407  const QUnicodeTables::Properties *prop = qGetProp(c);
5408  if (prop->lowerCaseDiff || prop->lowerCaseSpecial) {
5410  memcpy(s.d->data, d->data, (p - d->data)*sizeof(ushort));
5411  ushort *pp = s.d->data + (p - d->data);
5412  while (p < e) {
5413  uint c = *p;
5414  if (QChar(c).isLowSurrogate() && QChar(*(p - 1)).isHighSurrogate())
5415  c = QChar::surrogateToUcs4(*(p - 1), c);
5416  prop = qGetProp(c);
5417  if (prop->lowerCaseSpecial) {
5418  int pos = pp - s.d->data;
5419  s.resize(s.d->size + SPECIAL_CASE_MAX_LEN);
5420  pp = s.d->data + pos;
5421  const ushort *specialCase = specialCaseMap + prop->lowerCaseDiff;
5422  while (*specialCase)
5423  *pp++ = *specialCase++;
5424  } else {
5425  *pp++ = *p + prop->lowerCaseDiff;
5426  }
5427  ++p;
5428  }
5429  s.truncate(pp - s.d->data);
5430  return s;
5431  }
5432  ++p;
5433  }
5434  return *this;
5435 }
unsigned char c[8]
Definition: qnumeric_p.h:62
bool isLowSurrogate() const
Returns true if the QChar is the low part of a utf16 surrogate (ie.
Definition: qchar.h:279
The QString class provides a Unicode character string.
Definition: qstring.h:83
bool isHighSurrogate() const
Returns true if the QChar is the high part of a utf16 surrogate (ie.
Definition: qchar.h:276
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
static const ushort specialCaseMap[]
static const QUnicodeTables::Properties * qGetProp(uint ucs4)
unsigned int uint
Definition: qglobal.h:996
Data * d
Definition: qstring.h:618
ushort * data
Definition: qstring.h:606
unsigned short ushort
Definition: qglobal.h:995
#define SPECIAL_CASE_MAX_LEN
static uint surrogateToUcs4(ushort high, ushort low)
Converts a UTF16 surrogate pair with the given high and low values to its UCS-4 code point...
Definition: qchar.h:297

◆ toShort()

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

Returns the string converted to a short using base base, which is 10 by default and must be between 2 and 36, or 0.

Returns 0 if the conversion fails.

If a conversion error occurs, *{ok} is set to false; otherwise {ok} is set to true.

If base is 0, the C language convention is used: If the string begins with "0x", base 16 is used; if the string begins with "0", base 8 is used; otherwise, base 10 is used.

Example:

QString str = "FF";
bool ok;
short hex = str.toShort(&ok, 16); // hex == 255, ok == true
short dec = str.toShort(&ok, 10); // dec == 0, ok == false
See also
number(), toUShort(), toInt()

Definition at line 6150 of file qstring.cpp.

6151 {
6152  long v = toLongLong(ok, base);
6153  if (v < SHRT_MIN || v > SHRT_MAX) {
6154  if (ok)
6155  *ok = false;
6156  v = 0;
6157  }
6158  return (short)v;
6159 }
qlonglong toLongLong(bool *ok=0, int base=10) const
Returns the string converted to a long long using base base, which is 10 by default and must be betwe...
Definition: qstring.cpp:5943
static const uint base
Definition: qurl.cpp:268

◆ toStdString()

std::string QString::toStdString ( ) const
inline

Returns a std::string object with the data contained in this QString.

The Unicode data is converted into 8-bit characters using the toAscii() function.

This operator is mostly useful to pass a QString to a function that accepts a std::string object.

If the QString contains Unicode characters that the QTextCodec::codecForCStrings() codec cannot handle, using this operator can lead to loss of information.

This operator is only available if Qt is configured with STL compatibility enabled.

See also
toAscii(), toLatin1(), toUtf8(), toLocal8Bit()

Definition at line 1044 of file qstring.h.

1045 { const QByteArray asc = toAscii(); return std::string(asc.constData(), asc.length()); }
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
int length() const
Same as size().
Definition: qbytearray.h:356
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
QByteArray toAscii() const Q_REQUIRED_RESULT
Returns an 8-bit representation of the string as a QByteArray.
Definition: qstring.cpp:4014

◆ toStdWString()

QStdWString QString::toStdWString ( ) const
inline

Returns a std::wstring object with the data contained in this QString.

The std::wstring is encoded in utf16 on platforms where wchar_t is 2 bytes wide (e.g. windows) and in ucs4 on platforms where wchar_t is 4 bytes wide (most Unix systems).

This operator is mostly useful to pass a QString to a function that accepts a std::wstring object.

This operator is only available if Qt is configured with STL compatibility enabled.

See also
utf16(), toAscii(), toLatin1(), toUtf8(), toLocal8Bit()

Definition at line 1051 of file qstring.h.

1052 {
1053  QStdWString str;
1054  str.resize(length());
1055 
1056 #if defined(_MSC_VER) && _MSC_VER >= 1400
1057  // VS2005 crashes if the string is empty
1058  if (!length())
1059  return str;
1060 #endif
1061 
1062  str.resize(toWCharArray(&(*str.begin())));
1063  return str;
1064 }
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
int toWCharArray(wchar_t *array) const
Fills the array with the data contained in this QString object.
Definition: qstring.cpp:1086
std::basic_string< wchar_t > QStdWString
Definition: qstring.h:58

◆ toUcs4()

QVector< uint > QString::toUcs4 ( ) const

Returns a UCS-4/UTF-32 representation of the string as a QVector<uint>.

Since
4.2

UCS-4 is a Unicode codec and is lossless. All characters from this string can be encoded in UCS-4. The vector is not null terminated.

See also
fromUtf8(), toAscii(), toLatin1(), toLocal8Bit(), QTextCodec, fromUcs4(), toWCharArray()

Definition at line 4095 of file qstring.cpp.

Referenced by QStringRef::constData(), and toSQLTCHAR().

4096 {
4097  QVector<uint> v(length());
4098  uint *a = v.data();
4099  int len = toUcs4_helper<uint>(utf16(), length(), a);
4100  v.resize(len);
4101  return v;
4102 }
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
long ASN1_INTEGER_get ASN1_INTEGER * a
unsigned int uint
Definition: qglobal.h:996
const ushort * utf16() const
Returns the QString as a &#39;\0\&#39;-terminated array of unsigned shorts.
Definition: qstring.cpp:5290

◆ toUInt()

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

Returns the string converted to an unsigned int using base base, which is 10 by default and must be between 2 and 36, or 0.

Returns 0 if the conversion fails.

If a conversion error occurs, *{ok} is set to false; otherwise {ok} is set to true.

If base is 0, the C language convention is used: If the string begins with "0x", base 16 is used; if the string begins with "0", base 8 is used; otherwise, base 10 is used.

Example:

QString str = "FF";
bool ok;
uint hex = str.toUInt(&ok, 16); // hex == 255, ok == true
uint dec = str.toUInt(&ok, 10); // dec == 0, ok == false
See also
number(), toInt()

Definition at line 6120 of file qstring.cpp.

Referenced by colorFromName(), QHttpHeader::contentLength(), QMYSQLResult::data(), QNativeWifiEngine::disconnectFromId(), QSystemLocalePrivate::firstDayOfWeek(), QLibraryPrivate::isPlugin(), QNlaThread::parseBlob(), QTextHtmlParser::parseEntity(), parseIp4(), parseIp6(), QXmlSimpleReaderPrivate::parseReference(), parseServerList(), QHostAddress::parseSubnet(), qExtractSecurityPolicyFromString(), NamedNodeMapClass::queryProperty(), NodeListClass::queryProperty(), and QXmlStreamReaderPrivate::resolveCharRef().

6121 {
6122  quint64 v = toULongLong(ok, base);
6123  if (v > UINT_MAX) {
6124  if (ok)
6125  *ok = false;
6126  v = 0;
6127  }
6128  return (uint)v;
6129 }
qulonglong toULongLong(bool *ok=0, int base=10) const
Returns the string converted to an unsigned long long using base base, which is 10 by default and mus...
Definition: qstring.cpp:5984
static const uint base
Definition: qurl.cpp:268
unsigned __int64 quint64
Definition: qglobal.h:943
unsigned int uint
Definition: qglobal.h:996

◆ toULong()

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

Returns the string converted to an unsigned long using base base, which is 10 by default and must be between 2 and 36, or 0.

Returns 0 if the conversion fails.

If a conversion error occurs, *{ok} is set to false; otherwise {ok} is set to true.

If base is 0, the C language convention is used: If the string begins with "0x", base 16 is used; if the string begins with "0", base 8 is used; otherwise, base 10 is used.

Example:

QString str = "FF";
bool ok;
ulong hex = str.toULong(&ok, 16); // hex == 255, ok == true
ulong dec = str.toULong(&ok, 10); // dec == 0, ok == false
See also
number()

Definition at line 6059 of file qstring.cpp.

6060 {
6061  quint64 v = toULongLong(ok, base);
6062  if (v > ULONG_MAX) {
6063  if (ok)
6064  *ok = false;
6065  v = 0;
6066  }
6067  return (ulong)v;
6068 }
qulonglong toULongLong(bool *ok=0, int base=10) const
Returns the string converted to an unsigned long long using base base, which is 10 by default and mus...
Definition: qstring.cpp:5984
static const uint base
Definition: qurl.cpp:268
unsigned __int64 quint64
Definition: qglobal.h:943
unsigned long ulong
Definition: qglobal.h:997

◆ toULongLong()

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

Returns the string converted to an unsigned long long using base base, which is 10 by default and must be between 2 and 36, or 0.

Returns 0 if the conversion fails.

If a conversion error occurs, *{ok} is set to false; otherwise {ok} is set to true.

If base is 0, the C language convention is used: If the string begins with "0x", base 16 is used; if the string begins with "0", base 8 is used; otherwise, base 10 is used.

Example:

QString str = "FF";
bool ok;
quint64 hex = str.toULongLong(&ok, 16); // hex == 255, ok == true
quint64 dec = str.toULongLong(&ok, 10); // dec == 0, ok == false
See also
number(), toLongLong()

Definition at line 5984 of file qstring.cpp.

Referenced by QPSQLResult::data(), QMYSQLResult::data(), QPatternist::DerivedInteger< DerivedType >::fromLexical(), toUInt(), toULong(), and toUShort().

5985 {
5986 #if defined(QT_CHECK_RANGE)
5987  if (base != 0 && (base < 2 || base > 36)) {
5988  qWarning("QString::toULongLong: Invalid base (%d)", base);
5989  base = 10;
5990  }
5991 #endif
5992 
5993  bool my_ok;
5994  QLocale def_locale;
5995  quint64 result = def_locale.d()->stringToUnsLongLong(*this, base, &my_ok, QLocalePrivate::FailOnGroupSeparators);
5996  if (my_ok) {
5997  if (ok != 0)
5998  *ok = true;
5999  return result;
6000  }
6001 
6002  QLocale c_locale(QLocale::C);
6003  return c_locale.d()->stringToUnsLongLong(*this, base, ok, QLocalePrivate::FailOnGroupSeparators);
6004 }
static const uint base
Definition: qurl.cpp:268
quint64 stringToUnsLongLong(const QString &num, int base, bool *ok, GroupSeparatorMode group_sep_mode) const
Definition: qlocale.cpp:3119
unsigned __int64 quint64
Definition: qglobal.h:943
Q_CORE_EXPORT void qWarning(const char *,...)
const QLocalePrivate * d() const
Definition: qlocale.cpp:761

◆ toUpper()

QString QString::toUpper ( ) const

Returns an uppercase copy of the string.

QString str = "TeXt";
str = str.toUpper(); // str == "TEXT"

The case conversion will always happen in the 'C' locale. For locale dependent case folding use QLocale::toUpper()

See also
toLower(), QLocale::toLower()

Definition at line 5483 of file qstring.cpp.

Referenced by _q_parseUnixDir(), QDeclarativeEngineDebugService::buildObjectDump(), classIDL(), QLocalePrivate::codeToCountry(), QLocalePrivate::dateTimeToString(), QKeySequencePrivate::decodeString(), QPatternist::NormalizeUnicodeFN::determineNormalizationForm(), QLocalePrivate::doubleToString(), DumpIDL(), QPatternist::AbstractFloat< isDouble >::fromLexical(), getFmtString(), QNativeWifiEngine::getInterfaceFromId(), QFileIconProviderPrivate::getWinIcon(), QSqlRecord::indexOf(), QMenuBar::keyPressEvent(), QFSFileEnginePrivate::longFileName(), QLocalePrivate::longLongToString(), nameToType(), QFileSystemModelPrivate::node(), QIBaseDriver::open(), QSplitter::operator>>(), QDB2Driver::primaryIndex(), QIBaseDriver::primaryIndex(), QOCIDriver::primaryIndex(), qCreatev2Hash(), qGetODBCVersion(), qmlxmlhttprequest_open(), qmlxmlhttprequest_setRequestHeader(), qStringFromUcs2Le(), rasterFallbacksMask(), MetaObjectGenerator::readClassInfo(), MetaObjectGenerator::readEventInfo(), MetaObjectGenerator::readInterfaceInfo(), QIBaseResult::record(), QDB2Driver::record(), QIBaseDriver::record(), QOCIDriver::record(), QInternalMimeData::renderDataHelper(), QDB2Driver::tables(), QOCIDriver::tables(), QLocale::toUpper(), QLocalePrivate::unsLongLongToString(), UpdateRegistry(), and xdndObtainData().

5484 {
5485  const ushort *p = d->data;
5486  if (!p)
5487  return *this;
5488  if (!d->size)
5489  return *this;
5490 
5491  const ushort *e = d->data + d->size;
5492 
5493  // this avoids one out of bounds check in the loop
5494  if (QChar(*p).isLowSurrogate())
5495  ++p;
5496 
5497  while (p != e) {
5498  uint c = *p;
5499  if (QChar(c).isLowSurrogate() && QChar(*(p - 1)).isHighSurrogate())
5500  c = QChar::surrogateToUcs4(*(p - 1), c);
5501  const QUnicodeTables::Properties *prop = qGetProp(c);
5502  if (prop->upperCaseDiff || prop->upperCaseSpecial) {
5504  memcpy(s.d->data, d->data, (p - d->data)*sizeof(ushort));
5505  ushort *pp = s.d->data + (p - d->data);
5506  while (p < e) {
5507  uint c = *p;
5508  if (QChar(c).isLowSurrogate() && QChar(*(p - 1)).isHighSurrogate())
5509  c = QChar::surrogateToUcs4(*(p - 1), c);
5510  prop = qGetProp(c);
5511  if (prop->upperCaseSpecial) {
5512  int pos = pp - s.d->data;
5513  s.resize(s.d->size + SPECIAL_CASE_MAX_LEN);
5514  pp = s.d->data + pos;
5515  const ushort *specialCase = specialCaseMap + prop->upperCaseDiff;
5516  while (*specialCase)
5517  *pp++ = *specialCase++;
5518  } else {
5519  *pp++ = *p + prop->upperCaseDiff;
5520  }
5521  ++p;
5522  }
5523  s.truncate(pp - s.d->data);
5524  return s;
5525  }
5526  ++p;
5527  }
5528  return *this;
5529 }
unsigned char c[8]
Definition: qnumeric_p.h:62
bool isLowSurrogate() const
Returns true if the QChar is the low part of a utf16 surrogate (ie.
Definition: qchar.h:279
The QString class provides a Unicode character string.
Definition: qstring.h:83
bool isHighSurrogate() const
Returns true if the QChar is the high part of a utf16 surrogate (ie.
Definition: qchar.h:276
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
static const ushort specialCaseMap[]
static const QUnicodeTables::Properties * qGetProp(uint ucs4)
unsigned int uint
Definition: qglobal.h:996
Data * d
Definition: qstring.h:618
ushort * data
Definition: qstring.h:606
unsigned short ushort
Definition: qglobal.h:995
#define SPECIAL_CASE_MAX_LEN
static uint surrogateToUcs4(ushort high, ushort low)
Converts a UTF16 surrogate pair with the given high and low values to its UCS-4 code point...
Definition: qchar.h:297

◆ toUShort()

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

Returns the string converted to an unsigned short using base base, which is 10 by default and must be between 2 and 36, or 0.

Returns 0 if the conversion fails.

If a conversion error occurs, *{ok} is set to false; otherwise {ok} is set to true.

If base is 0, the C language convention is used: If the string begins with "0x", base 16 is used; if the string begins with "0", base 8 is used; otherwise, base 10 is used.

Example:

QString str = "FF";
bool ok;
ushort hex = str.toUShort(&ok, 16); // hex == 255, ok == true
ushort dec = str.toUShort(&ok, 10); // dec == 0, ok == false
See also
number(), toShort()

Definition at line 6180 of file qstring.cpp.

Referenced by QNativeWifiEngine::disconnectFromId(), and QCss::Scanner::preprocess().

6181 {
6182  ulong v = toULongLong(ok, base);
6183  if (v > USHRT_MAX) {
6184  if (ok)
6185  *ok = false;
6186  v = 0;
6187  }
6188  return (ushort)v;
6189 }
qulonglong toULongLong(bool *ok=0, int base=10) const
Returns the string converted to an unsigned long long using base base, which is 10 by default and mus...
Definition: qstring.cpp:5984
static const uint base
Definition: qurl.cpp:268
unsigned long ulong
Definition: qglobal.h:997
unsigned short ushort
Definition: qglobal.h:995

◆ toUtf8()

QByteArray QString::toUtf8 ( ) const

Returns a UTF-8 representation of the string as a QByteArray.

UTF-8 is a Unicode codec and can represent all characters in a Unicode string like QString.

However, in the Unicode range, there are certain codepoints that are not considered characters. The Unicode standard reserves the last two codepoints in each Unicode Plane (U+FFFE, U+FFFF, U+1FFFE, U+1FFFF, U+2FFFE, etc.), as well as 16 codepoints in the range U+FDD0..U+FDDF, inclusive, as non-characters. If any of those appear in the string, they may be discarded and will not appear in the UTF-8 representation, or they may be replaced by one or more replacement characters.

See also
fromUtf8(), toAscii(), toLatin1(), toLocal8Bit(), QTextCodec

Definition at line 4074 of file qstring.cpp.

Referenced by QDBusConnectionPrivate::activateCall(), QDeclarativeImportsPrivate::add(), QZipWriterPrivate::addEntry(), QDeclarativeXMLHttpRequest::addHeader(), QDnotifyFileSystemWatcherEngine::addPaths(), QDBusMarshaller::append(), Maemo::appendVariantToDBusMessage(), QApplicationPrivate::applyX11SpecificCommandLineArguments(), QDeclarativeEnginePrivate::atob(), QJSDebuggerAgent::backtrace(), QDeclarativeEnginePrivate::btoa(), QDeclarativeCompiler::buildDynamicMeta(), QAuthenticatorPrivate::calculateResponse(), QFileSystemEngine::canonicalName(), QDeclarativePropertyMap::clear(), QDeclarativeCompiler::compile(), QDeclarativeCompiler::compileAlias(), QDeclarativeListModelParser::compileProperty(), QDBusConnection::connectToBus(), QDBusConnection::connectToPeer(), QStringRef::constData(), QDeclarativeContext::contextProperty(), QMacPasteboardMimeAny::convertFromMime(), QWindowsMimeHtml::convertFromMime(), QMacPasteboardMimeVCard::convertFromMime(), QWindowsMimeText::convertToMime(), QDeclarativePropertyCache::create(), QDeclarativePathView::createdItem(), QPatternist::ExpressionFactory::createExpression(), QDeclarativeEnginePrivate::createQmlObject(), QDeclarativeXmlQueryEngine::doQueryJob(), QPSPrintEnginePrivate::emitHeader(), encodeString(), QDeclarativeObjectMethodScriptClass::enumType(), QODBCResult::exec(), QPSQLDriverPrivate::exec(), QFontconfigDatabase::fallbacksForFamily(), QWSSoundServerPrivate::feedDevice(), QDeclarativeXMLHttpRequest::findTextCodec(), QFontconfigDatabase::fontEngine(), QBBClipboard::MimeData::formats(), fromScriptValue(), QUrl::fromUserInput(), Maemo::GConfItemFast::getEntries(), getFcPattern(), getImage(), QDeclarativePathViewPrivate::getItem(), getMacLocaleName(), getPixmap(), QFileIconProviderPrivate::getWinIcon(), QBBClipboard::MimeData::hasFormat(), QDeclarativeXMLHttpRequest::header(), QDeclarativeImportDatabase::importPlugin(), QDeclarativePropertyPrivate::initProperty(), QDeclarativePropertyMap::insert(), QScript::integerFromString(), QTextLine::layout_helper(), QLibraryPrivate::load_sys(), locale_encode(), QDBusMessagePrivate::makeLocal(), QSharedMemoryPrivate::makePlatformSafeKey(), QDeclarativeEnginePrivate::md5(), navigatorInvoke(), QSQLiteDriver::open(), QODBCDriver::open(), QDeclarativePropertyMap::operator[](), QDeclarativeBindingCompilerPrivate::parseName(), QODBCResult::prepare(), QODBCDriver::primaryIndex(), QFontEngineMac::properties(), QFontEngine::properties(), QTextStreamPrivate::putString(), QDBusError::QDBusError(), qDBusPropertyGet(), qDBusPropertySet(), QDBusServer::QDBusServer(), qExtractSecurityPolicyFromString(), qmlsqldatabase_open_sync(), qmlxmlhttprequest_open(), qmlxmlhttprequest_send(), qstring_to_xtp(), qt_addPatternProps(), qt_mac_create_fsref(), qt_mac_execute_apple_script(), QDeclarativeValueTypeScriptClass::queryProperty(), QDeclarativeTypeNameScriptClass::queryProperty(), QODBCDriver::record(), registerFont(), QSQLite2Result::reset(), QODBCResult::reset(), QDeclarativeTypeData::resolveTypes(), QTextBrowserPrivate::resolveUrl(), QBBClipboard::MimeData::retrieveData(), QMimeDataPrivate::retrieveTypedData(), QWSSoundServerClient::sendClientMessage(), set_text(), QXmlQuery::setFocus(), QBBClipboard::setMimeData(), ModelNode::setObjectValue(), ModelNode::setProperty(), QXmlQuery::setQuery(), QXcbWindow::setWindowTitle(), QWidgetPrivate::setWindowTitle_sys(), sm_setProperty(), QProcessPrivate::startDetached(), QProcessPrivate::startProcess(), QDeclarativeVisualDataModel::stringValue(), QODBCDriver::tables(), QDeclarativeCompiler::testQualifiedEnumAssignment(), QDomDocument::toByteArray(), QDBusMessagePrivate::toDBusMessage(), QUrlPrivate::toEncoded(), toPercentEncodingHelper(), toSQLTCHAR(), QDeclarativePathViewPrivate::updateItem(), QDeclarativePropertyMap::value(), QTextOdfWriter::writeInlineCharacter(), and xic_draw_callback().

4075 {
4076  if (isNull())
4077  return QByteArray();
4078 
4079  return QUtf8::convertFromUnicode(constData(), length(), 0);
4080 }
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
static QByteArray convertFromUnicode(const QChar *, int, QTextCodec::ConverterState *)
Definition: qutfcodec.cpp:64
bool isNull() const
Returns true if this string is null; otherwise returns false.
Definition: qstring.h:505
const QChar * constData() const
Returns a pointer to the data stored in the QString.
Definition: qstring.h:712

◆ toWCharArray()

int QString::toWCharArray ( wchar_t *  array) const

Fills the array with the data contained in this QString object.

Since
4.2

The array is encoded in utf16 on platforms where wchar_t is 2 bytes wide (e.g. windows) and in ucs4 on platforms where wchar_t is 4 bytes wide (most Unix systems).

array has to be allocated by the caller and contain enough space to hold the complete string (allocating the array with the same length as the string is always sufficient).

returns the actual length of the string in array.

Note
This function does not append a null character to the array.
See also
utf16(), toUcs4(), toAscii(), toLatin1(), toUtf8(), toLocal8Bit(), toStdWString()

Definition at line 1086 of file qstring.cpp.

Referenced by toStdWString().

1087 {
1088  if (sizeof(wchar_t) == sizeof(QChar)) {
1089  memcpy(array, utf16(), sizeof(wchar_t)*length());
1090  return length();
1091  } else {
1092  return toUcs4_helper<wchar_t>(utf16(), length(), array);
1093  }
1094 }
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
const ushort * utf16() const
Returns the QString as a &#39;\0\&#39;-terminated array of unsigned shorts.
Definition: qstring.cpp:5290

◆ trimmed()

QString QString::trimmed ( ) const

Returns a string that has whitespace removed from the start and the end.

Whitespace means any character for which QChar::isSpace() returns true. This includes the ASCII characters '\t', '\n', '\v', '\f', '\r', and ' '.

Example:

QString str = " lots\t of\nwhitespace\r\n ";
str = str.trimmed();
// str == "lots\t of\nwhitespace"

Unlike simplified(), trimmed() leaves internal whitespace alone.

See also
simplified()

Definition at line 4506 of file qstring.cpp.

Referenced by QFtpPrivate::_q_startNextCommand(), QTransformedScreen::connect(), QHttpHeader::contentType(), createImageNode(), createSvgNode(), QPatternist::NormalizeUnicodeFN::determineNormalizationForm(), QAxBase::dynamicCallHelper(), QPatternist::NCNameConstructor::evaluateSingleton(), QSymSQLResult::exec(), QSqlQuery::exec(), familyList(), QDateTimeParser::findAmPm(), QIconLoader::findIconHelper(), fontPath(), fractionDigitsForDecimal(), QPatternist::HexBinary::fromLexical(), QPatternist::Decimal::fromLexical(), QPatternist::Boolean::fromLexical(), QPatternist::DerivedString< TypeToken >::fromLexical(), QSslCertificate::fromPath(), QUrl::fromUserInput(), QDeclarativeCompiler::genObjectBody(), getLocations(), QGtkStylePrivate::getThemeName(), QPatternist::XSLTTokenizer::insideSequenceConstructor(), QDeclarativeJS::integerFromString(), QScript::integerFromString(), Text::isElementContentWhitespace(), QMetaEnum::keysToValue(), launchWebBrowser(), QHttpHeader::parse(), parseAnimateColorNode(), parseAnimateTransformNode(), QTextHtmlParser::parseCloseTag(), parseColorValue(), parseCompOp(), QFtpDTP::parseDir(), parseFont(), parseLength(), QHttpHeader::parseLine(), parseOpacity(), parseOthers(), QDeclarativeGridScaledImage::QDeclarativeGridScaledImage(), qt_error_string(), qt_get_screen(), qt_mac_extract_filter(), qt_parsePrintcap(), qt_parseSpoolInterface(), qt_set_x11_resources(), qt_strippedText(), QFtp::rawCommand(), QPatternist::XSLTTokenizer::readAlternativeAttribute(), QNSOpenSavePanelDelegate::removeExtensions:, QPatternist::XsdValidatingInstanceReader::selectNodeSets(), QUrlPrivate::setAuthority(), QScriptDebuggerLocalsModel::setData(), QUrl::setUserInfo(), setWidthAttribute(), standardLibraryErrorString(), QLocalePrivate::stringToDouble(), QLocalePrivate::stringToLongLong(), QLocalePrivate::stringToUnsLongLong(), QAbstractSpinBoxPrivate::stripped(), QCoreFuriCuri::timerEvent(), QDeclarativePropertyAction::transition(), QDeclarativePropertyAnimation::transition(), trimmed(), QAbstractXmlReceiver::whitespaceOnly(), QPatternist::AccelTreeBuilder< true >::whitespaceOnly(), and QPatternist::QAbstractXmlReceiver::whitespaceOnly().

4507 {
4508  if (d->size == 0)
4509  return *this;
4510  const QChar *s = (const QChar*)d->data;
4511  if (!s->isSpace() && !s[d->size-1].isSpace())
4512  return *this;
4513  int start = 0;
4514  int end = d->size - 1;
4515  while (start<=end && s[start].isSpace()) // skip white space from start
4516  start++;
4517  if (start <= end) { // only white space
4518  while (end && s[end].isSpace()) // skip white space from end
4519  end--;
4520  }
4521  int l = end - start + 1;
4522  if (l <= 0) {
4523  shared_empty.ref.ref();
4524  return QString(&shared_empty, 0);
4525  }
4526  return QString(s + start, l);
4527 }
iterator end()
Returns an STL-style iterator pointing to the imaginary character after the last character in the str...
Definition: qstring.h:894
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
QBasicAtomicInt ref
Definition: qstring.h:604
bool isSpace() const
Returns true if the character is a separator character (Separator_* categories); otherwise returns fa...
Definition: qchar.cpp:609
Data * d
Definition: qstring.h:618
ushort * data
Definition: qstring.h:606
if(void) toggleToolbarShown
QFactoryLoader * l
QString()
Constructs a null string.
Definition: qstring.h:879
static Data shared_empty
Definition: qstring.h:617

◆ truncate()

void QString::truncate ( int  position)

Truncates the string at the given position index.

If the specified position index is beyond the end of the string, nothing happens.

Example:

QString str = "Vladivostok";
str.truncate(4);
// str == "Vlad"

If position is negative, it is equivalent to passing zero.

See also
chop(), resize(), left()

Definition at line 4603 of file qstring.cpp.

Referenced by QHttpPrivate::_q_slotReadyRead(), QCoreApplicationPrivate::appendApplicationPathToLibraryPaths(), QDBusAbstractInterface::callWithArgumentList(), QVNCScreen::connect(), QTransformedScreen::connect(), QWindowsMimeText::convertFromMime(), QBuiltInMimes::convertFromMime(), QUtf8::convertToUnicode(), QUtf16::convertToUnicode(), QUtf32::convertToUnicode(), QLocalePrivate::doubleToString(), QLCDNumberPrivate::drawString(), errorCodeToString(), QPatternist::TranslateFN::evaluateSingleton(), QWSSoundServerPrivate::feedDevice(), find_translation(), QSqlDriver::formatValue(), QProcessEnvironmentPrivate::fromList(), QDBusConnectionPrivate::handleSignal(), iniChopTrailingSpaces(), QSettingsPrivate::normalizedKey(), parse_locale_tag(), QDateTimeParser::parseSection(), QHostAddress::parseSubnet(), QSettingsPrivate::processChild(), qt_get_screen(), qt_nameprep(), QDirPrivate::setPath(), simplified(), QAbstractSpinBox::sizeHint(), toLower(), toPunycodeHelper(), QKeySequence::toString(), toUpper(), QWSSoundServerClient::tryReadCommand(), vsprintf(), and write_xpm_image().

4604 {
4605  if (pos < d->size)
4606  resize(pos);
4607 }
int size() const
Returns the number of characters in this string.
Definition: qstring.h:102
void resize(int size)
Sets the size of the string to size characters.
Definition: qstring.cpp:1353

◆ unicode()

const QChar * QString::unicode ( ) const
inline

Returns a '\0'-terminated Unicode representation of the string.

The result remains valid until the string is modified.

See also
utf16()

Definition at line 706 of file qstring.h.

Referenced by QXmlStreamPrivateTagStack::addToStringStorage(), QStringRef::appendTo(), bidiItemize(), QFontMetrics::charWidth(), QDir::cleanPath(), QLocalePrivate::codeToCountry(), QLocalePrivate::codeToLanguage(), compare(), QStringRef::constData(), QWindowsMimeText::convertFromMime(), QBuiltInMimes::convertFromMime(), QIsciiCodec::convertToUnicode(), QUtf8::convertToUnicode(), QUtf16::convertToUnicode(), QUtf32::convertToUnicode(), count(), QStringRef::count(), QStringRef::data(), QKeySequencePrivate::decodeString(), QLocalePrivate::doubleToString(), QTextLine::draw(), drawMenuText(), QPainter::drawText(), DumpIDL(), QAxBase::dynamicCallHelper(), endsWith(), QStringRef::endsWith(), QRegExp::exactMatch(), findArgEscapes(), QAxServerBase::GetCurFile(), getEnglishName(), QRegExpEngine::goodStringMatch(), QStringMatcher::indexIn(), QRegExp::indexIn(), indexOf(), QStringRef::indexOf(), QFileSystemEntry::isAbsolute(), QFileSystemEntry::isRelative(), QDBusUtil::isValidBusName(), QDBusUtil::isValidMemberName(), QDBusUtil::isValidPartOfObjectPath(), QDBusUtil::isValidUniqueConnectionName(), QTextEngine::itemize(), QRegExp::lastIndexIn(), lastIndexOf(), QStringRef::lastIndexOf(), localizedName(), QLocalePrivate::longLongToString(), QScriptEnginePrivate::newRegExp(), nextDotDelimiter(), QLocalePrivate::numberToCLocale(), operator<<(), QStringRef::operator==(), QTextDocumentPrivate::plainText(), qHash(), QRegExpEngine::QRegExpEngine(), QStringMatcher::QStringMatcher(), QStringToBSTR(), QStringToOLESTR(), qt_keyrelease_scanner(), qt_mac_to_pascal_string(), qt_string_count(), qt_string_normalize(), QUuid::QUuid(), qwsSetClipboardText(), replace(), replaceArgEscapes(), QCharRef::row(), section(), QStringMatcher::setCaseSensitivity(), QScript::Lexer::setCode(), QDeclarativeJS::Lexer::setCode(), QXmlInputSource::setData(), QWSPlaySoundCommand::setFileName(), QWSQCopSendCommand::setMessage(), QStringMatcher::setPattern(), startsWith(), QStringRef::startsWith(), QTextBoundaryFinder::string(), QStringRef::toAscii(), toLatin1(), QStringRef::toLatin1(), QStringRef::toLocal8Bit(), toSQLTCHAR(), QUuid::toString(), QStringRef::toUcs4(), QXlibKeyboard::translateKeySym(), QXcbKeyboard::translateKeySym(), translateKeySym(), QStringRef::unicode(), QLocalePrivate::unsLongLongToString(), and wc2rx().

707 { return reinterpret_cast<const QChar*>(d->data); }
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
Data * d
Definition: qstring.h:618
ushort * data
Definition: qstring.h:606

◆ updateProperties()

void QString::updateProperties ( ) const
private
Warning
This function is not part of the public interface.

Definition at line 7510 of file qstring.cpp.

7511 {
7512  ushort *p = d->data;
7513  ushort *end = p + d->size;
7514  d->simpletext = true;
7515  while (p < end) {
7516  ushort uc = *p;
7517  // sort out regions of complex text formatting
7518  if (uc > 0x058f && (uc < 0x1100 || uc > 0xfb0f)) {
7519  d->simpletext = false;
7520  }
7521  p++;
7522  }
7523 
7525  d->clean = true;
7526 }
iterator end()
Returns an STL-style iterator pointing to the imaginary character after the last character in the str...
Definition: qstring.h:894
ushort clean
Definition: qstring.h:607
static bool isStringRightToLeft(const ushort *p, const ushort *end)
Definition: qstring.cpp:7487
Data * d
Definition: qstring.h:618
ushort * data
Definition: qstring.h:606
unsigned short ushort
Definition: qglobal.h:995
ushort righttoleft
Definition: qstring.h:609
ushort simpletext
Definition: qstring.h:608

◆ utf16()

const ushort * QString::utf16 ( ) const

Returns the QString as a '\0\'-terminated array of unsigned shorts.

The result remains valid until the string is modified.

The returned string is in host byte order.

See also
unicode()

Definition at line 5290 of file qstring.cpp.

Referenced by QAxScriptEngine::addItem(), QLocalServerPrivate::addListener(), QFileSystemModelPrivate::addNode(), QOCIResultPrivate::bindValue(), QLastResortMimes::canConvertToMime(), QNativeWifiEngine::connectToId(), QWindowsMimeURI::convertFromMime(), QLastResortMimes::convertToMime(), QAxServerBase::create(), QAxServerBase::createMenu(), createOrOpenKey(), QAxServerBase::createPopup(), deleteChildGroups(), QAxMetaObject::dispIDofName(), QVistaHelper::drawTitleText(), QSQLiteResult::exec(), QOCICols::execBatch(), expandEnvStrings(), QFileSystemEngine::fillMetaData(), QFileSystemEngine::fillPermissions(), QSystemTrayIconSys::findTrayGeometry(), generateName(), getEnglishName(), getFindData(), XPThemeData::handle(), QFileIconProvider::icon(), QWindowsSystemProxy::init(), QAxScriptEngine::initialize(), QAxBase::initializeRemote(), isDirPath(), launchWebBrowser(), QSystemLibrary::load(), QAxServerBase::Load(), loadEngine(), QFSFileEnginePrivate::longFileName(), QFileDialogPrivate::maxNameLength(), QFileSystemEngine::nativeAbsoluteFilePath(), QFSFileEnginePrivate::nativeHandle(), QFileSystemModelPrivate::node(), QOCIDriver::open(), openDocument(), openKey(), QTest::outputMessage(), QFileSystemEngine::owner(), QProcessPrivate::pipeWriterBytesToWrite(), populate_database(), QOCIResult::prepare(), qAxInit(), QDeclarative_isFileCaseCorrect(), qStreamNtlmString(), qStringAsUcs2Le(), qt_create_commandline(), qt_create_internal_window(), qt_create_pipe(), qt_message_output(), QAxServerBase::qt_metacall(), qt_reg_winclass(), qt_tablet_cleanup_wce(), qt_wce_insert_action(), qt_wce_rename_menu_item(), qt_win_get_existing_directory(), qt_win_get_save_file_name(), qt_win_make_OFN(), qt_wince_is_platform(), QtCeSetClipboard(), qToTChar(), QtWndProc(), QWin32PrintEnginePrivate::queryDefault(), qWinCmdArgs(), qWinMsgHandler(), MetaObjectGenerator::readClassInfo(), QWinSettingsPrivate::readKey(), readLink(), readSymLink(), QAxScriptManager::registerEngine(), registerFont(), QWindowsMime::registerMimeType(), QWinSettingsPrivate::remove(), QAxServerBase::Save(), QWinSettingsPrivate::set(), QAxBase::setControl(), QSystemTrayIconSys::setIconContents(), QSystemTrayIconSys::showMessage(), SoundPlayProc(), QConfFileSettingsPrivate::syncConfFile(), QSystemLocalePrivate::toCurrencyString(), toUcs4(), toWCharArray(), QFileSystemEngine::uncListSharesOnServer(), unregWinClasses(), UpdateRegistry(), winGetExistDirCallbackProc(), WinMain(), QEventDispatcherWin32Private::~QEventDispatcherWin32Private(), and QWinSettingsPrivate::~QWinSettingsPrivate().

5291 {
5292  if (d->data != d->array) {
5293  QString *that = const_cast<QString*>(this);
5294  that->realloc(); // ensure '\\0'-termination for ::fromRawData strings
5295  return that->d->data;
5296  }
5297  return d->array;
5298 }
void realloc()
Definition: qstring.cpp:1472
The QString class provides a Unicode character string.
Definition: qstring.h:83
Data * d
Definition: qstring.h:618
ushort * data
Definition: qstring.h:606
ushort array[1]
Definition: qstring.h:614

◆ vsprintf()

QString & QString::vsprintf ( const char *  cformat,
va_list  ap 
)

Equivalent method to sprintf(), but takes a va_list ap instead a list of variable arguments.

See the sprintf() documentation for an explanation of cformat.

This method does not call the va_end macro, the caller is responsible to call va_end on ap.

See also
sprintf()

Definition at line 5587 of file qstring.cpp.

Referenced by qErrnoWarning(), qt_message(), QByteArray::qvsnprintf(), and sprintf().

5588 {
5589  QLocale locale(QLocale::C);
5590 
5591  if (!cformat || !*cformat) {
5592  // Qt 1.x compat
5593  *this = fromLatin1("");
5594  return *this;
5595  }
5596 
5597  // Parse cformat
5598 
5599  QString result;
5600  const char *c = cformat;
5601  for (;;) {
5602  // Copy non-escape chars to result
5603 #ifndef QT_NO_TEXTCODEC
5604  int i = 0;
5605  while (*(c + i) != '\0' && *(c + i) != '%')
5606  ++i;
5607  if (codecForCStrings)
5608  result.append(codecForCStrings->toUnicode(c, i));
5609  else
5610  result.append(fromLatin1(c, i));
5611  c += i;
5612 #else
5613  while (*c != '\0' && *c != '%')
5614  result.append(QLatin1Char(*c++));
5615 #endif
5616 
5617  if (*c == '\0')
5618  break;
5619 
5620  // Found '%'
5621  const char *escape_start = c;
5622  ++c;
5623 
5624  if (*c == '\0') {
5625  result.append(QLatin1Char('%')); // a % at the end of the string - treat as non-escape text
5626  break;
5627  }
5628  if (*c == '%') {
5629  result.append(QLatin1Char('%')); // %%
5630  ++c;
5631  continue;
5632  }
5633 
5634  // Parse flag characters
5635  uint flags = 0;
5636  bool no_more_flags = false;
5637  do {
5638  switch (*c) {
5639  case '#': flags |= QLocalePrivate::Alternate; break;
5640  case '0': flags |= QLocalePrivate::ZeroPadded; break;
5641  case '-': flags |= QLocalePrivate::LeftAdjusted; break;
5642  case ' ': flags |= QLocalePrivate::BlankBeforePositive; break;
5643  case '+': flags |= QLocalePrivate::AlwaysShowSign; break;
5644  case '\'': flags |= QLocalePrivate::ThousandsGroup; break;
5645  default: no_more_flags = true; break;
5646  }
5647 
5648  if (!no_more_flags)
5649  ++c;
5650  } while (!no_more_flags);
5651 
5652  if (*c == '\0') {
5653  result.append(QLatin1String(escape_start)); // incomplete escape, treat as non-escape text
5654  break;
5655  }
5656 
5657  // Parse field width
5658  int width = -1; // -1 means unspecified
5659  if (qIsDigit(*c)) {
5660  QString width_str;
5661  while (*c != '\0' && qIsDigit(*c))
5662  width_str.append(QLatin1Char(*c++));
5663 
5664  // can't be negative - started with a digit
5665  // contains at least one digit
5666  width = width_str.toInt();
5667  }
5668  else if (*c == '*') {
5669  width = va_arg(ap, int);
5670  if (width < 0)
5671  width = -1; // treat all negative numbers as unspecified
5672  ++c;
5673  }
5674 
5675  if (*c == '\0') {
5676  result.append(QLatin1String(escape_start)); // incomplete escape, treat as non-escape text
5677  break;
5678  }
5679 
5680  // Parse precision
5681  int precision = -1; // -1 means unspecified
5682  if (*c == '.') {
5683  ++c;
5684  if (qIsDigit(*c)) {
5685  QString precision_str;
5686  while (*c != '\0' && qIsDigit(*c))
5687  precision_str.append(QLatin1Char(*c++));
5688 
5689  // can't be negative - started with a digit
5690  // contains at least one digit
5691  precision = precision_str.toInt();
5692  }
5693  else if (*c == '*') {
5694  precision = va_arg(ap, int);
5695  if (precision < 0)
5696  precision = -1; // treat all negative numbers as unspecified
5697  ++c;
5698  }
5699  }
5700 
5701  if (*c == '\0') {
5702  result.append(QLatin1String(escape_start)); // incomplete escape, treat as non-escape text
5703  break;
5704  }
5705 
5706  // Parse the length modifier
5707  enum LengthMod { lm_none, lm_hh, lm_h, lm_l, lm_ll, lm_L, lm_j, lm_z, lm_t };
5708  LengthMod length_mod = lm_none;
5709  switch (*c) {
5710  case 'h':
5711  ++c;
5712  if (*c == 'h') {
5713  length_mod = lm_hh;
5714  ++c;
5715  }
5716  else
5717  length_mod = lm_h;
5718  break;
5719 
5720  case 'l':
5721  ++c;
5722  if (*c == 'l') {
5723  length_mod = lm_ll;
5724  ++c;
5725  }
5726  else
5727  length_mod = lm_l;
5728  break;
5729 
5730  case 'L':
5731  ++c;
5732  length_mod = lm_L;
5733  break;
5734 
5735  case 'j':
5736  ++c;
5737  length_mod = lm_j;
5738  break;
5739 
5740  case 'z':
5741  case 'Z':
5742  ++c;
5743  length_mod = lm_z;
5744  break;
5745 
5746  case 't':
5747  ++c;
5748  length_mod = lm_t;
5749  break;
5750 
5751  default: break;
5752  }
5753 
5754  if (*c == '\0') {
5755  result.append(QLatin1String(escape_start)); // incomplete escape, treat as non-escape text
5756  break;
5757  }
5758 
5759  // Parse the conversion specifier and do the conversion
5760  QString subst;
5761  switch (*c) {
5762  case 'd':
5763  case 'i': {
5764  qint64 i;
5765  switch (length_mod) {
5766  case lm_none: i = va_arg(ap, int); break;
5767  case lm_hh: i = va_arg(ap, int); break;
5768  case lm_h: i = va_arg(ap, int); break;
5769  case lm_l: i = va_arg(ap, long int); break;
5770  case lm_ll: i = va_arg(ap, qint64); break;
5771  case lm_j: i = va_arg(ap, long int); break;
5772  case lm_z: i = va_arg(ap, size_t); break;
5773  case lm_t: i = va_arg(ap, int); break;
5774  default: i = 0; break;
5775  }
5776  subst = locale.d()->longLongToString(i, precision, 10, width, flags);
5777  ++c;
5778  break;
5779  }
5780  case 'o':
5781  case 'u':
5782  case 'x':
5783  case 'X': {
5784  quint64 u;
5785  switch (length_mod) {
5786  case lm_none: u = va_arg(ap, uint); break;
5787  case lm_hh: u = va_arg(ap, uint); break;
5788  case lm_h: u = va_arg(ap, uint); break;
5789  case lm_l: u = va_arg(ap, ulong); break;
5790  case lm_ll: u = va_arg(ap, quint64); break;
5791  case lm_z: u = va_arg(ap, size_t); break;
5792  default: u = 0; break;
5793  }
5794 
5795  if (qIsUpper(*c))
5796  flags |= QLocalePrivate::CapitalEorX;
5797 
5798  int base = 10;
5799  switch (qToLower(*c)) {
5800  case 'o':
5801  base = 8; break;
5802  case 'u':
5803  base = 10; break;
5804  case 'x':
5805  base = 16; break;
5806  default: break;
5807  }
5808  subst = locale.d()->unsLongLongToString(u, precision, base, width, flags);
5809  ++c;
5810  break;
5811  }
5812  case 'E':
5813  case 'e':
5814  case 'F':
5815  case 'f':
5816  case 'G':
5817  case 'g':
5818  case 'A':
5819  case 'a': {
5820  double d;
5821  if (length_mod == lm_L)
5822  d = va_arg(ap, long double); // not supported - converted to a double
5823  else
5824  d = va_arg(ap, double);
5825 
5826  if (qIsUpper(*c))
5827  flags |= QLocalePrivate::CapitalEorX;
5828 
5830  switch (qToLower(*c)) {
5831  case 'e': form = QLocalePrivate::DFExponent; break;
5832  case 'a': // not supported - decimal form used instead
5833  case 'f': form = QLocalePrivate::DFDecimal; break;
5834  case 'g': form = QLocalePrivate::DFSignificantDigits; break;
5835  default: break;
5836  }
5837  subst = locale.d()->doubleToString(d, precision, form, width, flags);
5838  ++c;
5839  break;
5840  }
5841  case 'c': {
5842  if (length_mod == lm_l)
5843  subst = QChar((ushort) va_arg(ap, int));
5844  else
5845  subst = QLatin1Char((uchar) va_arg(ap, int));
5846  ++c;
5847  break;
5848  }
5849  case 's': {
5850  if (length_mod == lm_l) {
5851  const ushort *buff = va_arg(ap, const ushort*);
5852  const ushort *ch = buff;
5853  while (*ch != 0)
5854  ++ch;
5855  subst.setUtf16(buff, ch - buff);
5856  } else
5857  subst = QString::fromUtf8(va_arg(ap, const char*));
5858  if (precision != -1)
5859  subst.truncate(precision);
5860  ++c;
5861  break;
5862  }
5863  case 'p': {
5864  void *arg = va_arg(ap, void*);
5865 #ifdef Q_OS_WIN64
5866  quint64 i = reinterpret_cast<quint64>(arg);
5867 #else
5868  quint64 i = reinterpret_cast<unsigned long>(arg);
5869 #endif
5870  flags |= QLocalePrivate::Alternate;
5871  subst = locale.d()->unsLongLongToString(i, precision, 16, width, flags);
5872  ++c;
5873  break;
5874  }
5875  case 'n':
5876  switch (length_mod) {
5877  case lm_hh: {
5878  signed char *n = va_arg(ap, signed char*);
5879  *n = result.length();
5880  break;
5881  }
5882  case lm_h: {
5883  short int *n = va_arg(ap, short int*);
5884  *n = result.length();
5885  break;
5886  }
5887  case lm_l: {
5888  long int *n = va_arg(ap, long int*);
5889  *n = result.length();
5890  break;
5891  }
5892  case lm_ll: {
5893  qint64 *n = va_arg(ap, qint64*);
5894  volatile uint tmp = result.length(); // egcs-2.91.66 gets internal
5895  *n = tmp; // compiler error without volatile
5896  break;
5897  }
5898  default: {
5899  int *n = va_arg(ap, int*);
5900  *n = result.length();
5901  break;
5902  }
5903  }
5904  ++c;
5905  break;
5906 
5907  default: // bad escape, treat as non-escape text
5908  for (const char *cc = escape_start; cc != c; ++cc)
5909  result.append(QLatin1Char(*cc));
5910  continue;
5911  }
5912 
5913  if (flags & QLocalePrivate::LeftAdjusted)
5914  result.append(subst.leftJustified(width));
5915  else
5916  result.append(subst.rightJustified(width));
5917  }
5918 
5919  *this = result;
5920 
5921  return *this;
5922 }
unsigned char c[8]
Definition: qnumeric_p.h:62
int toInt(bool *ok=0, int base=10) const
Returns the string converted to an int using base base, which is 10 by default and must be between 2 ...
Definition: qstring.cpp:6090
QString leftJustified(int width, QChar fill=QLatin1Char(' '), bool trunc=false) const Q_REQUIRED_RESULT
Returns a string of size width that contains this string padded by the fill character.
Definition: qstring.cpp:5318
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
quint16 u
The QString class provides a Unicode character string.
Definition: qstring.h:83
bool qIsDigit(char ch)
Definition: qstring.cpp:367
static const uint base
Definition: qurl.cpp:268
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
unsigned char uchar
Definition: qglobal.h:994
QString rightJustified(int width, QChar fill=QLatin1Char(' '), bool trunc=false) const Q_REQUIRED_RESULT
Returns a string of size() width that contains the fill character followed by the string...
Definition: qstring.cpp:5357
void truncate(int pos)
Truncates the string at the given position index.
Definition: qstring.cpp:4603
unsigned __int64 quint64
Definition: qglobal.h:943
static QString fromUtf8(const char *, int size=-1)
Returns a QString initialized with the first size bytes of the UTF-8 string str.
Definition: qstring.cpp:4302
unsigned int uint
Definition: qglobal.h:996
__int64 qint64
Definition: qglobal.h:942
unsigned long ulong
Definition: qglobal.h:997
Data * d
Definition: qstring.h:618
QString toUnicode(const QByteArray &) const
Converts a from the encoding of this codec to Unicode, and returns the result in a QString...
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
Definition: qstring.cpp:7186
QString & append(QChar c)
Definition: qstring.cpp:1777
unsigned short ushort
Definition: qglobal.h:995
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188
static QTextCodec * codecForCStrings
Definition: qstring.h:621
bool qIsUpper(char ch)
Definition: qstring.cpp:362
QString & setUtf16(const ushort *utf16, int size)
Resizes the string to size characters and copies unicode into the string.
Definition: qstring.h:882
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
char qToLower(char ch)
Definition: qstring.cpp:372

Friends and Related Functions

◆ operator!=()

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

Returns true if s1 is not equal to s2; otherwise returns false.

For s1 != 0, this is equivalent to {compare(} s1, s2 {) != 0}. Note that no string is equal to s1 being 0.

See also
QString::compare()

Definition at line 938 of file qstring.h.

939 { return !qStringComparisonHelper(s2, s1); }
friend bool qStringComparisonHelper(const QString &s1, const char *s2)
Definition: qstring.h:916

◆ operator+() [1/5]

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

Returns a string which is the result of concatenating s1 and s2.

Definition at line 1021 of file qstring.h.

1022 { QString t(s1); t += s2; return t; }
The QString class provides a Unicode character string.
Definition: qstring.h:83

◆ operator+() [2/5]

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

Returns a string which is the result of concatenating s1 and s2 (s2 is converted to Unicode using the QString::fromAscii() function).

See also
QString::fromAscii()

Definition at line 1028 of file qstring.h.

1029 { QString t(s1); t += QString::fromAscii(s2); return t; }
static QString fromAscii(const char *, int size=-1)
Returns a QString initialized with the first size characters from the string str. ...
Definition: qstring.cpp:4276
The QString class provides a Unicode character string.
Definition: qstring.h:83

◆ operator+() [3/5]

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

Returns a string which is the result of concatenating s1 and s2 (s1 is converted to Unicode using the QString::fromAscii() function).

See also
QString::fromAscii()

Definition at line 1030 of file qstring.h.

1031 { QString t = QString::fromAscii(s1); t += s2; return t; }
static QString fromAscii(const char *, int size=-1)
Returns a QString initialized with the first size characters from the string str. ...
Definition: qstring.cpp:4276
The QString class provides a Unicode character string.
Definition: qstring.h:83

◆ operator+() [4/5]

const QString operator+ ( const QString s,
char  ch 
)
related

Returns a string which is the result of concatenating the string s and the character ch.

Definition at line 1034 of file qstring.h.

1035 { QString t = s; t += QChar::fromAscii(c); return t; }
unsigned char c[8]
Definition: qnumeric_p.h:62
The QString class provides a Unicode character string.
Definition: qstring.h:83
static QChar fromAscii(char c)
Converts the ASCII character c to its equivalent QChar.
Definition: qchar.cpp:1521

◆ operator+() [5/5]

const QString operator+ ( char  ch,
const QString s 
)
related

Returns a string which is the result of concatenating the character ch and the string s.

Definition at line 1032 of file qstring.h.

1033 { QString t = s; t.prepend(QChar::fromAscii(c)); return t; }
unsigned char c[8]
Definition: qnumeric_p.h:62
QString & prepend(QChar c)
Definition: qstring.h:261
The QString class provides a Unicode character string.
Definition: qstring.h:83
static QChar fromAscii(char c)
Converts the ASCII character c to its equivalent QChar.
Definition: qchar.cpp:1521

◆ operator<()

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

Returns true if s1 is lexically less than s2; otherwise returns false. For s1 != 0, this is equivalent to {compare(s1, s2) < 0}.

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 using the QString::localeAwareCompare() function.

See also
QString::compare()

Definition at line 940 of file qstring.h.

941 { return (QString::fromAscii(s1) < s2); }
static QString fromAscii(const char *, int size=-1)
Returns a QString initialized with the first size characters from the string str. ...
Definition: qstring.cpp:4276

◆ operator<<()

QDataStream & operator<< ( QDataStream stream,
const QString string 
)
related

Writes the given string to the specified stream.

See also
{Serializing Qt Data Types}

Definition at line 8034 of file qstring.cpp.

Referenced by fromStdWString().

8035 {
8036  if (out.version() == 1) {
8037  out << str.toLatin1();
8038  } else {
8039  if (!str.isNull() || out.version() < 3) {
8040  if ((out.byteOrder() == QDataStream::BigEndian) == (QSysInfo::ByteOrder == QSysInfo::BigEndian)) {
8041  out.writeBytes(reinterpret_cast<const char *>(str.unicode()), sizeof(QChar) * str.length());
8042  } else {
8043  QVarLengthArray<ushort> buffer(str.length());
8044  const ushort *data = reinterpret_cast<const ushort *>(str.constData());
8045  for (int i = 0; i < str.length(); i++) {
8046  buffer[i] = qbswap(*data);
8047  ++data;
8048  }
8049  out.writeBytes(reinterpret_cast<const char *>(buffer.data()), sizeof(ushort) * buffer.size());
8050  }
8051  } else {
8052  // write null marker
8053  out << (quint32)0xffffffff;
8054  }
8055  }
8056  return out;
8057 }
void qbswap(const T src, uchar *dest)
Definition: qendian.h:74
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
QChar * data()
Returns a pointer to the data stored in the QString.
Definition: qstring.h:710
unsigned short ushort
Definition: qglobal.h:995
unsigned int quint32
Definition: qglobal.h:938

◆ operator<=()

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

Returns true if s1 is lexically less than or equal to s2; otherwise returns false. For s1 != 0, this is equivalent to {compare(s1, s2) <= 0}.

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().

See also
QString::compare()

Definition at line 944 of file qstring.h.

945 { return (QString::fromAscii(s1) <= s2); }
static QString fromAscii(const char *, int size=-1)
Returns a QString initialized with the first size characters from the string str. ...
Definition: qstring.cpp:4276

◆ operator==operator==()

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

Returns true if s1 is equal to s2; otherwise returns false. Note that no string is equal to s1 being 0.

Equivalent to {s1 != 0 && compare(s1, s2) == 0}.

See also
QString::compare()

◆ operator>()

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

Returns true if s1 is lexically greater than s2; otherwise returns false. Equivalent to {compare(s1, s2) > 0}.

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 using the QString::localeAwareCompare() function.

See also
QString::compare()

Definition at line 942 of file qstring.h.

943 { return (QString::fromAscii(s1) > s2); }
static QString fromAscii(const char *, int size=-1)
Returns a QString initialized with the first size characters from the string str. ...
Definition: qstring.cpp:4276

◆ operator>=()

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

Returns true if s1 is lexically greater than or equal to s2; otherwise returns false. For s1 != 0, this is equivalent to {compare(s1, s2) >= 0}.

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 using the QString::localeAwareCompare() function.

Definition at line 946 of file qstring.h.

947 { return (QString::fromAscii(s1) >= s2); }
static QString fromAscii(const char *, int size=-1)
Returns a QString initialized with the first size characters from the string str. ...
Definition: qstring.cpp:4276

◆ operator>>()

QDataStream & operator>> ( QDataStream stream,
QString string 
)
related

Reads a string from the specified stream into the given string.

See also
{Serializing Qt Data Types}

Definition at line 8071 of file qstring.cpp.

Referenced by fromStdWString().

8072 {
8073 #ifdef QT_QSTRING_UCS_4
8074 #if defined(Q_CC_GNU)
8075 #warning "operator>> not working properly"
8076 #endif
8077 #endif
8078 
8079  if (in.version() == 1) {
8080  QByteArray l;
8081  in >> l;
8082  str = QString::fromLatin1(l);
8083  } else {
8084  quint32 bytes = 0;
8085  in >> bytes; // read size of string
8086  if (bytes == 0xffffffff) { // null string
8087  str.clear();
8088  } else if (bytes > 0) { // not empty
8089  if (bytes & 0x1) {
8090  str.clear();
8091  in.setStatus(QDataStream::ReadCorruptData);
8092  return in;
8093  }
8094 
8095  const quint32 Step = 1024 * 1024;
8096  quint32 len = bytes / 2;
8097  quint32 allocated = 0;
8098 
8099  while (allocated < len) {
8100  int blockSize = qMin(Step, len - allocated);
8101  str.resize(allocated + blockSize);
8102  if (in.readRawData(reinterpret_cast<char *>(str.data()) + allocated * 2,
8103  blockSize * 2) != blockSize * 2) {
8104  str.clear();
8105  in.setStatus(QDataStream::ReadPastEnd);
8106  return in;
8107  }
8108  allocated += blockSize;
8109  }
8110 
8111  if ((in.byteOrder() == QDataStream::BigEndian)
8112  != (QSysInfo::ByteOrder == QSysInfo::BigEndian)) {
8113  ushort *data = reinterpret_cast<ushort *>(str.data());
8114  while (len--) {
8115  *data = qbswap(*data);
8116  ++data;
8117  }
8118  }
8119  } else {
8120  str = QLatin1String("");
8121  }
8122  }
8123  return in;
8124 }
const int blockSize
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
void qbswap(const T src, uchar *dest)
Definition: qendian.h:74
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
QChar * data()
Returns a pointer to the data stored in the QString.
Definition: qstring.h:710
unsigned short ushort
Definition: qglobal.h:995
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188
unsigned int quint32
Definition: qglobal.h:938
QFactoryLoader * l

◆ QAbstractConcatenable

friend struct QAbstractConcatenable
friend

Definition at line 645 of file qstring.h.

◆ QCFString

friend class QCFString
friend

Definition at line 642 of file qstring.h.

◆ QCharRef

friend class QCharRef
friend

Definition at line 641 of file qstring.h.

Referenced by operator[]().

◆ qStringComparisonHelper [1/2]

bool qStringComparisonHelper ( const QString s1,
const char *  s2 
)
friend

Definition at line 916 of file qstring.h.

Referenced by QByteArray::operator!=(), operator!=(), operator!=(), QByteArray::operator==(), operator==(), and operator==().

917 {
918 # ifndef QT_NO_TEXTCODEC
919  if (QString::codecForCStrings) return (s1 == QString::fromAscii(s2));
920 # endif
921  return (s1 == QLatin1String(s2));
922 }
static QString fromAscii(const char *, int size=-1)
Returns a QString initialized with the first size characters from the string str. ...
Definition: qstring.cpp:4276
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
static QTextCodec * codecForCStrings
Definition: qstring.h:621

◆ qStringComparisonHelper [2/2]

bool qStringComparisonHelper ( const QStringRef s1,
const char *  s2 
)
friend

Definition at line 1228 of file qstring.h.

1229 {
1230 # ifndef QT_NO_TEXTCODEC
1231  if (QString::codecForCStrings) return (s1 == QString::fromAscii(s2));
1232 # endif
1233  return (s1 == QLatin1String(s2));
1234 }
static QString fromAscii(const char *, int size=-1)
Returns a QString initialized with the first size characters from the string str. ...
Definition: qstring.cpp:4276
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
static QTextCodec * codecForCStrings
Definition: qstring.h:621

◆ QStringRef

friend class QStringRef
friend

Definition at line 644 of file qstring.h.

Referenced by QStringRef::appendTo(), leftRef(), midRef(), QStringRef::QStringRef(), and rightRef().

◆ QTextCodec

friend class QTextCodec
friend

Definition at line 643 of file qstring.h.

Properties

◆ codecForCStrings

QTextCodec * QString::codecForCStrings
staticprivate

◆ d

Data* QString::d
private

◆ null

const QString::Null QString::null = { }
static

◆ shared_empty

QString::Data QString::shared_empty
staticprivate
Initial value:
0, 0, shared_empty.array, 0, 0, 0, 0, 0, 0, {0} }

Definition at line 617 of file qstring.h.

Referenced by fromAscii_helper(), fromLatin1_helper(), QString(), qToLower(), resize(), simplified(), and trimmed().

◆ shared_null

QString::Data QString::shared_null
staticprivate
Initial value:
0, 0, shared_null.array, 0, 0, 0, 0, 0, 0, {0} }

Definition at line 616 of file qstring.h.

Referenced by append(), fromAscii_helper(), fromLatin1_helper(), mid(), midRef(), QString(), qToLower(), and QStringRef::unicode().


The documentation for this class was generated from the following files: