Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
QString Class Reference

\macro QT_RESTRICTED_CAST_FROM_ASCII More...

#include <qstring.h>

+ Inheritance diagram for QString:
+ Collaboration diagram for QString:

Public Types

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  NormalizationForm { NormalizationForm_D , NormalizationForm_C , NormalizationForm_KD , NormalizationForm_KC }
 This enum describes the various normalized forms of Unicode text. More...
 
typedef QStringPrivate DataPointer
 
typedef QChariterator
 
typedef const QCharconst_iterator
 
typedef iterator Iterator
 Qt-style synonym for QString::iterator.
 
typedef const_iterator ConstIterator
 Qt-style synonym for QString::const_iterator.
 
typedef std::reverse_iterator< iteratorreverse_iterator
 
typedef std::reverse_iterator< const_iteratorconst_reverse_iterator
 
typedef qsizetype size_type
 
typedef qptrdiff difference_type
 
typedef const QCharconst_reference
 
typedef QCharreference
 
typedef QCharpointer
 The QString::pointer typedef provides an STL-style pointer to a QString element (QChar).
 
typedef const QCharconst_pointer
 The QString::const_pointer typedef provides an STL-style const pointer to a QString element (QChar).
 
typedef QChar value_type
 

Public Member Functions

constexpr QString () noexcept
 Constructs a null string.
 
 QString (const QChar *unicode, qsizetype size=-1)
 Constructs a string initialized with the first size characters of the QChar array unicode.
 
 QString (QChar c)
 Constructs a string of size 1 containing the character ch.
 
 QString (qsizetype size, QChar c)
 Constructs a string of the given size with every character set to ch.
 
 QString (QLatin1StringView latin1)
 Constructs a copy of the Latin-1 string viewed by str.
 
 QString (QStringView sv)
 
 QString (const QString &) noexcept
 Constructs a copy of other.
 
 ~QString ()
 Destroys the string.
 
QStringoperator= (QChar c)
 
QStringoperator= (const QString &) noexcept
 Assigns other to this string and returns a reference to this string.
 
QStringoperator= (QLatin1StringView latin1)
 
 QString (QString &&other) noexcept=default
 Move-constructs a QString instance, making it point at the same object that other was pointing to.
 
void swap (QString &other) noexcept
 
qsizetype size () const noexcept
 Returns the number of characters in this string.
 
qsizetype length () const noexcept
 Returns the number of characters in this string.
 
bool isEmpty () const noexcept
 Returns true if the string has no characters; otherwise returns false.
 
void resize (qsizetype size)
 Sets the size of the string to size characters.
 
void resize (qsizetype size, QChar fillChar)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
void resizeForOverwrite (qsizetype size)
 
QStringfill (QChar c, qsizetype size=-1)
 Sets every character in the string to character ch.
 
void truncate (qsizetype pos)
 Truncates the string at the given position index.
 
void chop (qsizetype n)
 Removes n characters from the end of the string.
 
QStringslice (qsizetype pos)
 
QStringslice (qsizetype pos, qsizetype n)
 
qsizetype capacity () const
 Returns the maximum number of characters that can be stored in the string without forcing a reallocation.
 
void reserve (qsizetype size)
 Ensures the string has space for at least size characters.
 
void squeeze ()
 Releases any memory not required to store the character data.
 
const QCharunicode () const
 Returns a Unicode representation of the string.
 
QChardata ()
 Returns a pointer to the data stored in the QString.
 
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.
 
const QCharconstData () const
 Returns a pointer to the data stored in the QString.
 
void detach ()
 
bool isDetached () const
 
bool isSharedWith (const QString &other) const
 
void clear ()
 Clears the contents of the string and makes it null.
 
const QChar at (qsizetype i) const
 Returns the character at the given index position in the string.
 
const QChar operator[] (qsizetype i) const
 
QCharoperator[] (qsizetype i)
 Returns the character at the specified position in the string as a modifiable reference.
 
QChar front () const
 
QCharfront ()
 
QChar back () const
 
QCharback ()
 
QString arg (qlonglong a, int fieldwidth=0, int base=10, QChar fillChar=u' ') const
 
QString arg (qulonglong a, int fieldwidth=0, int base=10, QChar fillChar=u' ') const
 
QString arg (long a, int fieldwidth=0, int base=10, QChar fillChar=u' ') const
 
QString arg (ulong a, int fieldwidth=0, int base=10, QChar fillChar=u' ') const
 
QString arg (int a, int fieldWidth=0, int base=10, QChar fillChar=u' ') const
 
QString arg (uint a, int fieldWidth=0, int base=10, QChar fillChar=u' ') const
 
QString arg (short a, int fieldWidth=0, int base=10, QChar fillChar=u' ') const
 fieldWidth specifies the minimum amount of space that a is padded to and filled with the character fillChar.
 
QString arg (ushort a, int fieldWidth=0, int base=10, QChar fillChar=u' ') const
 
QString arg (double a, int fieldWidth=0, char format='g', int precision=-1, QChar fillChar=u' ') const
 
QString arg (char a, int fieldWidth=0, QChar fillChar=u' ') const
 
QString arg (QChar a, int fieldWidth=0, QChar fillChar=u' ') const
 
QString arg (const QString &a, int fieldWidth=0, QChar fillChar=u' ') const
 Returns a copy of this string with the lowest numbered place marker replaced by string a, i.e., %1, %2, ..., %99.
 
QString arg (QStringView a, int fieldWidth=0, QChar fillChar=u' ') const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
QString arg (QLatin1StringView a, int fieldWidth=0, QChar fillChar=u' ') const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
template<typename... Args>
std::enable_if< sizeof...(Args)>=2 &&std::is_same< QtPrivate::BoolList< is_convertible_to_view_or_qstring< Args >::value..., true >, QtPrivate::BoolList< true, is_convertible_to_view_or_qstring< Args >::value... > >::value, QString >::type arg (Args &&...args) const
 
static QString static QString QT_CORE_INLINE_SINCE (6, 7) qsizetype indexOf(QChar c
 
qsizetype indexOf (QLatin1StringView s, qsizetype from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
 
qsizetype indexOf (const QString &s, qsizetype from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
 
qsizetype indexOf (QStringView s, qsizetype from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
 
qsizetype lastIndexOf (QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
 
 QT_CORE_INLINE_SINCE (6, 7) qsizetype lastIndexOf(QChar c
 
qsizetype lastIndexOf (QLatin1StringView s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
 
qsizetype lastIndexOf (QLatin1StringView s, qsizetype from, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
 
qsizetype lastIndexOf (const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
 
qsizetype lastIndexOf (const QString &s, qsizetype from, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
 
qsizetype lastIndexOf (QStringView s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
 
qsizetype lastIndexOf (QStringView s, qsizetype from, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
 
bool contains (QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
 
bool 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.
 
bool contains (QLatin1StringView s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
 
bool contains (QStringView s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
 
qsizetype count (QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
 
qsizetype count (const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
 Returns the number of (potentially overlapping) occurrences of the string str in this string.
 
qsizetype count (QStringView s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
 
QString section (QChar sep, qsizetype start, qsizetype end=-1, SectionFlags flags=SectionDefault) const
 This function returns a section of the string.
 
QString section (const QString &in_sep, qsizetype start, qsizetype end=-1, SectionFlags flags=SectionDefault) const
 
QString left (qsizetype n) const &
 
QString left (qsizetype n) &&
 
QString right (qsizetype n) const &
 
QString right (qsizetype n) &&
 
QString mid (qsizetype position, qsizetype n=-1) const &
 
QString mid (qsizetype position, qsizetype n=-1) &&
 
QString first (qsizetype n) const &
 
QString last (qsizetype n) const &
 
QString sliced (qsizetype pos) const &
 
QString sliced (qsizetype pos, qsizetype n) const &
 
QString chopped (qsizetype n) const &
 
QString first (qsizetype n) &&
 
QString last (qsizetype n) &&
 
QString sliced (qsizetype pos) &&
 
QString sliced (qsizetype pos, qsizetype n) &&
 
QString chopped (qsizetype n) &&
 
bool startsWith (const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
 Returns true if the string starts with s; otherwise returns false.
 
bool startsWith (QStringView s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
 
bool startsWith (QLatin1StringView s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
 
bool startsWith (QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
 
bool endsWith (const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
 Returns true if the string ends with s; otherwise returns false.
 
bool endsWith (QStringView s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
 
bool endsWith (QLatin1StringView s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
 
bool endsWith (QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
 
bool isUpper () const
 Returns true if the string is uppercase, that is, it's identical to its toUpper() folding.
 
bool isLower () const
 Returns true if the string is lowercase, that is, it's identical to its toLower() folding.
 
QString leftJustified (qsizetype width, QChar fill=u' ', bool trunc=false) const
 Returns a string of size width that contains this string padded by the fill character.
 
QString rightJustified (qsizetype width, QChar fill=u' ', bool trunc=false) const
 Returns a string of size() width that contains the fill character followed by the string.
 
QString toLower () const &
 
QString toLower () &&
 
QString toUpper () const &
 
QString toUpper () &&
 
QString toCaseFolded () const &
 
QString toCaseFolded () &&
 
QString trimmed () const &
 
QString trimmed () &&
 
QString simplified () const &
 
QString simplified () &&
 
QString toHtmlEscaped () const
 
QStringinsert (qsizetype i, QChar c)
 
QStringinsert (qsizetype i, const QChar *uc, qsizetype len)
 
QStringinsert (qsizetype i, const QString &s)
 
QStringinsert (qsizetype i, QStringView v)
 
QStringinsert (qsizetype i, QLatin1StringView s)
 
QStringinsert (qsizetype i, QUtf8StringView s)
 
QStringappend (QChar c)
 
QStringappend (const QChar *uc, qsizetype len)
 
QStringappend (const QString &s)
 Appends the string str onto the end of this string.
 
QStringappend (QStringView v)
 
QStringappend (QLatin1StringView s)
 
QStringappend (QUtf8StringView s)
 
QStringprepend (QChar c)
 
QStringprepend (const QChar *uc, qsizetype len)
 
QStringprepend (const QString &s)
 Prepends the string str to the beginning of this string and returns a reference to this string.
 
QStringprepend (QStringView v)
 
QStringprepend (QLatin1StringView s)
 
QStringprepend (QUtf8StringView s)
 
QStringassign (QAnyStringView s)
 
QStringassign (qsizetype n, QChar c)
 
template<typename InputIterator , if_compatible_iterator< InputIterator > = true>
QStringassign (InputIterator first, InputIterator last)
 
QStringoperator+= (QChar c)
 
QStringoperator+= (const QString &s)
 Appends the string other onto the end of this string and returns a reference to this string.
 
QStringoperator+= (QStringView v)
 
QStringoperator+= (QLatin1StringView s)
 
QStringoperator+= (QUtf8StringView s)
 
QStringremove (qsizetype i, qsizetype len)
 Removes n characters from the string, starting at the given position index, and returns a reference to the string.
 
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.
 
QStringremove (QLatin1StringView s, Qt::CaseSensitivity cs=Qt::CaseSensitive)
 
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.
 
QStringremoveAt (qsizetype pos)
 
QStringremoveFirst ()
 
QStringremoveLast ()
 
template<typename Predicate >
QStringremoveIf (Predicate pred)
 
QStringreplace (qsizetype i, qsizetype len, QChar after)
 
QStringreplace (qsizetype i, qsizetype len, const QChar *s, qsizetype slen)
 
QStringreplace (qsizetype i, qsizetype len, const QString &after)
 Replaces n characters beginning at index position with the string after and returns a reference to this string.
 
QStringreplace (QChar before, QChar after, Qt::CaseSensitivity cs=Qt::CaseSensitive)
 
QStringreplace (const QChar *before, qsizetype blen, const QChar *after, qsizetype alen, Qt::CaseSensitivity cs=Qt::CaseSensitive)
 
QStringreplace (QLatin1StringView before, QLatin1StringView after, Qt::CaseSensitivity cs=Qt::CaseSensitive)
 
QStringreplace (QLatin1StringView before, const QString &after, Qt::CaseSensitivity cs=Qt::CaseSensitive)
 
QStringreplace (const QString &before, QLatin1StringView 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, QLatin1StringView after, Qt::CaseSensitivity cs=Qt::CaseSensitive)
 
QStringList split (const QString &sep, Qt::SplitBehavior behavior=Qt::KeepEmptyParts, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
 Splits the string into substrings wherever sep occurs, and returns the list of those strings.
 
QStringList split (QChar sep, Qt::SplitBehavior behavior=Qt::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.
 
QStringList split (const QRegularExpression &sep, Qt::SplitBehavior behavior=Qt::KeepEmptyParts) const
 
template<typename Needle , typename... Flags>
auto tokenize (Needle &&needle, Flags...flags) const &noexcept(noexcept(qTokenize(std::declval< const QString & >(), std::forward< Needle >(needle), flags...))) -> decltype(qTokenize(*this, std::forward< Needle >(needle), flags...))
 
template<typename Needle , typename... Flags>
auto tokenize (Needle &&needle, Flags...flags) const &&noexcept(noexcept(qTokenize(std::declval< const QString >(), std::forward< Needle >(needle), flags...))) -> decltype(qTokenize(std::move(*this), std::forward< Needle >(needle), flags...))
 
template<typename Needle , typename... Flags>
auto tokenize (Needle &&needle, Flags...flags) &&noexcept(noexcept(qTokenize(std::declval< QString >(), std::forward< Needle >(needle), flags...))) -> decltype(qTokenize(std::move(*this), std::forward< Needle >(needle), flags...))
 
QString normalized (NormalizationForm mode, QChar::UnicodeVersion version=QChar::Unicode_Unassigned) const
 Returns the string in the given Unicode normalization mode, according to the given version of the Unicode standard.
 
QString repeated (qsizetype times) const
 
const ushortutf16 () const
 Returns the QString as a '\0\'-terminated array of unsigned shorts.
 
QByteArray toLatin1 () const &
 
QByteArray toLatin1 () &&
 
QByteArray toUtf8 () const &
 
QByteArray toUtf8 () &&
 
QByteArray toLocal8Bit () const &
 
QByteArray toLocal8Bit () &&
 
QList< uinttoUcs4 () const
 
qsizetype toWCharArray (wchar_t *array) const
 
QStringsetRawData (const QChar *unicode, qsizetype size)
 
QStringsetUnicode (const QChar *unicode, qsizetype size)
 Resizes the string to size characters and copies unicode into the string.
 
QStringsetUtf16 (const ushort *utf16, qsizetype size)
 Resizes the string to size characters and copies unicode into the string.
 
int compare (const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
 
int compare (QLatin1StringView other, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
 
int compare (QStringView s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
 
int compare (QChar ch, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
 
int localeAwareCompare (const QString &s) const
 
int localeAwareCompare (QStringView s) const
 
short toShort (bool *ok=nullptr, 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.
 
ushort toUShort (bool *ok=nullptr, 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.
 
int toInt (bool *ok=nullptr, 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.
 
uint toUInt (bool *ok=nullptr, 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.
 
long toLong (bool *ok=nullptr, 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.
 
ulong toULong (bool *ok=nullptr, 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.
 
qlonglong toLongLong (bool *ok=nullptr, 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.
 
qulonglong toULongLong (bool *ok=nullptr, 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.
 
float toFloat (bool *ok=nullptr) const
 Returns the string converted to a float value.
 
double toDouble (bool *ok=nullptr) const
 Returns the string converted to a double value.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
QStringsetNum (float, char format='g', int precision=6)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Sets the string to the printed value of n, formatted according to the given format and precision, and returns a reference to the string.
 
QStringsetNum (double, char format='g', int precision=6)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Sets the string to the printed value of n, formatted according to the given format and precision, and returns a reference to the string.
 
QT_ASCII_CAST_WARN QString (const char *ch)
 Constructs a string initialized with the 8-bit string str.
 
QT_ASCII_CAST_WARN QString (const QByteArray &a)
 Constructs a string initialized with the byte array ba.
 
QT_ASCII_CAST_WARN QStringoperator= (const char *ch)
 
QT_ASCII_CAST_WARN QStringoperator= (const QByteArray &a)
 
QT_ASCII_CAST_WARN QStringprepend (const char *s)
 
QT_ASCII_CAST_WARN QStringprepend (const QByteArray &s)
 
QT_ASCII_CAST_WARN QStringappend (const char *s)
 
QT_ASCII_CAST_WARN QStringappend (const QByteArray &s)
 
QT_ASCII_CAST_WARN QStringinsert (qsizetype i, const char *s)
 
QT_ASCII_CAST_WARN QStringinsert (qsizetype i, const QByteArray &s)
 
QT_ASCII_CAST_WARN QStringoperator+= (const char *s)
 
QT_ASCII_CAST_WARN QStringoperator+= (const QByteArray &s)
 
iterator begin ()
 Returns an \l{STL-style iterators}{STL-style iterator} pointing to the first character in the string.
 
const_iterator begin () const
 
const_iterator cbegin () const
 
const_iterator constBegin () const
 Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the first character in the string.
 
iterator end ()
 Returns an \l{STL-style iterators}{STL-style iterator} pointing just after the last character in the string.
 
const_iterator end () const
 
const_iterator cend () const
 
const_iterator constEnd () const
 Returns a const \l{STL-style iterators}{STL-style iterator} pointing just after the last character in the string.
 
reverse_iterator rbegin ()
 
reverse_iterator rend ()
 
const_reverse_iterator rbegin () const
 
const_reverse_iterator rend () const
 
const_reverse_iterator crbegin () const
 
const_reverse_iterator crend () const
 
void push_back (QChar c)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Appends the given ch character onto the end of this string.
 
void push_back (const QString &s)
 This function is provided for STL compatibility, appending the given other string onto the end of this string.
 
void push_front (QChar c)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Prepends the given ch character to the beginning of this string.
 
void push_front (const QString &s)
 This function is provided for STL compatibility, prepending the given other string to the beginning of this string.
 
void shrink_to_fit ()
 
iterator erase (const_iterator first, const_iterator last)
 
iterator erase (const_iterator it)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
std::string toStdString () const
 Returns a std::string object with the data contained in this QString.
 
std::wstring toStdWString () const
 Returns a std::wstring object with the data contained in this QString.
 
std::u16string toStdU16String () const
 
std::u32string toStdU32String () const
 
Q_IMPLICIT operator std::u16string_view () const noexcept
 
bool isNull () const
 Returns true if this string is null; otherwise returns false.
 
bool isRightToLeft () const
 Returns true if the string is read right to left.
 
bool isValidUtf16 () const noexcept
 
 QString (qsizetype size, Qt::Initialization)
 
 QString (DataPointer &&dd)
 
DataPointerdata_ptr ()
 
const DataPointerdata_ptr () const
 

Static Public Member Functions

static QString vasprintf (const char *format, va_list ap) Q_ATTRIBUTE_FORMAT_PRINTF(1
 
static QString static QString asprintf (const char *format,...) Q_ATTRIBUTE_FORMAT_PRINTF(1
 
static QString fromLatin1 (QByteArrayView ba)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
static Q_WEAK_OVERLOAD QString fromLatin1 (const QByteArray &ba)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
static QString fromLatin1 (const char *str, qsizetype size)
 Returns a QString initialized with the first size characters of the Latin-1 string str.
 
static QString fromUtf8 (QByteArrayView utf8)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
static Q_WEAK_OVERLOAD QString fromUtf8 (const QByteArray &ba)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
static QString fromUtf8 (const char *utf8, qsizetype size)
 Returns a QString initialized with the first size bytes of the UTF-8 string str.
 
static QString fromLocal8Bit (QByteArrayView ba)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
static Q_WEAK_OVERLOAD QString fromLocal8Bit (const QByteArray &ba)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
static QString fromLocal8Bit (const char *str, qsizetype size)
 Returns a QString initialized with the first size characters of the 8-bit string str.
 
static QString fromUtf16 (const char16_t *, qsizetype size=-1)
 
static QString fromUcs4 (const char32_t *, qsizetype size=-1)
 
static QString fromRawData (const QChar *, qsizetype size)
 Constructs a QString that uses the first size Unicode characters in the array unicode.
 
static QString fromWCharArray (const wchar_t *string, qsizetype size=-1)
 
static int compare (const QString &s1, const QString &s2, Qt::CaseSensitivity cs=Qt::CaseSensitive) noexcept
 
static int compare (const QString &s1, QLatin1StringView s2, Qt::CaseSensitivity cs=Qt::CaseSensitive) noexcept
 
static int compare (QLatin1StringView s1, const QString &s2, Qt::CaseSensitivity cs=Qt::CaseSensitive) noexcept
 
static int compare (const QString &s1, QStringView s2, Qt::CaseSensitivity cs=Qt::CaseSensitive) noexcept
 
static int compare (QStringView s1, const QString &s2, Qt::CaseSensitivity cs=Qt::CaseSensitive) noexcept
 
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.
 
static int localeAwareCompare (QStringView s1, QStringView 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.
 
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.
 
static QString number (long, int base=10)
 Returns a string equivalent of the number n according to the specified base.
 
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.
 
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.
 
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.
 
static QString number (double, char format='g', int precision=6)
 Returns a string representing the floating-point number n.
 
static constexpr qsizetype max_size () noexcept
 
static QString fromStdString (const std::string &s)
 
static QString fromStdWString (const std::wstring &s)
 Returns a copy of the str string.
 
static QString fromStdU16String (const std::u16string &s)
 
static QString fromStdU32String (const std::u32string &s)
 

Public Attributes

static QString static QString qsizetype from = 0
 
static QString static QString qsizetype Qt::CaseSensitivity cs = Qt::CaseSensitive) const
 
qsizetype from
 
qsizetype Qt::CaseSensitivity cs = Qt::CaseSensitive) const
 

Friends

class ::tst_QString
 
class QStringView
 
class QByteArray
 
struct QAbstractConcatenable
 
bool comparesEqual (const QString &s1, const QString &s2) noexcept
 
Qt::strong_ordering compareThreeWay (const QString &s1, const QString &s2) noexcept
 
Q_WEAK_OVERLOAD friend bool comparesEqual (const QString &s1, QUtf8StringView s2) noexcept
 
Q_WEAK_OVERLOAD friend Qt::strong_ordering compareThreeWay (const QString &s1, QUtf8StringView s2) noexcept
 
bool comparesEqual (const QString &s1, QLatin1StringView s2) noexcept
 
Qt::strong_ordering compareThreeWay (const QString &s1, QLatin1StringView s2) noexcept
 
bool comparesEqual (const QString &s1, std::nullptr_t) noexcept
 
Qt::strong_ordering compareThreeWay (const QString &s1, std::nullptr_t) noexcept
 
bool comparesEqual (const QString &s1, const char16_t *s2) noexcept
 
Qt::strong_ordering compareThreeWay (const QString &s1, const char16_t *s2) noexcept
 
bool comparesEqual (const QString &lhs, QChar rhs) noexcept
 
Qt::strong_ordering compareThreeWay (const QString &lhs, QChar rhs) noexcept
 
bool comparesEqual (const QString &lhs, QByteArrayView rhs) noexcept
 
Qt::strong_ordering compareThreeWay (const QString &lhs, QByteArrayView rhs) noexcept
 
bool comparesEqual (const QString &lhs, const QByteArray &rhs) noexcept
 
Qt::strong_ordering compareThreeWay (const QString &lhs, const QByteArray &rhs) noexcept
 
bool comparesEqual (const QString &lhs, const char *rhs) noexcept
 
Qt::strong_ordering compareThreeWay (const QString &lhs, const char *rhs) noexcept
 
template<typename T >
qsizetype erase (QString &s, const T &t)
 
template<typename Predicate >
qsizetype erase_if (QString &s, Predicate pred)
 

Related Symbols

(Note that these are not member symbols.)

QString operator+ (QString &&s1, const QString &s2)
 Returns a string which is the result of concatenating s1 and s2.
 
QString operator+ (const QString &s1, const char *s2)
 Returns a string which is the result of concatenating s1 and s2 (s2 is converted to Unicode using the QString::fromUtf8() function).
 
QString operator+ (const char *s1, const QString &s2)
 Returns a string which is the result of concatenating s1 and s2 (s1 is converted to Unicode using the QString::fromUtf8() function).
 
QDataStreamoperator<< (QDataStream &stream, const QString &string)
 Writes the given string to the specified stream.
 
QDataStreamoperator>> (QDataStream &stream, QString &string)
 Reads a string from the specified stream into the given string.
 
 operator""_s (const char16_t *str, size_t size)
 \macro QStringLiteral(str)
 
template< typename T > qsizetype erase (QString &s, const T &t)
 
template< typename Predicate > qsizetype erase_if (QString &s, Predicate pred)
 

Detailed Description

\macro QT_RESTRICTED_CAST_FROM_ASCII

Disables most automatic conversions from source literals and 8-bit data to unicode QStrings, but allows the use of the {QChar(char)} and {QString(const char (&ch)[N]} constructors, and the {QString::operator=(const char (&ch)[N])} assignment operator. This gives most of the type-safety benefits of \l QT_NO_CAST_FROM_ASCII but does not require user code to wrap character and string literals with QLatin1Char, QLatin1StringView or similar.

Using this macro together with source strings outside the 7-bit range, non-literals, or literals with embedded NUL characters is undefined.

See also
QT_NO_CAST_FROM_ASCII, QT_NO_CAST_TO_ASCII

\macro QT_NO_CAST_FROM_ASCII

Disables automatic conversions from 8-bit strings ({char *}) to Unicode QStrings, as well as from 8-bit {char} types ({char} and {unsigned char}) to QChar.

See also
QT_NO_CAST_TO_ASCII, QT_RESTRICTED_CAST_FROM_ASCII, QT_NO_CAST_FROM_BYTEARRAY

\macro QT_NO_CAST_TO_ASCII

Disables automatic conversion from QString to 8-bit strings ({char *}).

See also
QT_NO_CAST_FROM_ASCII, QT_RESTRICTED_CAST_FROM_ASCII, QT_NO_CAST_FROM_BYTEARRAY

\macro QT_ASCII_CAST_WARNINGS

This macro can be defined to force a warning whenever a function is called that automatically converts between unicode and 8-bit encodings.

Note: This only works for compilers that support warnings for deprecated API.

See also
QT_NO_CAST_TO_ASCII, QT_NO_CAST_FROM_ASCII, QT_RESTRICTED_CAST_FROM_ASCII

\inmodule QtCore \reentrant

The QString class provides a Unicode character string.

\compares strong \compareswith strong QChar QLatin1StringView {const char16_t *} \ QStringView QUtf8StringView \endcompareswith \compareswith strong QByteArray QByteArrayView {const char *} When comparing with byte arrays, their content is interpreted as utf-8. \endcompareswith

QString stores a string of 16-bit \l{QChar}s, where each QChar corresponds to one UTF-16 code unit. (Unicode characters with code values above 65535 are stored using surrogate pairs, that is, two consecutive \l{QChar}s.)

\l{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 \l{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 are easy to translate if you want to expand your application's market at some point. Two prominent cases where QByteArray is appropriate are when you need to store raw binary data, and when memory conservation is critical (like in embedded systems).

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

QString converts the {const char *} data into Unicode using the fromUtf8() function.

In all of the QString functions that take {const char *} parameters, the {const char *} is interpreted as a classic C-style {'\0'}-terminated string. Except where the function's name overtly indicates some other encoding, such {const char *} parameters are assumed to be encoded in UTF-8.

You can also provide string data as an array of \l{QChar}s:

QString makes a deep copy of the QChar data, so you can modify it later without experiencing side effects. You can avoid taking a deep copy of the character data by using QStringView or 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 \l operator[](). On non-{const} strings, \l operator[]() returns a reference to a character that can be used on the left side of an assignment. For example:

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

The at() function can be faster than \l operator[]() because it never causes a \l{deep copy} to occur. Alternatively, use the first(), last(), or sliced() 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:

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 \l qPrintable() macro, which returns the given QString as a {const char *}. This is equivalent to calling <QString>.toLocal8Bit().constData().

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"

In the above example, the replace() function's first two arguments are the position from which to start replacing and the number of characters that should be replaced.

When data-modifying functions increase the size of the string, QString may reallocate the memory in which it holds its data. When this happens, QString expands by more than it immediately needs so as to have space for further expansion without reallocation until the size of the string has significantly increased.

The insert(), remove(), and, when replacing a sub-string with one of different size, replace() functions can be slow (\l{linear time}) for large strings because they require moving many characters in the string by at least one position in memory.

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 the QString actually has allocated.

QString provides \l{STL-style iterators} (QString::const_iterator and QString::iterator). In practice, iterators are handy when working with generic algorithms provided by the C++ standard library.

Note
Iterators over a QString, and references to individual characters within one, cannot be relied on to remain valid when any non-{const} method of the QString is called. Accessing such an iterator or reference after the call to a non-{const} method leads to undefined behavior. When stability for iterator-like functionality is required, you should use indexes instead of iterators, as they are not tied to QString's internal state and thus do not get invalidated.
Due to \l{implicit sharing}, the first non-{const} operator or function used on a given QString may cause it to internally perform a deep copy of its data. This invalidates all iterators over the string and references to individual characters within it. Do not call non-const functions while keeping iterators. Accessing an iterator or reference after it has been invalidated leads to undefined behavior. See the \l{Implicit sharing iterator problem} section for more information.

A frequent requirement is to remove or simplify the spacing between visible characters in a string. The characters that make up that spacing are those for which \l {QChar::}{isSpace()} returns true, such as the simple space {' '}, the horizontal tab {'\t'} and the newline {'\n'}. To obtain a copy of a string leaving out any spacing from its start and end, use \l trimmed(). To also replace each sequence of spacing characters within the string with a simple space, {' '}, use \l 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, the latter searches backward. Either can be told an index position from which to start their search. Each returns the index position of the character or substring if they find it; otherwise, they return -1. For example, here is a typical loop that finds all occurrences of a particular substring:

QString str = "We must be <b>bold</b>, very <b>bold</b>";
qsizetype 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 uppercase 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 filtered list from a string list by selecting the entries in it that contain a particular substring or match a particular QRegularExpression. See QStringList::filter() for details.

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

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.

QStrings can be compared using overloaded operators such as \l operator<(), \l operator<=(), \l operator==(), \l operator>=(), and so on. The comparison is based exclusively on the lexicographical order of the two strings, seen as sequences of UTF-16 code units. It is very fast but is not what a human would expect; the QString::localeAwareCompare() function is usually a better choice for sorting user-interface strings, when such a comparison is available.

When Qt is linked with the ICU library (which it usually is), its locale-aware sorting is used. Otherwise, platform-specific solutions are used: \list

  • On Windows, localeAwareCompare() uses the current user locale, as set in the \uicontrol{regional} and \uicontrol{language} options portion of \uicontrol{Control Panel}.
  • On \macos and iOS, \l localeAwareCompare() compares according to the \uicontrol{Order for sorted lists} setting in the \uicontrol{International preferences} panel.
  • On other Unix-like systems, the comparison falls back to the system library's strcoll(). \endlist

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

\list

  • toLatin1() returns a Latin-1 (ISO 8859-1) encoded 8-bit string.
  • toUtf8() returns a UTF-8 encoded 8-bit string. UTF-8 is a superset of US-ASCII (ANSI X3.4-1986) that supports the entire Unicode character set through multibyte sequences.
  • toLocal8Bit() returns an 8-bit string using the system's local encoding. This is the same as toUtf8() on Unix systems. \endlist

To convert from one of these encodings, QString provides fromLatin1(), fromUtf8(), and fromLocal8Bit(). Other encodings are supported through the QStringEncoder and QStringDecoder classes.

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 some of the following preprocessor symbols:

\list

  • \l QT_NO_CAST_FROM_ASCII disables automatic conversions from C string literals and pointers to Unicode.
  • \l QT_RESTRICTED_CAST_FROM_ASCII allows automatic conversions from C characters and character arrays but disables automatic conversions from character pointers to Unicode.
  • \l QT_NO_CAST_TO_ASCII disables automatic conversion from QString to C strings. \endlist

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

Similarly, you must call toLatin1(), toUtf8(), or toLocal8Bit() explicitly to convert the QString to an 8-bit string.

\table 100 % \header

  • Note for C Programmers

\row

  • Due to C++'s type system and the fact that QString is \l{implicitly shared}, QStrings may be treated like {int}s or other basic types. For example:
{
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.

\endtable

For historical reasons, QString distinguishes between null and empty strings. A null string is a string that is initialized using QString's default constructor or by passing \nullptr 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, toUtf8().constData() returns a valid pointer (not \nullptr) to a '\0' character for a null string. We recommend that you always use the isEmpty() function and avoid isNull().

When a QString::arg() {''} format specifier includes the {'L'} locale qualifier, and the base is ten (its default), the default locale is used. This can be set using \l{QLocale::setDefault()}. For more refined control of localized string representations of numbers, see QLocale::toString(). All other number formatting done by QString follows the C locale's representation of numbers.

When QString::arg() applies left-padding to numbers, the fill character {'0'} is treated specially. If the number is negative, its minus sign appears before the zero-padding. If the field is localized, the locale-appropriate zero character is used in place of {'0'}. For floating-point numbers, this special treatment only applies if the number is finite.

In member functions (for example, arg() and number()) that format floating-point numbers (float or double) as strings, the representation used can be controlled by a choice of format and precision, whose meanings are as for \l {QLocale::toString(double, char, int)}.

If the selected format includes an exponent, localized forms follow the locale's convention on digits in the exponent. For non-localized formatting, the exponent shows its sign and includes at least two digits, left-padding with zero if needed.

Many strings are known at compile time. The QString constructor from C++ string literals will copy the contents of the string, treating the contents as UTF-8. This requires memory allocation and re-encoding string data, operations that will happen at runtime. If the string data is known at compile time, you can use the QStringLiteral macro or similarly {operator""_s} to create QString's payload at compile time instead.

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

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

There is nothing wrong with either of these string constructions, but there are a few hidden inefficiencies:

First, repeated use of the {'+'} operator may lead to multiple memory allocations. When concatenating {n} substrings, where {n > 2}, there can be as many as {n - 1} calls to the memory allocator.

These allocations can be optimized by an internal class {QStringBuilder}. 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.

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

There are two 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");
QStringView el = QStringView{ hello }.mid(2, 3);

A more global approach, which is more convenient but not entirely source-compatible, is to define QT_USE_QSTRINGBUILDER (by adding it to the compiler flags) at build time. This will make concatenating strings with {'+'} work the same way as {QStringBuilder's} {''}.

Note
Using automatic type deduction (for example, by using the auto keyword) with the result of string concatenation when QStringBuilder is enabled will show that the concatenation is indeed an object of a QStringBuilder specialization:
QString str("QStringBuilder");
// "s" type is deduced as QStringBuilder<...>
auto s = "Like hot glue, " % str % " concatenates strings";
// Similarly the return type of this lambda is deduced as QStringBuilder<...>
auto concatenateStr = []() {
return "Like hot glue, " % str % " concatenates strings";
};

This does not cause any harm, as QStringBuilder will implicitly convert to QString when required. If this is undesirable, then one should specify the necessary types instead of having the compiler deduce them:

QString s = "Like hot glue, " % str % " concatenates strings";
// With a lambda, specify a trailing return type:
auto concatenateStr = []() -> QString {
return "Like hot glue, " % str % " concatenates strings";
};
HelloWorldTask * hello
QStringView el
QLatin1StringView world("world")
auto concatenateStr
QString foo
[0]

The maximum size of QString depends on the architecture. Most 64-bit systems can allocate more than 2 GB of memory, with a typical limit of 2^63 bytes. The actual value also depends on the overhead required for managing the data block. As a result, you can expect a maximum size of 2 GB minus overhead on 32-bit platforms and 2^63 bytes minus overhead on 64-bit platforms. The number of elements that can be stored in a QString is this maximum size divided by the size of QChar.

When memory allocation fails, QString throws a std::bad_alloc exception if the application was compiled with exception support. Out-of-memory conditions in Qt containers are the only cases where Qt will throw exceptions. If exceptions are disabled, then running out of memory is undefined behavior.

Note
Target operating systems may impose limits on how much memory an application can allocate, in total, or on the size of individual allocations. This may further restrict the size of string a QString can hold. Mitigating or controlling the behavior these limits cause is beyond the scope of the Qt API.
See also
fromRawData(), QChar, QStringView, QLatin1StringView, QByteArray

Definition at line 128 of file qstring.h.

Member Typedef Documentation

◆ const_iterator

See also
QString::iterator

Definition at line 929 of file qstring.h.

◆ const_pointer

The QString::const_pointer typedef provides an STL-style const pointer to a QString element (QChar).

Definition at line 955 of file qstring.h.

◆ const_reference

Definition at line 952 of file qstring.h.

◆ const_reverse_iterator

◆ ConstIterator

Qt-style synonym for QString::const_iterator.

Definition at line 931 of file qstring.h.

◆ DataPointer

Definition at line 163 of file qstring.h.

◆ difference_type

Definition at line 951 of file qstring.h.

◆ iterator

See also
QString::const_iterator

Definition at line 928 of file qstring.h.

◆ Iterator

Qt-style synonym for QString::iterator.

Definition at line 930 of file qstring.h.

◆ pointer

The QString::pointer typedef provides an STL-style pointer to a QString element (QChar).

Definition at line 954 of file qstring.h.

◆ reference

Definition at line 953 of file qstring.h.

◆ reverse_iterator

◆ size_type

Definition at line 950 of file qstring.h.

◆ value_type

Definition at line 956 of file qstring.h.

Member Enumeration Documentation

◆ NormalizationForm

This enum describes the various normalized forms of Unicode text.

\value NormalizationForm_D Canonical Decomposition \value NormalizationForm_C Canonical Decomposition followed by Canonical Composition \value NormalizationForm_KD Compatibility Decomposition \value NormalizationForm_KC Compatibility Decomposition followed by Canonical Composition

See also
normalized(), {https://www.unicode.org/reports/tr15/}{Unicode Standard Annex #15}
Enumerator
NormalizationForm_D 
NormalizationForm_C 
NormalizationForm_KD 
NormalizationForm_KC 

Definition at line 617 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.

\value SectionDefault Empty fields are counted, leading and trailing separators are not included, and the separator is compared case sensitively.

\value SectionSkipEmpty Treat empty fields as if they don't exist, i.e. they are not considered as far as start and end are concerned.

\value SectionIncludeLeadingSep Include the leading separator (if any) in the result string.

\value SectionIncludeTrailingSep Include the trailing separator (if any) in the result string.

\value SectionCaseInsensitiveSeps Compare the separator case-insensitively.

See also
section()
Enumerator
SectionDefault 
SectionSkipEmpty 
SectionIncludeLeadingSep 
SectionIncludeTrailingSep 
SectionCaseInsensitiveSeps 

Definition at line 337 of file qstring.h.

Constructor & Destructor Documentation

◆ QString() [1/12]

constexpr QString::QString ( )
constexprnoexcept

Constructs a null string.

Null strings are also considered empty.

See also
isEmpty(), isNull(), {Distinction Between Null and Empty Strings}

Definition at line 1322 of file qstring.h.

◆ QString() [2/12]

QString::QString ( const QChar * unicode,
qsizetype size = -1 )
explicit

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

If unicode is 0, a null string is constructed.

If size is negative, unicode is assumed to point to a \0'-terminated array and its length is determined dynamically. The terminating null character is not considered part of the string.

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.

See also
fromRawData()

Definition at line 2493 of file qstring.cpp.

References d, Q_CHECK_PTR(), and QtPrivate::qustrlen().

+ Here is the call graph for this function:

◆ QString() [3/12]

QString::QString ( QChar c)

Constructs a string of size 1 containing the character ch.

Definition at line 2559 of file qstring.cpp.

References ch, d, and Q_CHECK_PTR().

+ Here is the call graph for this function:

◆ QString() [4/12]

QString::QString ( qsizetype size,
QChar ch )

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

See also
fill()

Definition at line 2517 of file qstring.cpp.

References ch, d, and Q_CHECK_PTR().

+ Here is the call graph for this function:

◆ QString() [5/12]

QString::QString ( QLatin1StringView str)
inline

Constructs a copy of the Latin-1 string viewed by str.

See also
fromLatin1()

Definition at line 1224 of file qstring.h.

References QLatin1StringView::data(), fromLatin1(), and QLatin1StringView::size().

+ Here is the call graph for this function:

◆ QString() [6/12]

QString::QString ( QStringView sv)
inlineexplicit

Definition at line 170 of file qstring.h.

◆ QString() [7/12]

QString::QString ( const QString & other)
inlinenoexcept

Constructs a copy of other.

This operation takes \l{constant time}, because QString is \l{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 \l{linear time}.

See also
operator=()

Definition at line 1254 of file qstring.h.

◆ ~QString()

QString::~QString ( )
inline

Destroys the string.

Definition at line 1323 of file qstring.h.

◆ QString() [8/12]

QString::QString ( QString && other)
inlinedefaultnoexcept

Move-constructs a QString instance, making it point at the same object that other was pointing to.

Since
5.2

◆ QString() [9/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 fromUtf8() function.

You can disable this constructor by defining \l 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.

Note
Defining \l QT_RESTRICTED_CAST_FROM_ASCII also disables this constructor, but enables a {QString(const char (&ch)[N])} constructor instead. Using non-literal input, or input with embedded NUL characters, or non-7-bit characters is undefined in this case.
See also
fromLatin1(), fromLocal8Bit(), fromUtf8()

Definition at line 838 of file qstring.h.

◆ QString() [10/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 fromUtf8().

You can disable this constructor by defining \l 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.

Note
Any null ('\0') bytes in the byte array will be included in this string, converted to Unicode null characters (U+0000). This behavior is different from Qt 5.x.
See also
fromLatin1(), fromLocal8Bit(), fromUtf8()

Definition at line 841 of file qstring.h.

◆ QString() [11/12]

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

Constructs a string of the given size without initializing the characters. This is only used in QStringBuilder::toString().

Definition at line 2538 of file qstring.cpp.

References d, and Q_CHECK_PTR().

+ Here is the call graph for this function:

◆ QString() [12/12]

QString::QString ( DataPointer && dd)
inlineexplicit

Definition at line 1001 of file qstring.h.

Member Function Documentation

◆ append() [1/8]

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

Definition at line 865 of file qstring.h.

References append().

+ Here is the call graph for this function:

◆ append() [2/8]

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

Definition at line 867 of file qstring.h.

References append().

+ Here is the call graph for this function:

◆ append() [3/8]

QString & QString::append ( const QChar * uc,
qsizetype len )

Definition at line 3186 of file qstring.cpp.

References d, data(), and str.

+ Here is the call graph for this function:

◆ append() [4/8]

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

Appends the string str onto the end of this string.

Example:

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

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

The append() function is typically very fast (\l{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 3157 of file qstring.cpp.

References append(), constData(), QArrayDataPointer< T >::isMutable(), isNull(), Q_UNLIKELY, size(), and str.

+ Here is the call graph for this function:

◆ append() [5/8]

QString & QString::append ( QChar c)

Definition at line 3252 of file qstring.cpp.

References ch, d, data(), and QArrayData::GrowsAtEnd.

Referenced by QQmlJS::Dom::OutWriter::OutWriter(), QFileSystemIterator::QFileSystemIterator(), CPP::WriteDeclaration::acceptUI(), QWindowsFontDatabase::addApplicationFont(), QQmlJS::Dom::ImportScope::addImport(), QQmlSignalNames::addPrefixToPropertyName(), addressLine(), QXmlStreamPrivateTagStack::addToStringStorage(), QQmlDelayedCallQueue::addUniquelyAndExecuteLater(), QCoreApplicationPrivate::appendApplicationPathToLibraryPaths(), Widget::appendFunction(), QmlIR::IRBuilder::asString(), QQmlJS::Dom::ModuleIndex::autoExports(), QQmlJSImportVisitor::breakInheritanceCycles(), buildAndroidProject(), codesignBundle(), QColorOutput::colorify(), comify(), QSqlQueryModelSql::comma(), QQuickStateGroup::componentComplete(), QSqlQueryModelSql::concat(), QPlaceManagerEngineNokiaV2::constructIconUrl(), QMacMimePlainTextFallback::convertFromMime(), QMacMimeUnicodeText::convertFromMime(), QMacMimeTraditionalMacPlainText::convertFromMime(), QXcbWindow::create(), QQmlPropertyCacheCreator< ObjectContainer >::createMetaObject(), QMimerSQLResult::data(), QCalendarBackend::dateTimeToString(), deployQmlImports(), deployTranslations(), QLocaleData::doubleToString(), QSqlQueryModelSql::eq(), QColorOutputPrivate::escapeCode(), QPlatformFontDatabase::fallbacksForFamily(), QFontDatabase::families(), QV4::Moth::BytecodeGenerator::finalize(), QSSGRenderEffect::finalizeShaders(), QTextBrowserPrivate::findFile(), QmlTypesClassDescription::findType(), QQmlDebugTranslationServicePrivate::getStyleNameForFont(), Driver::headerFileName(), QQmlXMLHttpRequest::headers(), QTextDocumentPrivate::insert(), QTextDocumentPrivate::insertBlock(), QStandardPaths::locateAll(), QmlLsp::messageToDiagnostic_helper(), QXcbMime::mimeAtomForFormat(), Widget::modify(), QFileSystemModelPrivate::node(), QPSQLDriver::open(), parseAttributeValues(), parseCSStoXMLAttrs(), SyncScanner::parseHeader(), parseNumbersArray(), parseNumbersArray(), parseNumbersList(), parsePercentageList(), QCss::Parser::parseSimpleSelector(), CompletionRequest::patchInvalidFileForParser(), QMimerSQLDriver::primaryIndex(), qRelocateResourceFile(), QTest::qSignalDumperCallback(), DomInclude::read(), DomHeader::read(), DomResourcePixmap::read(), DomResourceIcon::read(), DomString::read(), QMimerSQLDriver::record(), AppendText::redo(), resolveFileName(), QToolBarAreaLayout::restoreState(), GatherSourcesJob::run(), QWindowsNativeOpenFileDialog::selectedFiles(), QSqlRelationalTableModel::selectStatement(), QQmlDebugTranslationServicePrivate::sendTranslationIssues(), QQuickTextInput::setInputMask(), QWindowsSystemTrayIcon::showMessage(), QSqlDriver::sqlStatement(), QQmlJS::Dom::QmlComponent::subComponents(), QMimeType::suffixes(), ToString(), QIPAddressUtils::toString(), QSSGQmlUtilities::valueToQml(), QQmlJS::Dom::LineWriter::write(), and write_pbm_image().

+ Here is the call graph for this function:

◆ append() [6/8]

QString & QString::append ( QLatin1StringView s)

Definition at line 3203 of file qstring.cpp.

References str.

◆ append() [7/8]

QString & QString::append ( QStringView v)
inline

Definition at line 474 of file qstring.h.

References append().

Referenced by append().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ append() [8/8]

QString & QString::append ( QUtf8StringView s)

Definition at line 3215 of file qstring.cpp.

References str.

◆ arg() [1/15]

template<typename... Args>
template< typename...Args > QString QString::arg ( Args &&... args) const
inline
Since
5.14

Replaces occurrences of {N} in this string with the corresponding argument from args. The arguments are not positional: the first of the args replaces the {N} with the lowest {N} (all of them), the second of the args the {N} with the next-lowest {N} etc.

Args can consist of anything that implicitly converts to QString, QStringView or QLatin1StringView.

In addition, the following types are also supported: QChar, QLatin1Char.

See also
QString::arg()

Definition at line 284 of file qstring.h.

References QStringView::arg(), args, and qToStringViewIgnoringNull().

+ Here is the call graph for this function:

◆ arg() [2/15]

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

Definition at line 8994 of file qstring.cpp.

References arg.

◆ arg() [3/15]

QString QString::arg ( const QString & a,
int fieldWidth = 0,
QChar fillChar = u' ' ) 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 asprintf() 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 8704 of file qstring.cpp.

References arg, and qToStringViewIgnoringNull().

+ Here is the call graph for this function:

◆ arg() [4/15]

QString QString::arg ( double a,
int fieldWidth = 0,
char format = 'g',
int precision = -1,
QChar fillChar = u' ' ) const

◆ arg() [5/15]

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

Definition at line 1271 of file qstring.h.

References arg, and base.

◆ arg() [6/15]

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

Definition at line 1275 of file qstring.h.

References arg, and base.

◆ arg() [7/15]

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

Definition at line 8984 of file qstring.cpp.

References arg.

◆ arg() [8/15]

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

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

Since
5.10

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

fieldWidth specifies the minimum amount of space that 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.

One advantage of using arg() over asprintf() 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, arg() replaces all of them.

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

Definition at line 8777 of file qstring.cpp.

References arg, and qt_from_latin1_to_qvla().

+ Here is the call graph for this function:

◆ arg() [9/15]

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

Definition at line 8870 of file qstring.cpp.

References arg, base, QLocaleData::c(), d, findArgEscapes(), QLocaleData::GroupDigits, QLocaleData::NoFlags, QLocale::OmitGroupSeparator, Q_ASSERT, qWarning, replaceArgEscapes(), and QLocaleData::ZeroPadded.

Referenced by QMessageBox::aboutQt(), Widget::argFunction(), buildAndroidProject(), buildMatchRule(), QImageWriterPrivate::canWriteHelper(), checkRegistration(), conflictingVersionToString(), QBluetoothSocketPrivateAndroid::connectToServiceHelper(), containsApplicationBinary(), QQmlJSCodeGenerator::conversion(), copyStdCpp(), QQuickAbstractAnimationPrivate::createProperty(), QLocale::createSeparatedList(), TableModel::data(), QPcsc::errorMessage(), QWasmScreen::eventTargetId(), QBluetoothSocketPrivateAndroid::fallBackReversedConnect(), fboStatusString(), QPSQLResultPrivate::fieldSerial(), QSqlResultPrivate::fieldSerial(), findPatternUnloaded(), QHttpThreadDelegate::finishedSlot(), QMinimalBackingStore::flush(), QQmlJSCodeGenerator::generate_GetOptionalLookup(), QLocalSocketPrivate::generateErrorString(), generateInterfaceXml(), genVulkanFunctionsPC(), QGeoUriProvider::getCurrentHost(), QtWaylandClient::getIconSvg(), QNearFieldTargetPrivateImpl::getTagTechnology(), GeoTileFetcherEsri::getTileImage(), QCommandLineParserPrivate::helpText(), QQmlJSLinter::lintModule(), QGeoServiceProviderPrivate::loadMeta(), QDnsLookupReply::makeDnsRcodeError(), maxExpression(), minExpression(), LiteralBindingCheckBase::onBinding(), QWasmScreen::outerScreenId(), QT_BEGIN_NAMESPACE::parseLocation(), parseOptions(), QCommandLineParserPrivate::parseOptionValue(), parseTestArgs(), QMYSQLDriver::primaryIndex(), QPSQLDriver::primaryIndex(), QQmlAbstractBinding::printBindingLoopError(), pullFiles(), QSvgPaintEngine::qbrushToSvg(), qDBusReplyFill(), QTest::qFindTestData(), qRequireVersion(), readInputFile(), QMYSQLDriver::record(), QOCIDriver::record(), replacePercentN(), QQmlJSFunctionInitializer::run(), QmlTypeRegistrar::runExtract(), QSvgPaintEngine::savePatternBrush(), QSvgPaintEngine::savePatternMask(), PlaceManagerEngineEsri::search(), QQmlToolingSettings::search(), QQmlDebugTranslationServicePrivate::sendTranslatableTextOccurrences(), QLocalServerPrivate::setError(), QMdiSubWindowPrivate::setNewWindowTitle(), signAAB(), signPackage(), QHttpThreadDelegate::synchronousFinishedSlot(), QQuickTableViewPrivate::tableLayoutToString(), QSQLiteDriver::tables(), QSchannelBackend::tlsLibraryBuildVersionString(), QQmlDebugTranslation::TranslationIssue::toDebugString(), QQmlItemSelectionRangeValueType::toString(), QQuickVector2DValueType::toString(), QQuickVector3DValueType::toString(), QQuickVector4DValueType::toString(), QQuickQuaternionValueType::toString(), QQuickFontValueType::toString(), QPdfLink::toString(), updateAndroidManifest(), updateLibsXml(), QLibraryPrivate::updatePluginState(), MainWindow::updateSelection(), QV4::Compiler::Codegen::visit(), Jpeg2000JasperReader::write(), and QBluetoothSocketPrivateBluez::writeData().

+ Here is the call graph for this function:

◆ arg() [10/15]

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

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

Since
5.10

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 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:

int i; // current file's number
int total; // number of files to process
QStringView 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 asprintf() 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, arg() replaces all of them.

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

Definition at line 8741 of file qstring.cpp.

References d, findArgEscapes(), Q_UNLIKELY, qUtf16Printable, qWarning, and replaceArgEscapes().

+ Here is the call graph for this function:

◆ arg() [11/15]

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

Definition at line 8916 of file qstring.cpp.

References arg, base, QLocaleData::c(), d, findArgEscapes(), QLocaleData::GroupDigits, QLocaleData::NoFlags, QLocale::OmitGroupSeparator, Q_ASSERT, qWarning, replaceArgEscapes(), and QLocaleData::ZeroPadded.

+ Here is the call graph for this function:

◆ arg() [12/15]

QString QString::arg ( short a,
int fieldWidth = 0,
int base = 10,
QChar fillChar = u' ' ) 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 argument specifies the base to use when converting the integer a into a string. The base must be between 2 and 36, with 8 giving octal, 10 decimal, and 16 hexadecimal numbers.

See also
{Number Formats}

Definition at line 1279 of file qstring.h.

References arg, and base.

◆ arg() [13/15]

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

Definition at line 1273 of file qstring.h.

References arg, and base.

◆ arg() [14/15]

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

Definition at line 1277 of file qstring.h.

References arg, and base.

◆ arg() [15/15]

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

Definition at line 1281 of file qstring.h.

References arg, and base.

◆ asprintf()

QString QString::asprintf ( const char * cformat,
... )
static
Since
5.5

Safely builds a formatted string from the format string cformat and an arbitrary list of arguments.

The format string supports the conversion specifiers, length modifiers, and flags provided by printf() in the standard C++ library. The cformat string and {s} arguments must be UTF-8 encoded.

Note
The {lc} escape sequence expects a unicode character of type char16_t, or ushort (as returned by QChar::unicode()). The {ls} escape sequence expects a pointer to a zero-terminated array of unicode characters of type char16_t, or ushort (as returned by QString::utf16()). This is at odds with the printf() in the standard C++ library, which defines {lc} to print a wchar_t and {ls} to print a {wchar_t*}, and might also produce compiler warnings on platforms where the size of {wchar_t} is not 16 bits.
Warning
We do not recommend using QString::asprintf() in new Qt code. Instead, consider using QTextStream or arg(), both of which support Unicode strings seamlessly and are type-safe. Here is an example that uses QTextStream:
QTextStream(&result) << "pi = " << 3.14;
// result == "pi = 3.14"

For \l {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 7263 of file qstring.cpp.

Referenced by addFunction(), addStartCond(), QSSGStageGeneratorBase::buildShaderSourcePass2(), QCoreApplicationPrivate::checkReceiverThread(), QRhiMetal::create(), QKmsDevice::discoverPlanes(), double2string(), dumpAttributeVariant(), DebugViewHelpers::ensureDebugObjectName(), QQmlJavaScriptExpression::expressionIdentifier(), formatLogMessage(), funcCall(), funcSig(), generateInterfaceXml(), genVulkanFunctionsH(), genVulkanFunctionsPC(), genVulkanFunctionsPH(), QQmlPluginImporter::importPlugins(), int2string(), QTimeZonePrivate::isoOffsetFormat(), QSysInfo::kernelVersion(), main(), QMimeTypeParserBase::parse(), QSysInfo::prettyProductName(), printRenderPassDetails(), QSysInfo::productVersion(), QTest::qCaught(), QQmlEnginePrivate::singletonInstance(), timeUnit(), toOffsetString(), QQmlPointFValueType::toString(), QQmlPointValueType::toString(), QQmlSizeFValueType::toString(), QQmlSizeValueType::toString(), QQmlRectFValueType::toString(), QQmlRectValueType::toString(), updateLibsXml(), QPrintPreviewDialogPrivate::updateZoomFactor(), QSettingsPrivate::variantToString(), QQmlImports::versionString(), and write_xpm_image().

+ Here is the caller graph for this function:

◆ assign() [1/3]

template<typename InputIterator , if_compatible_iterator< InputIterator > = true>
QString & QString::assign ( InputIterator first,
InputIterator last )
inline

Definition at line 492 of file qstring.h.

References append(), ch, d, reserve(), resize(), and q20::to_address().

+ Here is the call graph for this function:

◆ assign() [2/3]

QString & QString::assign ( QAnyStringView v)
Since
6.6

Replaces the contents of this string with a copy of v and returns a reference to this string.

The size of this string will be equal to the size of v, converted to UTF-16 as if by {v.toString()}. Unlike QAnyStringView::toString(), however, this function only allocates memory if the estimated size exceeds the capacity of this string or this string is shared.

See also
QAnyStringView::toString()

Definition at line 3406 of file qstring.cpp.

References append(), capacity, d, and resize().

+ Here is the call graph for this function:

◆ assign() [3/3]

QString & QString::assign ( qsizetype n,
QChar c )
inline
Since
6.6

Replaces the contents of this string with n copies of c and returns a reference to this string.

The size of this string will be equal to n, which has to be non-negative.

This function will only allocate memory if n exceeds the capacity of this string or this string is shared.

See also
fill()

Definition at line 486 of file qstring.h.

References fill(), and Q_ASSERT.

+ Here is the call graph for this function:

◆ at()

const QChar QString::at ( qsizetype 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 1226 of file qstring.h.

References d, and i.

Referenced by CompletionContextStrings::CompletionContextStrings(), QMacSettingsPrivate::QMacSettingsPrivate(), QQmlTypeLoader::absoluteFilePath(), addFontToDatabase(), addFontToDatabase(), advanceStringIndex(), QUrlPrivate::appendHost(), QToolBarAreaLayout::apply(), Widget::atFunction(), QTextEngine::atWordSeparator(), QWidgetLineControl::backspace(), QQuickTextInputPrivate::backspace(), QFileSystemEntry::baseName(), Utils::TextDocument::characterAt(), comify(), QFileSystemEntry::completeBaseName(), constructRoute(), convertMnemonics(), QTextLayout::createLine(), createPatternNode(), createSvgNode(), QQuickPropertyAnimation::createTransitionActions(), CustomIterator::currentFileName(), QTextCursor::deletePreviousChar(), QAbstractItemModel::dropMimeData(), QAbstractTableModel::dropMimeData(), QAbstractListModel::dropMimeData(), QTextHtmlParser::eatSpace(), QTextEngine::elidedText(), QQmlJS::SourceLocation::endZeroLengthLocation(), QQmlJS::Dom::LineWriter::ensureSpace(), QQmlJS::Dom::LineWriter::ensureSpace(), QRegularExpression::escape(), QSqlResult::exec(), QFontEngineMulti::fallbackFamilyAt(), QFileSystemEntry::fileName(), findInBlock(), findTextEntry(), QToolBarAreaLayout::findToolBar(), formatLogMessage(), QQmlJS::Dom::Path::fromString(), QToolBarAreaLayoutInfo::gapIndex(), QToolBarAreaLayout::getStyleOptionInfo(), QV4::RegExp::getSubstitution(), QTextLine::glyphRuns(), QQmlJS::Dom::LineWriter::handleTrailingSpace(), QTextHtmlParserNode::hasOnlyWhitespace(), QTextHtmlParser::hasPrefix(), Driver::headerFileName(), QToolBarAreaLayout::indexOf(), iniChopTrailingSpaces(), QGeoSatelliteInfoSourceGypsy::init(), init_platform(), QQmlDelegateModelItemMetaType::initializeMetaObject(), QQmlDelegateModelItemMetaType::initializePrototype(), QSettingsPrivate::iniUnescapedKey(), QSettingsPrivate::iniUnescapedStringList(), QQuickTextInput::insert(), QToolBarAreaLayoutInfo::insertItem(), QTextCursor::insertText(), QToolBarAreaLayoutInfo::insertToolBarBreak(), QFileSystemEntry::isAbsolute(), QInputControl::isAcceptableInput(), isLineSeparatorBlockAfterTable(), QAndroidPlatformIconEngine::isNull(), QWindowsIconEngine::isNull(), isParentOf(), isSpecialKey(), QToolBarAreaLayout::itemAt(), QToolBarAreaLayoutInfo::itemRect(), QMenu::keyPressEvent(), QMenuBar::keyPressEvent(), QComboBox::keyPressEvent(), QTextEdit::keyPressEvent(), QCss::Symbol::lexem(), loadTzTimeZones(), mangledIdentifier(), QV4::ExecutionEngine::metaTypeFromJS(), QV4::StringPrototype::method_charAt(), QV4::StringPrototype::method_charCodeAt(), QV4::StringIteratorPrototype::method_next(), mightBeRichTextImpl(), QAbstractItemModel::mimeData(), QKeySequence::mnemonic(), QTextDocumentPrivate::move(), QTextCursorPrivate::movePosition(), QToolBarAreaLayoutInfo::moveToolBar(), QTextLineItemIterator::next(), nextNonWhitespace(), QQmlError::operator<<(), QTextHtmlParser::parse(), QTextHtmlParser::parseCloseTag(), parseColorValue(), QTextHtmlParser::parseEntity(), QTextHtmlParser::parseExclamationTag(), parseFlags(), parseFont(), SyncScanner::parseHeader(), parseInt(), parseIntOption(), parseSymbolLikeAttributes(), QTextHtmlParser::parseTag(), QTextHtmlParser::parseWord(), QFileSystemEntry::path(), QKeyMapper::possibleKeys(), QQmlRangeFormatting::process(), QQml_isFileCaseCorrect(), qQmlJSGenerateLoader(), qt_mac_removeMnemonics(), QQC2_NAMESPACE::qt_mac_removeMnemonics(), qt_punycodeDecoder(), Driver::qtify(), quote(), QOCICols::readPiecewise(), registrationVarName(), QQmlJS::Dom::IndentingLineWriter::reindentAndSplit(), removeDuplicateProxies(), QToolBarAreaLayoutInfo::removeToolBarBreak(), QQuickStateGroupPrivate::replace_states(), QBenchmarkValgrindUtils::runCallgrindSubProcess(), runMoc(), runRcc(), QToolBarAreaLayout::saveState(), QQuickTextInputPrivate::selectWordAtPos(), QV4::Compiler::StringTableGenerator::serialize(), QmlIR::IRBuilder::setId(), QQmlJS::Dom::LineWriter::setLineIndent(), QQuick3DRenderStatsMeshesModel::setMeshData(), QQuick3DRenderStatsPassesModel::setPassData(), QMessagePattern::setPattern(), QQuick3DRenderStatsTexturesModel::setTextureData(), QV4::Compiler::StringTableGenerator::stringForIndex(), QSettingsPrivate::stringListToVariantList(), stringMidRetainingBidiCC(), QCss::StyleSelector::styleRulesForNode(), QQmlLSUtils::textOffsetFrom(), QToolBarAreaLayout::toolBarBreak(), toVariant(), QToolBarAreaLayout::unplug(), unquote(), QDateTimeEditPrivate::validateAndInterpret(), GLSL::Semantic::visit(), QmlIR::IRBuilder::visit(), QmlIR::IRBuilder::visit(), TestHTTPServer::wait(), wrapText(), xpmHash(), and QLocaleData::zeroUcs().

◆ back() [1/2]

QChar & QString::back ( )
inline
Since
5.10

Returns a reference to the last character in the string. Same as {operator[](size() - 1)}.

This function is provided for STL compatibility.

Warning
Calling this function on an empty string constitutes undefined behavior.
See also
front(), at(), operator[]()

Definition at line 1348 of file qstring.h.

◆ back() [2/2]

QChar QString::back ( ) const
inline
Since
5.10

Returns the last character in the string. Same as {at(size() - 1)}.

This function is provided for STL compatibility.

Warning
Calling this function on an empty string constitutes undefined behavior.
See also
front(), at(), operator[]()

Definition at line 232 of file qstring.h.

References at.

Referenced by QWindowsNativeFileDialogBase::setNameFilters().

+ Here is the caller graph for this function:

◆ begin() [1/2]

QString::iterator QString::begin ( )
inline

Returns an \l{STL-style iterators}{STL-style iterator} pointing to the first character in the string.

! [iterator-invalidation-func-desc]

Warning
The returned iterator is invalidated on detachment or when the QString is modified. ! [iterator-invalidation-func-desc]
\sa constBegin(), end()

Definition at line 1349 of file qstring.h.

References d.

Referenced by QQmlDelayedCallQueue::addUniquelyAndExecuteLater(), decode(), decodeFsEncString(), isIp6(), Parser::lineNumber(), QtPrivate::qustrcasechr(), QQmlJSScope::resolveEnums(), and set_text().

+ Here is the caller graph for this function:

◆ begin() [2/2]

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

Definition at line 1351 of file qstring.h.

References d.

◆ capacity()

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

Note
a statically allocated string will report a capacity of 0, even if it's not empty.
The free space position in the allocated memory block is undefined. In other words, one should not assume that the free memory is always located after the initialized elements.
See also
reserve(), squeeze()

Definition at line 1256 of file qstring.h.

References d.

Referenced by QDB2Result::exec(), QOCICols::execBatch(), and needsReallocate().

+ Here is the caller graph for this function:

◆ cbegin()

QString::const_iterator QString::cbegin ( ) const
inline
Since
5.0

Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the first character in the string.

iterator-invalidation-func-desc

See also
begin(), cend()

Definition at line 1353 of file qstring.h.

References d.

Referenced by language::_formatString(), insert_helper(), positionIsFollowedBySpaces(), QStringAlgorithms< StringType >::simplified_helper(), QStringAlgorithms< StringType >::trimmed_helper(), QStringAlgorithms< StringType >::trimmed_helper_inplace(), and QStringAlgorithms< StringType >::trimmed_helper_positions().

+ Here is the caller graph for this function:

◆ cend()

QString::const_iterator QString::cend ( ) const
inline
Since
5.0

Returns a const \l{STL-style iterators}{STL-style iterator} pointing just after the last character in the string.

iterator-invalidation-func-desc

See also
cbegin(), end()

Definition at line 1361 of file qstring.h.

References d.

Referenced by insert_helper(), positionIsFollowedBySpaces(), QStringAlgorithms< StringType >::simplified_helper(), QStringAlgorithms< StringType >::trimmed_helper(), and QStringAlgorithms< StringType >::trimmed_helper_positions().

+ Here is the caller graph for this function:

◆ chop()

void QString::chop ( qsizetype n)

Removes n characters from the end of the string.

If n is greater than or equal to size(), the result is an empty string; if n is negative, it is equivalent to passing zero.

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(), QStringView::chop()

Definition at line 6340 of file qstring.cpp.

References d, and resize().

Referenced by QQmlImports::addFileImport(), addressLine(), buildMatchRule(), QCommonStylePrivate::calculateElidedText(), QQC2::QCommonStylePrivate::calculateElidedText(), Widget::chopFunction(), AndroidAssetsFileEngineHandler::create(), QQmlPreviewFileEngineHandler::create(), createDiskImage(), QUrl::errorString(), formattedAddress(), QAndroidInputContext::getTextBeforeCursor(), QCompletionEngine::matchHint(), QPdfDocument::metaData(), QV4::UrlSearchParamsPrototype::method_toString(), QXcbMime::mimeConvertToFormat(), QFileSystemModelPrivate::node(), packagePath(), parseClockValue(), parseLength(), parseOtoolLibraryLine(), QCss::Parser::parseTerm(), QtModuleInfoStore::populate(), QTest::qSignalDumperCallback(), qt_cleanPath(), removeOptionalQuotes(), QFseventsFileSystemWatcherEngine::removePaths(), QMimeDataPrivate::retrieveTypedData(), QAndroidInputContext::setComposingRegion(), setFontSizeFromValue(), setLetterSpacingFromValue(), QWindowsNativeFileDialogBase::setNameFilters(), setWordSpacingFromValue(), QSqlDriver::stripDelimiters(), QIBaseDriver::tables(), QImage::text(), translateDriveName(), AppendText::undo(), updateLibsXml(), and QTextMarkdownWriter::writeBlock().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ chopped() [1/2]

QString QString::chopped ( qsizetype n) &&
inline

Definition at line 413 of file qstring.h.

◆ chopped() [2/2]

QString QString::chopped ( qsizetype n) const &
inline

Definition at line 398 of file qstring.h.

Referenced by QQmlJSTypeReader::operator()(), and QSQLiteDriver::stripDelimiters().

+ Here is the caller graph for this function:

◆ clear()

void QString::clear ( )
inline

Clears the contents of the string and makes it null.

See also
resize(), isNull()

Definition at line 1252 of file qstring.h.

Referenced by KeyEvent::KeyEvent(), QPlaceManagerEngineNokiaV2::QPlaceManagerEngineNokiaV2(), QLocalSocketPrivate::_q_connectToSocket(), QLocalSocketPrivate::_q_stateChanged(), CPP::WriteInitialization::acceptWidget(), QNetworkAccessAuthenticationManager::cacheProxyCredentials(), QAndroidCameraSession::captureToBuffer(), QTextMarkdownImporter::cbLeaveBlock(), QFileInfoPrivate::clear(), QResourcePrivate::clear(), QTranslatorPrivate::clear(), QMimeTypeXMLData::clear(), QTextDocumentPrivate::clear(), QDecompressHelper::clear(), QHttpHeaderParser::clear(), QAndroidInputContext::ExtractedText::clear(), QAndroidInputContext::clear(), QSqlTableModelPrivate::clear(), QQmlDirParser::clear(), QQmlProfilerEventLocation::clear(), QPlaceContactDetail::clear(), QPlaceSearchRequestPrivate::clear(), QGeoAddress::clear(), QQuickPdfSelection::clear(), QAbstractSpinBoxPrivate::clearCache(), QLabelPrivate::clearContents(), QDtlsBasePrivate::clearDtlsError(), QNetworkRequestFactory::clearPassword(), QV4::Compiler::Codegen::Result::clearResultName(), QQuickFontDialogImplAttached::clearSearch(), QNetworkRequestFactory::clearUserName(), QDBusConnectionPrivate::closeConnection(), QCupsPrintEnginePrivate::closePrintDevice(), QQmlJS::Dom::LineWriter::commitLine(), QAbstractSocket::connectToHost(), QDBusMetaObject::createMetaObject(), QPSQLResultPrivate::deallocatePreparedStmt(), QIBusEngineDesc::deserializeFrom(), QDomBuilder::endEntity(), QQmlJSImportVisitor::endVisit(), QDateTimeEdit::event(), QQmlJS::Dom::ModuleIndex::exportsWithNameAndMinorVersion(), QFont::fromString(), getIBaseError(), QDomDocumentTypePrivate::init(), QCss::Parser::init(), QOpenXRManager::initialize(), QGeoServiceProviderPrivate::manager(), QWhatsThat::mouseReleaseEvent(), QDeclarativeGeoMapCopyrightNotice::mouseReleaseEvent(), QTextHtmlParser::newNode(), Recognizer::nextToken(), QDBusError::operator=(), QHostAddress::operator>>(), CategoryParser::parse(), Recognizer::parse(), QUrlPrivate::parse(), QCommandLineParserPrivate::parse(), parseFontName(), SyncScanner::parseHeader(), QAuthenticatorPrivate::parseHttpResponse(), parseIp6(), parseOptions(), qQmlJSSymbolNamespaceForPath(), qt_split_namespace(), QConfFileSettingsPrivate::readIniFile(), QMdiSubWindowPrivate::removeBaseWidget(), FileInfoThread::removePath(), QWindowsSystemProxy::reset(), QCtfServer::run(), QUrlPrivate::setAuthority(), QQmlJS::Lexer::setCode(), QFileDevicePrivate::setError(), QWaylandTextInputV3Private::setFocus(), setFontFamilyFromValues(), QUrl::setFragment(), QUrlPrivate::setHost(), QLibrary::setLoadHints(), QUrl::setPassword(), QUrl::setPath(), QUrl::setQuery(), QDeclarativeGeocodeModel::setQuery(), QUrl::setScheme(), QUrlPrivate::setScheme(), QLabel::setTextFormat(), QV4::CompiledData::CompilationUnit::setUnitData(), QUrl::setUserInfo(), QUrlPrivate::setUserInfo(), QUrl::setUserName(), QQuickPlatformFileDialog::show(), QDBusTrayIcon::showMessage(), QODBCDriverPrivate::splitTableQualifier(), QSqlDriver::sqlStatement(), QBluetoothDeviceDiscoveryAgentPrivate::start(), QLowEnergyControllerPrivateBluezDBus::startAdvertising(), QQmlJSCodeGenerator::startInstruction(), QQmlApplicationEnginePrivate::startLoad(), QQmlApplicationEnginePrivate::startLoad(), QSQLiteDriver::tables(), QtQuickControls2Plugin::unregisterTypes(), QImageCapturePrivate::unsetError(), QAuthenticatorPrivate::updateCredentials(), QQuickListViewPrivate::updateCurrentSection(), QLibraryPrivate::updatePluginState(), QQuickGridMesh::validateAttributes(), QQmlJSImportVisitor::visit(), QQmlJSImportVisitor::visit(), Uic::write(), QTextMarkdownWriter::writeBlock(), QTextMarkdownWriter::writeFrame(), QtWaylandClient::QWaylandTextInputv1::zwp_text_input_v1_commit_string(), QtWaylandClient::QWaylandTextInputv3::zwp_text_input_v3_done(), and QtWaylandClient::QWaylandTextInputv3::zwp_text_input_v3_enter().

◆ compare() [1/9]

int QString::compare ( const QString & s,
Qt::CaseSensitivity cs = Qt::CaseSensitive ) const
noexcept

Definition at line 6664 of file qstring.cpp.

References QtPrivate::compareStrings(), and other().

Referenced by QFontDatabase::bold(), QWindowsFileIconEngine::cacheKey(), CPP::FontHandle::compare(), CPP::IconHandle::compare(), CPP::SizePolicyHandle::compare(), Widget::compareFunction(), Widget::compareSensitiveFunction(), QCocoaIntegrationPlugin::create(), QIOSIntegrationPlugin::create(), QComposePlatformInputContextPlugin::create(), QIbusPlatformInputContextPlugin::create(), QBsdFbIntegrationPlugin::create(), QWindowsDirect2DIntegrationPlugin::create(), QDirectFbIntegrationPlugin::create(), QEglFSIntegrationPlugin::create(), QHaikuIntegrationPlugin::create(), QIntegrityFbIntegrationPlugin::create(), QLinuxFbIntegrationPlugin::create(), QMinimalIntegrationPlugin::create(), QMinimalEglIntegrationPlugin::create(), QOffscreenIntegrationPlugin::create(), QQnxIntegrationPlugin::create(), QVkKhrDisplayIntegrationPlugin::create(), QVncIntegrationPlugin::create(), QWasmIntegrationPlugin::create(), QWindowsIntegrationPlugin::create(), QXcbIntegrationPlugin::create(), QAndroidIntegrationPlugin::create(), QNetworkAccessFileBackendFactory::create(), QFileSystemModelPrivate::fileSystemChanged(), QSortedModelEngine::filter(), QFontDatabase::font(), QAndroidInputContext::handleLocationChanged(), QCoreApplicationPrivate::initConsole(), QQuickListViewPrivate::initializeViewItem(), QFontDatabase::isBitmapScalable(), QFontDatabase::isSmoothlyScalable(), QExtendedInformation::isSymLink(), QQmlFile::isSynchronous(), QFontDatabase::italic(), QAmbientSoundPrivate::load(), macQueryInternal(), GeoMapSource::mapStyle(), QV4::QQmlXMLHttpRequestCtor::method_get_response(), mightBeRichTextImpl(), needsBasicRenderloopWorkaround(), QSvgStyleSelector::nodeNameEquals(), operator<(), QFileSystemModelPrivate::QFileSystemNode::operator<(), QFileSystemModelPrivate::QFileSystemNode::operator<(), operator<(), QFileSystemWatcherPathKey::operator==(), QFileSystemModelPrivate::QFileSystemNode::operator==(), QFileSystemModelPrivate::QFileSystemNode::operator>(), parseBrushValue(), parseCmakeBoolean(), parseColorValue(), parseOptions(), QFontDatabase::pointSizes(), qt_gl_resolve_extensions(), quick_test_main_with_setup(), runUic(), QDomElementPrivate::save(), QQuickCanvasItem::setContextType(), QFontDatabase::smoothSizes(), QSortedModelEngine::sortOrder(), QFontDatabase::styles(), toBool(), QQuickListViewPrivate::updateInlineSection(), QQuickListViewPrivate::updateStickySections(), QQmlFile::urlToLocalFileOrQrc(), QFontDatabase::weight(), and QDockWidgetLayout::wmSupportsNativeWindowDeco().

+ Here is the call graph for this function:

◆ compare() [2/9]

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

Definition at line 705 of file qstring.h.

References s2.

◆ compare() [3/9]

static int QString::compare ( const QString & s1,
QLatin1StringView s2,
Qt::CaseSensitivity cs = Qt::CaseSensitive )
inlinestaticnoexcept

Definition at line 709 of file qstring.h.

References s2.

◆ compare() [4/9]

static int QString::compare ( const QString & s1,
QStringView s2,
Qt::CaseSensitivity cs = Qt::CaseSensitive )
inlinestaticnoexcept

Definition at line 715 of file qstring.h.

References s2.

◆ compare() [5/9]

int QString::compare ( QChar ch,
Qt::CaseSensitivity cs = Qt::CaseSensitive ) const
inlinenoexcept

Definition at line 702 of file qstring.h.

References ch, and compare().

+ Here is the call graph for this function:

◆ compare() [6/9]

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

Definition at line 6689 of file qstring.cpp.

References QtPrivate::compareStrings(), and other().

+ Here is the call graph for this function:

◆ compare() [7/9]

static int QString::compare ( QLatin1StringView s1,
const QString & s2,
Qt::CaseSensitivity cs = Qt::CaseSensitive )
inlinestaticnoexcept

Definition at line 712 of file qstring.h.

References s2.

◆ compare() [8/9]

int QString::compare ( QStringView s,
Qt::CaseSensitivity cs = Qt::CaseSensitive ) const
inlinenoexcept

Definition at line 1492 of file qstring.h.

◆ compare() [9/9]

static int QString::compare ( QStringView s1,
const QString & s2,
Qt::CaseSensitivity cs = Qt::CaseSensitive )
inlinestaticnoexcept

Definition at line 717 of file qstring.h.

References s2.

◆ constBegin()

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

Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the first character in the string.

iterator-invalidation-func-desc

See also
begin(), constEnd()

Definition at line 1355 of file qstring.h.

References d.

Referenced by QUnicodeTables::convertCase(), QSvgFont::draw(), is_valid_domain_name(), QFileSystemEntry::isClean(), QStandardPaths::locate(), QStandardPaths::locateAll(), Recognizer::parse(), parseAnimateColorNode(), parseIpFuture(), and set_text().

+ Here is the caller graph for this function:

◆ constData()

const QChar * QString::constData ( ) const
inline

◆ constEnd()

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

Returns a const \l{STL-style iterators}{STL-style iterator} pointing just after the last character in the string.

iterator-invalidation-func-desc

See also
constBegin(), end()

Definition at line 1363 of file qstring.h.

References d.

Referenced by QSvgFont::draw(), is_valid_domain_name(), QFileSystemEntry::isClean(), QStandardPaths::locate(), QStandardPaths::locateAll(), Recognizer::parse(), parseAnimateColorNode(), parseIpFuture(), QQmlJSScope::resolveEnums(), and set_text().

+ Here is the caller graph for this function:

◆ contains() [1/4]

bool 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.

{search-comparison-case-sensitivity} {search}

Example:

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

Definition at line 1365 of file qstring.h.

References indexOf().

+ Here is the call graph for this function:

◆ contains() [2/4]

◆ contains() [3/4]

bool QString::contains ( QLatin1StringView s,
Qt::CaseSensitivity cs = Qt::CaseSensitive ) const
inline

Definition at line 1367 of file qstring.h.

References indexOf().

+ Here is the call graph for this function:

◆ contains() [4/4]

bool QString::contains ( QStringView s,
Qt::CaseSensitivity cs = Qt::CaseSensitive ) const
inlinenoexcept

Definition at line 1371 of file qstring.h.

References indexOf().

+ Here is the call graph for this function:

◆ count() [1/3]

qsizetype 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.

{search-comparison-case-sensitivity} {search}

See also
contains(), indexOf()

Definition at line 4818 of file qstring.cpp.

References QtPrivate::count(), size(), str, and unicode().

+ Here is the call graph for this function:

◆ count() [2/3]

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

Definition at line 4833 of file qstring.cpp.

References ch, and QtPrivate::count().

Referenced by Widget::countFunction(), QSSGMesh::Mesh::fromAssetData(), QAbstractItemView::keyboardSearch(), QTreeView::keyboardSearch(), AttachedPropertyTypeValidatorPass::onBinding(), qt_alphamapblit_argb32(), qt_alphamapblit_generic(), qt_alphamapblit_quint16(), qt_alphargbblit_argb32(), qt_alphargbblit_generic(), QQuickKeyEvent::reset(), and QQuickComboBoxPrivate::tryComplete().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ count() [3/3]

qsizetype QString::count ( QStringView s,
Qt::CaseSensitivity cs = Qt::CaseSensitive ) const

Definition at line 4848 of file qstring.cpp.

References QtPrivate::count(), and str.

+ Here is the call graph for this function:

◆ crbegin()

QString::const_reverse_iterator QString::crbegin ( ) const
inline
Since
5.6

Returns a const \l{STL-style iterators}{STL-style} reverse iterator pointing to the first character in the string, in reverse order.

iterator-invalidation-func-desc

See also
begin(), rbegin(), rend()

Definition at line 946 of file qstring.h.

◆ crend()

QString::const_reverse_iterator QString::crend ( ) const
inline
Since
5.6

Returns a const \l{STL-style iterators}{STL-style} reverse iterator pointing just after the last character in the string, in reverse order.

iterator-invalidation-func-desc

See also
end(), rend(), rbegin()

Definition at line 947 of file qstring.h.

References begin().

+ Here is the call graph for this function:

◆ 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.

Unlike constData() and unicode(), the returned data is always '\0'-terminated.

Example:

QString str = "Hello world";
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 \l{deep copy} to occur.

See also
constData(), operator[]()

Definition at line 1240 of file qstring.h.

References d, and Q_ASSERT.

Referenced by QAnyStringView::QAnyStringView(), QAnyStringView::QAnyStringView(), QAnyStringView::QAnyStringView(), QtAndroidMenu::addAllMenuItemsToMenu(), QWindowsFontDatabase::addApplicationFont(), QUrlModel::addUrls(), addZeroPrefixedInt(), allocateStringFn(), append(), append(), QTextEngine::attributes(), QV4::Heap::StringOrSymbol::createHashValue(), createLinkTitle(), Widget::dataFunction(), dataToUrls(), decode(), QFileDialogPrivate::deleteCurrent(), DomText(), doParseMountInfo(), QFileDialogPrivate::enterDirectory(), QRegularExpression::errorString(), QDB2Result::exec(), QSQLiteResult::exec(), QDrag::exec(), QBenchmarkValgrindUtils::extractResult(), QSortFilterProxyModel::filterAcceptsRow(), QCompletionEngine::filterHistory(), getMessage(), QRawFont::glyphIndexesForString(), QQmlConnectionSlotDispatcher::impl(), init(), QByteArray::insert(), QTextEngine::itemize(), QLocale::languageToCode(), main(), QQmlLSCompletion::makeSnippet(), QV4::StringCtor::method_fromCharCode(), QV4::StringPrototype::method_padEnd(), QV4::StringPrototype::method_padStart(), QLocale::name(), QtAndroidMenu::onPrepareOptionsMenu(), QFontFamilyDelegate::paint(), parseFontName(), qFillBufferWithString(), DarwinBluetooth::qt_address(), QTest::qt_asprintf(), qt_color_from_string(), qt_from_latin1_to_qvla(), QItemDelegate::rect(), screenForDeviceName(), QUrlPrivate::setScheme(), Widget::sizeFunction(), QFontFamilyDelegate::sizeHint(), QV4::Heap::String::startsWithUpper(), QNetworkReplyWasmImplPrivate::stateChange(), QCoreTextFontEngine::stringToCMap(), QXmlStreamReaderPrivate::symView(), tokenizeLine(), toStdWString(), ucalDaylightOffset(), uuidFromString(), uuidFromString(), QtPrivate::XmlStringRef::view(), and wrapInFunction().

◆ 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.

Note
The returned string may not be '\0'-terminated. Use size() to determine the length of the array.
See also
fromRawData()

Definition at line 1232 of file qstring.h.

References d.

◆ data_ptr() [1/2]

DataPtr & QString::data_ptr ( )
inline

Definition at line 1093 of file qstring.h.

References d.

Referenced by insert_helper(), needsReallocate(), QtPrivate::XmlStringRef::operator QXmlString(), performBitwiseOperation(), prepareForBitwiseOperation(), replace_helper(), replace_in_place(), replace_with_copy(), and QV4::Heap::String::simplifyString().

+ Here is the caller graph for this function:

◆ data_ptr() [2/2]

const DataPointer & QString::data_ptr ( ) const
inline

Definition at line 1094 of file qstring.h.

References d.

◆ detach()

void QString::detach ( )
inline

Definition at line 1248 of file qstring.h.

References d, and QArrayData::KeepSize.

Referenced by appendToUser(), and QTextEngine::itemize().

+ Here is the caller graph for this function:

◆ end() [1/2]

QString::iterator QString::end ( )
inline

Returns an \l{STL-style iterators}{STL-style iterator} pointing just after the last character in the string.

iterator-invalidation-func-desc

See also
begin(), constEnd()

Definition at line 1357 of file qstring.h.

References d.

Referenced by QQmlDelayedCallQueue::addUniquelyAndExecuteLater(), dataToUrls(), isIp6(), Parser::lineNumber(), QQmlLSUtils::qmlLocationToLspLocation(), QtPrivate::qustrcasechr(), QQmlJSScope::resolveEnums(), and set_text().

+ Here is the caller graph for this function:

◆ end() [2/2]

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

Definition at line 1359 of file qstring.h.

References d.

◆ 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.

{search-comparison-case-sensitivity} {search}

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

Definition at line 5506 of file qstring.cpp.

Referenced by QQmlJS::Dom::JsFile::JsFile(), QFileSystemIterator::QFileSystemIterator(), QQmlImports::addFileImport(), addLexToken(), QAbstractGeoTileCache::baseCacheDirectory(), QCommonStylePrivate::calculateElidedText(), QQC2::QCommonStylePrivate::calculateElidedText(), copyQtFiles(), QQmlPreviewFileEngineHandler::create(), QtObject::createComponent(), doFilter(), Widget::endsWithFunction(), QUrl::errorString(), QDB2Driver::escapeIdentifier(), QIBaseDriver::escapeIdentifier(), QMimerSQLDriver::escapeIdentifier(), QMYSQLDriver::escapeIdentifier(), QODBCDriver::escapeIdentifier(), QPSQLDriver::escapeIdentifier(), QIOSFileEngineAssetsLibrary::fileFlags(), QQmlJS::Dom::fileTypeForPath(), findDependencyInfo(), QStandardPaths::findExecutable(), QQuickVectorImagePrivate::formatFromFilePath(), QPlatformWindow::formatWindowTitle(), QQuickQmlGenerator::generateImageNode(), ignoreProxyFor(), QQmlPluginImporter::importPlugins(), QWidgetTextControlPrivate::inputMethodEvent(), FrameworkInfo::isDebugLibrary(), QSqlDriver::isIdentifierEscaped(), QMYSQLDriver::isIdentifierEscaped(), QODBCDriver::isIdentifierEscaped(), QLibrary::isLibrary(), isScalableImageFormat(), QQuickTextDocumentPrivate::load(), QTranslator::load(), QQmlSA::lookupName(), QPdfDocument::metaData(), QFileSystemModelPrivate::node(), QQmlJSTypeReader::operator()(), QQmlJS::Dom::Scanner::operator()(), parseClockValue(), QTextHtmlParser::parseCloseTag(), QHttpHeaderParser::parseHeaders(), parseOptions(), prefixedName(), preprocessMetadata(), qCompileJSFile(), qQmlResolveImportPaths(), qRelocateResourceFile(), QTest::qSignalDumperCallback(), QAndroidSystemLocale::query(), recursiveCopyAndDeploy(), QPlatformTheme::removeMnemonics(), QFileSelectorPrivate::select(), Utils::TextDocument::setPlainText(), QCss::Declaration::sizeValue(), splitIntoFamilies(), QAbstractSpinBoxPrivate::stripped(), QSqlError::text(), QLibraryPrivate::updatePluginState(), GLSL::Semantic::visit(), QmlIR::IRBuilder::visit(), TestHTTPServer::wait(), and QQuickTextDocumentPrivate::writeTo().

◆ endsWith() [2/4]

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

Definition at line 5537 of file qstring.cpp.

References at, Qt::CaseSensitive, and foldCase().

+ Here is the call graph for this function:

◆ endsWith() [3/4]

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

Definition at line 5526 of file qstring.cpp.

◆ endsWith() [4/4]

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

Definition at line 423 of file qstring.h.

References QtPrivate::endsWith().

+ Here is the call graph for this function:

◆ erase() [1/2]

Since
6.1

Removes from the string the characters in the half-open range [ first , last ). Returns an iterator to the character immediately after the last erased character (i.e. the character referred to by last before the erase).

Definition at line 9411 of file qstring.cpp.

References begin(), and remove().

Referenced by QQmlDelayedCallQueue::addUniquelyAndExecuteLater().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ erase() [2/2]

QString::iterator QString::erase ( QString::const_iterator it)
inline

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

Since
6.5

Removes the character denoted by it from the string. Returns an iterator to the character immediately after the erased character.

QString c = "abcdefg";
auto it = c.erase(c.cbegin()); // c is now "bcdefg"; "it" points to "b"
iterator erase(const_iterator i)
Definition qset.h:145
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
QSet< QString >::iterator it
const GLubyte * c

Definition at line 963 of file qstring.h.

References erase(), and it.

Referenced by erase().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fill()

QString & QString::fill ( QChar ch,
qsizetype 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 6358 of file qstring.cpp.

References ch, d, and resize().

Referenced by Option::Option(), QQuickTextInputPrivate::~QQuickTextInputPrivate(), QWidgetLineControl::~QWidgetLineControl(), Widget::fillFunction(), QWidgetLineControl::processInputMethodEvent(), QSvgPaintEngine::qbrushToSvg(), QTest::qSignalDumperCallback(), QTest::qSignalDumperCallbackSlot(), and QSvgVisitorImpl::visitTextNode().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ first() [1/2]

QString QString::first ( qsizetype n) &&
inline

Definition at line 401 of file qstring.h.

References resize().

+ Here is the call graph for this function:

◆ first() [2/2]

◆ fromLatin1() [1/3]

QString QString::fromLatin1 ( const char * str,
qsizetype size )
inlinestatic

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

If size is {-1}, {strlen(str)} is used instead.

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

Definition at line 653 of file qstring.h.

References qstrlen(), and str.

+ Here is the call graph for this function:

◆ fromLatin1() [2/3]

QString QString::fromLatin1 ( const QByteArray & str)
inlinestatic

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

Since
5.0

Returns a QString initialized with the Latin-1 string str.

Note
: any null ('\0') bytes in the byte array will be included in this string, converted to Unicode null characters (U+0000). This behavior is different from Qt 5.x.

Definition at line 652 of file qstring.h.

References ba, and fromLatin1().

Referenced by fromLatin1().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fromLatin1() [3/3]

QString QString::fromLatin1 ( QByteArrayView str)
static

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

Since
6.0

Returns a QString initialized with the Latin-1 string str.

Note
: any null ('\0') bytes in the byte array will be included in this string, converted to Unicode null characters (U+0000).

Definition at line 5871 of file qstring.cpp.

References ba, d, QByteArray::data(), Q_CHECK_PTR(), qt_from_latin1(), and QByteArray::size().

Referenced by QtGraphicsAnchorLayout::ParallelAnchorData::ParallelAnchorData(), QDirPrivate::QDirPrivate(), QProgressDialog::QProgressDialog(), QQuickWidgetOffscreenWindow::QQuickWidgetOffscreenWindow(), QSGDefaultPainterNode::QSGDefaultPainterNode(), QString(), QTextLayout::QTextLayout(), QXcbSessionManager::QXcbSessionManager(), QZipStreamStrategy::QZipStreamStrategy(), QtGraphicsAnchorLayout::SequentialAnchorData::SequentialAnchorData(), QGeoFileTileCache::~QGeoFileTileCache(), QZipStreamStrategy::~QZipStreamStrategy(), QPrintPreviewDialogPrivate::_q_zoomFactorChanged(), QMimeBinaryProvider::addAliases(), QGraphicsAnchorLayoutPrivate::addAnchor_helper(), addFunction(), QMimeBinaryProvider::addParents(), QFreeTypeFontDatabase::addTTFile(), QQmlJSLinter::applyFixes(), automaticPipelineCacheFileName(), QStringConverter::availableCodecs(), QLocale::bcp47Name(), borderStyleName(), bufferFromAttribute(), QNetworkAccessAuthenticationManager::cacheCredentials(), QV4::CallMethod(), QDir::cdUp(), QWindowsFontDatabaseBase::EmbeddedFont::changeFamilyName(), QV4::Managed::className(), QPlatformFileDialogHelper::cleanFilterList(), QBenchmarkValgrindUtils::cleanup(), codesignBundle(), Collector::collect(), QColorOutput::colorify(), colorValue(), QOpenGLShaderPrivate::compile(), QV4::WeakMapCtor::construct(), QPlaceManagerEngineNokiaV2::constructIconUrl(), QTlsPrivate::TlsCryptographSecureTransport::continueHandshake(), QQmlJS::AST::PatternElement::convertLiteralToAssignmentPattern(), QQmlJS::AST::ArrayPattern::convertLiteralToAssignmentPattern(), QQmlJS::AST::PatternProperty::convertLiteralToAssignmentPattern(), QXcbWindow::create(), QIBusPlatformInputContextPrivate::createConnection(), createDirectory(), Graph< Vertex, EdgeData >::createEdge(), createPixmapDataSync(), QQuickDesignerSupportItems::createPrimitive(), createReadHandlerHelper(), createSequence(), QDBusArgumentPrivate::createSignature(), createSymbolicLink(), QOutputStrategy::createUniqueImageName(), createWriteHandlerHelper(), QLocale::currencySymbol(), QSysInfo::currentCpuArchitecture(), QPSQLResult::data(), QGraphicsSceneBspTree::debug(), QKeySequencePrivate::decodeString(), descriptorForFamily(), QPSQLDriverPrivate::detectBackslashEscape(), deviceModelIdentifier(), QNetworkReplyWasmImplPrivate::doSendRequest(), QLocaleData::doubleToString(), QWindowsVistaStyle::drawControl(), QQC2::QStyleHelper::drawDial(), QWindowsVistaStyle::drawPrimitive(), QSimplex::dumpMatrix(), QDateTimeEditPrivate::editorCursorPositionChanged(), encodeByteArray(), encodeFrame(), QKeySequencePrivate::encodeString(), QQmlJSImportVisitor::endVisit(), DebugViewHelpers::ensureDebugObjectName(), QDB2Result::exec(), QRhiD3D11::executeCommandBuffer(), QQmlPropertyBindingJS::expressionChanged(), QWindowsFontDatabaseBase::extraTryFontsForFamily(), fallbackStyleUri(), fbname(), fileArchitecture(), fileInfoListToString(), QQmlJS::Dom::fileLocationRegionName(), QImageTextureGlyphCache::fillTexture(), findAppBundleFiles(), findAppFrameworkNames(), findAppFrameworkPaths(), findAppLibraries(), QMimeBinaryProvider::findByMagic(), QtAndroidPrivate::findClass(), findEntitlementsFile(), QWindowsBackingStore::flush(), QGtk3Interface::font(), formatLogMessage(), QQuickTextEditMimeData::formats(), QQmlLocaleValueType::formattedDataSize(), QVideoTextureHelper::fragmentShaderFileName(), QUrl::fromAce(), QQmlJS::Dom::Map::fromFileRegionListMap(), QQmlJS::Dom::Map::fromFileRegionMap(), QNetworkHeadersPrivate::fromHttpDate(), fromLatin1List(), GLSL::Semantic::functionIdentifier(), QV4::Compiler::Codegen::generateFromProgram(), QSvgPaintEnginePrivate::generateGradientName(), generateInterfaceXml(), generateInterfaceXml(), getExtractedText(), QSSGQmlUtilities::getIdForNode(), getIllegalNames(), QXcbScreen::getName(), QBenchmarkValgrindUtils::getNewestFileName(), QLocationUtils::getNmeaTime(), QPlaceManagerEngineNokiaV2::getPlaceContent(), QPlaceManagerEngineNokiaV2::getPlaceDetails(), QPSQLDriverPrivate::getPSQLVersion(), getQtLibsFromElf(), QTextStreamPrivate::getReal(), QFFmpegWindowCaptureUwp::Grabber::grabFrame(), QOpenXRRuntimeInfo::graphicsApiName(), QQuickSplitViewPrivate::handlePress(), helpText(), host_name_to_settings_key(), QPlaceManagerEngineNokiaV2::icon(), GLSL::Engine::identifier(), QSSGQmlUtilities::indentString(), QWindowsOpengl32DLL::init(), QV4::ErrorPrototype::init(), QWaylandTextureSharingExtension::initialize(), QPlaceManagerEngineNokiaV2::initializeCategories(), QLoggingRegistry::initializeRules(), QQuickGridLayout::insertLayoutItems(), interfaceListing(), QNetworkInterfaceManager::interfaceNameFromIndex(), QSslSocketPrivate::isMatchingHostname(), isScript(), QQuickItemPrivate::itemNode(), QSysInfo::kernelType(), QSysInfo::kernelVersion(), QStringHashNode::key(), QKeySequencePrivate::keyName(), QQuickSplitViewPrivate::layout(), QOpenGLShaderProgram::link(), QQmlJSLinter::lintFile(), QWaylandCompositorPrivate::loadClientBufferIntegration(), QQmlTypeLoader::Blob::loadDependentImports(), QSSGShaderLibraryManager::loadPregeneratedShaderInfo(), QGeoFileTileCache::loadTiles(), QQmlPreviewHandler::loadUrl(), QTlsBackendOpenSSL::longNameForId(), main(), makeFpString(), matchArgsForService(), QQmlPreviewServiceImpl::messageReceived(), QQmlPreviewClient::messageReceived(), QDBusInterfacePrivate::metacall(), QV4::ArrayPrototype::method_fill(), QV4::ArrayPrototype::method_from(), QV4::IntrinsicTypedArrayCtor::method_from(), QQuickJSContext2D::method_get_fillStyle(), QV4::PropertyListPrototype::method_get_length(), QQuickJSContext2D::method_get_strokeStyle(), QV4::IntrinsicTypedArrayPrototype::method_get_toStringTag(), QV4::PropertyListPrototype::method_indexOf(), QV4::PropertyListPrototype::method_lastIndexOf(), QV4::ArrayPrototype::method_map(), QV4::ArrayPrototype::method_of(), QV4::PropertyListPrototype::method_push(), QV4::PropertyListPrototype::method_set_length(), QV4::ArrayPrototype::method_splice(), QV4::PropertyListPrototype::method_splice(), QV4::NumberPrototype::method_toFixed(), QV4::PropertyListPrototype::method_unshift(), QXcbMime::mimeAtomToString(), QXcbMime::mimeConvertToFormat(), QMediaFormat::mimeType(), mmErrorMessage(), msgOpenReadFailed(), QSSGShaderCache::newPipelineFromPregenerated(), GLSL::Engine::number(), QDB2Driver::open(), QOCIDriver::open(), QQmlJSTypeDescriptionReader::operator()(), operator<<(), QUrl::operator>>(), QQmlJS::Dom::ScriptFormatter::out(), QBenchmarkValgrindUtils::outFileBase(), QStaticTextPrivate::paintText(), CategoryParser::parse(), GLSL::Parser::parse(), QMimeTypeParserBase::parse(), parseBoolean(), RCCResourceLibrary::parseCompressionAlgorithm(), RCCResourceLibrary::parseCompressionLevel(), parseDateString(), QIcc::parseDesc(), parseETag(), QTlsPrivate::X509CertificateGeneric::parseExtension(), parseHeaderValue(), QAuthenticatorPrivate::parseHttpResponse(), parseIconEntryInfo(), parseMatchImpl(), QHttpHeaderParser::parseStatus(), parseStopNode(), QQuickStyledTextPrivate::parseTag(), patchQtCore(), QFontconfigDatabase::populateFontDatabase(), QSysInfo::prettyProductName(), QSSGBufferManager::primitivePath(), QSysInfo::productVersion(), propertyWriteReply(), DynamicRoleModelNodeMetaObject::propertyWritten(), Q_TRACE_INSTRUMENT(), QSvgPaintEngine::qbrushToSvg(), qDBusGenerateClassDefXml(), qDBusIntrospectObject(), qlocationutils_readRmc(), qMakeError(), qMakeFieldInfo(), qMakeStatement(), qMakeStmtError(), qQmlResolveImportPaths(), qRegisterNotificationCallbacks(), QDB2DriverPrivate::qSplitTableQualifier(), DarwinBluetooth::qt_error_string(), qt_keyForPageSizeId(), qt_localeFromLCID(), qt_mac_applicationmenu_string(), QTlsBackendOpenSSL::qt_OpenSSL_cipher_to_QSslCipher(), qt_qmlDebugDisableService(), qt_qmlDebugEnableService(), qt_strip_filters(), QTest::qtest_qParseArgs(), QGLXContext::queryDummyContext(), QDeclarativeSearchResultModel::queryFinished(), QAlsaAudioSource::read(), readAllProperties(), QSystemLocaleData::readEnvironment(), RCCResourceLibrary::readFiles(), QPngHandlerPrivate::readPngHeader(), QPngHandlerPrivate::readPngTexts(), QQuickTextInputPrivate::realText(), QIBaseResult::record(), Graph< Vertex, EdgeData >::removeEdge(), QGraphicsAnchorLayoutPrivate::replaceVertex(), QHostInfoAgent::reverseLookup(), QQuickWindowPrivate::rhiCreationFailureMessage(), ValueLookupJob::run(), QmlTypeRegistrar::runExtract(), QV4::MemoryManager::runGC(), runMoc(), runRcc(), runUic(), QDomDocumentPrivate::saveDocument(), QDeviceDiscoveryStatic::scanConnectedDevices(), QPlaceManagerEngineNokiaV2::search(), QPlaceManagerEngineNokiaV2::searchSuggestions(), QSqlRelationalTableModel::selectStatement(), sequenceInterface(), ListModel::set(), QDBusPendingCallPrivate::setMetaTypes(), QComboBoxDelegate::setSeparator(), QQuickQmlGenerator::shapeTypeName(), QTlsBackendOpenSSL::shortNameForId(), simpleTypeString(), QGraphicsAnchorLayoutPrivate::simplifyGraph(), sm_performSaveYourself(), standardLibraryErrorString(), QuickTestResult::stringify(), styleUri(), QTlsPrivate::X509CertificateOpenSSL::subjectAlternativeNames(), QIBaseDriver::subscribeToNotification(), QWidgetLineControl::surroundingText(), QTextOdfWriter::tableCellStyleElement(), Graph< Vertex, EdgeData >::takeEdge(), QWidgetLineControl::text(), QQuickTextInput::text(), QGenericUnixTheme::themeNames(), QTlsBackendOpenSSL::tlsLibraryVersionString(), QAsn1Element::toDateTime(), QQuickStyledTextPrivate::toRoman(), QCborError::toString(), QAsn1Element::toString(), QBenchmarkContext::toString(), GLSL::VectorType::toString(), GLSL::MatrixType::toString(), QTest::toString(), QGeoCoordinate::toString(), QQmlLocaleValueType::toString(), QUuid::toString(), translate_color(), translate_dashPattern(), types(), ucalDaylightOffset(), QLocale::uiLanguages(), QIBaseDriver::unsubscribeFromNotification(), QPdfLinkModelPrivate::update(), QQnxMediaMetaData::update(), updateFile(), updateFile(), QPrintPreviewDialogPrivate::updatePageNumLabel(), QQuickNinePatchImage::updatePaintNode(), QFileSelectorPrivate::updateSelectors(), QSSGQmlUtilities::valueToQml(), QAbstractSpinBoxPrivate::variantCompare(), QV4::CompiledData::Unit::verifyHeader(), QV4::WeakMapCtor::virtualCall(), QV4::WeakSetCtor::virtualCall(), GLSL::Semantic::visit(), GLSL::Semantic::visit(), GLSL::Semantic::visit(), GLSL::Semantic::visit(), GLSL::Semantic::visit(), GLSL::Semantic::visit(), warnIfHorizontallyAnchored(), QXcbWindow::windowTitle(), wrapInFunction(), QTextOdfWriter::writeAll(), writeAttribute(), QTextOdfWriter::writeBlock(), QTextOdfWriter::writeBlockFormat(), QTextOdfWriter::writeCharacterFormat(), RCCFileInfo::writeDataBlob(), QTextOdfWriter::writeFormats(), QTextOdfWriter::writeFrame(), QTextOdfWriter::writeFrameFormat(), QTextOdfWriter::writeInlineCharacter(), QTextOdfWriter::writeListFormat(), QSSGQmlUtilities::writeQml(), and QTextOdfWriter::writeTableFormat().

+ Here is the call graph for this function:

◆ fromLocal8Bit() [1/3]

QString QString::fromLocal8Bit ( const char * str,
qsizetype size )
inlinestatic

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

If size is {-1}, {strlen(str)} is used instead.

{qstring-local-8-bit-equivalent} {fromUtf8}

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

Definition at line 675 of file qstring.h.

References fromLocal8Bit(), qstrlen(), and str.

+ Here is the call graph for this function:

◆ fromLocal8Bit() [2/3]

QString QString::fromLocal8Bit ( const QByteArray & str)
inlinestatic

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

Since
5.0

Returns a QString initialized with the 8-bit string str.

{qstring-local-8-bit-equivalent} {fromUtf8}

Note
: any null ('\0') bytes in the byte array will be included in this string, converted to Unicode null characters (U+0000). This behavior is different from Qt 5.x.

Definition at line 674 of file qstring.h.

References ba, and fromLocal8Bit().

Referenced by fromLocal8Bit().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fromLocal8Bit() [3/3]

QString QString::fromLocal8Bit ( QByteArrayView str)
static

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

Since
6.0

Returns a QString initialized with the 8-bit string str.

{qstring-local-8-bit-equivalent} {fromUtf8}

Note
: any null ('\0') bytes in the byte array will be included in this string, converted to Unicode null characters (U+0000).

Definition at line 5949 of file qstring.cpp.

References ba, QByteArray::isEmpty(), QByteArray::isNull(), QStringConverterBase::Stateless, QStringConverter::System, and toUtf16.

Referenced by DBusConnection::DBusConnection(), QT_BEGIN_NAMESPACE::DeviceIntegration::DeviceIntegration(), QEvdevKeyboardManager::QEvdevKeyboardManager(), QEvdevMouseManager::QEvdevMouseManager(), QEvdevTabletManager::QEvdevTabletManager(), QEvdevTouchManager::QEvdevTouchManager(), QEvdevTouchScreenHandler::QEvdevTouchScreenHandler(), QIBusPlatformInputContextPrivate::QIBusPlatformInputContextPrivate(), QMessagePattern::QMessagePattern(), QWindowsContext::QWindowsContext(), QXcbSessionManager::QXcbSessionManager(), QCoreApplicationPrivate::appName(), QCoreApplication::arguments(), argumentsFromCommandLineAndFile(), QmlTypeRegistrar::argumentsFromCommandLineAndFile(), QCupsPrinterSupport::availablePrintDeviceIds(), bluetoothdVersion(), QWindowsMimeText::convertToMime(), QWindowsMimeURI::convertToMime(), QtWaylandClient::QWaylandWindow::createDecoration(), QGuiApplicationPrivate::createPlatformIntegration(), QFile::decodeName(), QFile::decodeName(), QXcbScreen::defaultName(), QApplicationPrivate::desktopStyleKey(), deviceModelIdentifier(), QFFmpeg::err2str(), SharedTextureImageResponse::fallbackPath(), QZipReader::fileData(), QZipPrivate::fillFileInfo(), QStandardPaths::findExecutable(), findInPath(), QPlatformFontDatabase::fontDir(), QEglFSDeviceIntegration::framebufferIndex(), QFileDialogPrivate::getEnvironmentVariable(), QSSGShaderLibraryManager::getIncludeContents(), getLibraryProjectsInOutputFolder(), QXcbScreen::getName(), getPrefix(), QOpenXRSpaceExtension::getSemanticLabels(), QIBusPlatformInputContextPrivate::getSocketPath(), QXcbConnection::glIntegration(), importImp(), interfaceListing(), QWaylandQuickHardwareLayerPrivate::layerIntegration(), QWaylandCompositorPrivate::loadClientBufferIntegration(), QWaylandCompositorPrivate::loadServerBufferIntegration(), QV4::CompiledData::CompilationUnit::localCacheFilePath(), QLocalTime::localTimeAbbbreviationAt(), QHostInfoAgent::lookup(), QSysInfo::machineHostName(), main(), QHaikuClipboard::mimeData(), QProcessEnvironmentPrivate::nameToString(), QCupsPrintEnginePrivate::openPrintDevice(), Moc::parsePluginData(), QLibraryInfoPrivate::path(), populateFromPattern(), QApplicationPrivate::process_cmdline(), QCoreApplicationPrivate::processCommandLineArguments(), Q_TRACE_INSTRUMENT(), qEnvironmentVariable(), qTzName(), queryQtPaths(), quick_test_main_with_setup(), QLibInputTouch::registerDevice(), QPlatformInputContextFactory::requested(), QQuickStyleSpec::resolve(), Preprocessor::resolveInclude(), retrieveLabel(), runProcess(), runQmlImportScanner(), scanLangEnv(), searchIncludePaths(), dom::DataTransfer::setDataFromMimeData(), signAAB(), sm_performSaveYourself(), standardLibraryErrorString(), QStandardPaths::standardLocations(), QCupsPrinterSupport::staticDefaultPrintDeviceId(), QProcEnvValue::string(), systemThemeName(), QXcbIntegration::wmClass(), QSSGQmlUtilities::writeNodeProperties(), and QSSGQmlUtilities::writeQmlForAnimation().

+ Here is the call graph for this function:

◆ fromRawData()

QString QString::fromRawData ( const QChar * unicode,
qsizetype 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 is an example of how we can use a QRegularExpression on raw data in memory without requiring to copy the data into a QString:

static const QChar unicode[] = {
0x005A, 0x007F, 0x00A4, 0x0060,
0x1009, 0x0020, 0x0020};
qsizetype size = sizeof(unicode) / sizeof(QChar);
// ...
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 9482 of file qstring.cpp.

Referenced by QtCbor::ByteData::asQStringRaw(), QSvgPaintEngine::drawTextItem(), Widget::fromRawDataFunction(), QLocaleData::DataRange::getData(), QQmlMetaType::qmlType(), and QV4::CompiledData::Unit::stringAtInternal().

+ Here is the caller graph for this function:

◆ fromStdString()

◆ fromStdU16String()

QString QString::fromStdU16String ( const std::u16string & str)
inlinestatic
Since
5.5

{from-std-string} {UTF-16} {fromUtf16()}

See also
fromUtf16(), fromStdWString(), fromStdU32String()

Definition at line 1461 of file qstring.h.

References fromUtf16.

◆ fromStdU32String()

QString QString::fromStdU32String ( const std::u32string & str)
inlinestatic
Since
5.5

{from-std-string} {UCS-4} {fromUcs4()}

See also
fromUcs4(), fromStdWString(), fromStdU16String()

Definition at line 1467 of file qstring.h.

Referenced by qt_punycodeDecoder().

+ Here is the caller graph for this function:

◆ 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).

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

Definition at line 1458 of file qstring.h.

Referenced by windowTitle().

+ Here is the caller graph for this function:

◆ fromUcs4()

QString QString::fromUcs4 ( const char32_t * unicode,
qsizetype size = -1 )
static
Since
4.2
Deprecated
[6.0] Use the char32_t overload instead.
Since
5.3

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

If size is -1 (default), unicode must be \0'-terminated.

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

Definition at line 6077 of file qstring.cpp.

References QStringConverterBase::Stateless, toUtf16, and QStringConverter::Utf32.

Referenced by fromSQLTCHAR().

+ Here is the caller graph for this function:

◆ fromUtf16()

QString QString::fromUtf16 ( const char16_t * unicode,
qsizetype size = -1 )
static
Since
5.3 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 \0'-terminated.

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 *, qsizetype) or QString(const QChar *) if possible.

QString makes a deep copy of the Unicode data.

See also
utf16(), setUtf16(), fromStdU16String()
Deprecated
[6.0] Use the char16_t overload instead.

Definition at line 6045 of file qstring.cpp.

References QtPrivate::qustrlen(), QStringConverterBase::Stateless, toUtf16, and QStringConverter::Utf16.

Referenced by QPdfBookmarkModelPrivate::appendChildNode(), backendName(), backendName(), backendName(), byteArrayFromBuffer(), QtWaylandClient::convertData(), convertValue(), QRhiD3D11::create(), QPdfSearchModelPrivate::doSearch(), QRhiD3D::fillDriverInfo(), filterForFindUsages(), fromSQLTCHAR(), QPdfDocumentPrivate::getText(), QPdfDocument::metaData(), QPdfDocument::pageLabel(), QIcc::parseDesc(), QSSGBufferManager::runtimeMeshSourceName(), QSSGMesh::MeshInternal::Subset::toMeshSubset(), QPdfLinkModelPrivate::update(), and valueToKeySequence().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fromUtf8() [1/3]

QString QString::fromUtf8 ( const char * str,
qsizetype size )
inlinestatic

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

If size is {-1}, {strlen(str)} is used instead.

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.

This function can be used to process incoming data incrementally as long as all UTF-8 characters are terminated within the incoming data. Any unterminated characters at the end of the string will be replaced or suppressed. In order to do stateful decoding, please use \l QStringDecoder.

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

Definition at line 660 of file qstring.h.

References qstrlen().

+ Here is the call graph for this function:

◆ fromUtf8() [2/3]

QString QString::fromUtf8 ( const QByteArray & str)
inlinestatic

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

Since
5.0

Returns a QString initialized with the UTF-8 string str.

Note
: any null ('\0') bytes in the byte array will be included in this string, converted to Unicode null characters (U+0000). This behavior is different from Qt 5.x.

Definition at line 659 of file qstring.h.

References ba, and fromUtf8().

Referenced by fromUtf8().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fromUtf8() [3/3]

QString QString::fromUtf8 ( QByteArrayView str)
static

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

Since
6.0

Returns a QString initialized with the UTF-8 string str.

Note
: any null ('\0') bytes in the byte array will be included in this string, converted to Unicode null characters (U+0000).

Definition at line 6018 of file qstring.cpp.

References ba, QUtf8::convertToUnicode(), QByteArray::isEmpty(), and QByteArray::isNull().

Referenced by QQmlJS::Dom::PathEls::Current::Current(), KeyEvent::KeyEvent(), QQnxClipboard::MimeData::MimeData(), QDBusError::QDBusError(), QIconCacheGtkReader::QIconCacheGtkReader(), QIOSIntegration::QIOSIntegration(), QnxAudioDeviceInfo::QnxAudioDeviceInfo(), QPulseAudioDeviceInfo::QPulseAudioDeviceInfo(), QQnxScreen::QQnxScreen(), QQuickVisualTestUtils::QQuickApplicationHelper::QQuickApplicationHelper(), QQuickGridScaledImage::QQuickGridScaledImage(), QUtcTimeZonePrivate::QUtcTimeZonePrivate(), QUtcTimeZonePrivate::QUtcTimeZonePrivate(), QWasmAudioDevice::QWasmAudioDevice(), QWindowContainer::QWindowContainer(), QQmlJS::Dom::PathEls::Root::Root(), _q_lower(), _q_upper(), QFontconfigDatabase::addApplicationFont(), QFFmpegMetaData::addEntry(), QJUnitTestLogger::addIncident(), QTapTestLogger::addIncident(), QDBusServer::address(), QT_BEGIN_NAMESPACE::addTagToMetaData(), QQuickDesignerSupportProperties::allPropertyNames(), QtObject::atob(), QMediaFormat::audioCodecDescription(), QMediaFormat::audioCodecName(), AVFMediaPlayer::audioOutputChanged(), QWindowsMediaDeviceSession::audioOutputDeviceChanged(), availableDevices(), QSSGRhiContextStats::beginRenderPass(), blockMemberObject(), calculatePosixTransitions(), QTextMarkdownImporter::cbEnterSpan(), QTextMarkdownImporter::cbText(), QQuickDesignerSupportPropertyChanges::changeExpression(), QQuickDesignerSupportPropertyChanges::changeValue(), QQuickDesignerSupportStates::changeValueInRevertList(), checkForDrmPermission(), QNetworkReplyHttpImplPrivate::checkForRedirect(), checkRegistration(), WorkspaceHandlers::clientInitialized(), QRhiD3D11::compileHlslShaderSource(), QV4::ExecutionEngine::compileModule(), convertFromEnum(), QMacMimeAny::convertToMime(), QMacMimeUnicodeText::convertToMime(), QWindowsMimeHtml::convertToMime(), QV4::QQmlValueTypeWrapper::create(), QV4::QQmlValueTypeWrapper::create(), QQmlCppBinding::createBindingForBindable(), QQmlCppBinding::createBindingForNonBindable(), QV4::Script::createFromFileOrCache(), createQQmlType(), createQQmlType(), createQQmlType(), createQQmlType(), createQQmlType(), QKmsDevice::createScreenForConnector(), QQmlCppBinding::createTranslationBindingForBindable(), QQmlCppBinding::createTranslationBindingForNonBindable(), QGtk3FontDialogHelper::currentFont(), QDBusMarshaller::currentSignature(), QDBusDemarshaller::currentSignature(), QQmlTableModel::data(), QMYSQLResult::data(), QPSQLResult::data(), QuickTestResult::dataTag(), QPSQLResultPrivate::deallocatePreparedStmt(), QFontconfigDatabase::defaultFont(), QPpdPrintDevice::defaultPageSize(), QQmlBinding::dependencies(), QFFmpeg::deviceTypes(), TextSynchronization::didDidChangeTextDocument(), TextSynchronization::didOpenTextDocument(), QGtk3FileDialogHelper::directory(), QTranslatorPrivate::do_load(), AVFImageCapture::doCapture(), doRegisterTypeAndRevisions(), QNetworkReplyWasmImplPrivate::downloadFailed(), doWriteProperties(), doWriteProperties(), doWriteProperties(), QmlLsp::OpenDocumentSnapshot::dump(), QGraphicsFrameCaptureRenderDoc::endCaptureFrame(), QPcsc::errorMessage(), QSQLiteResult::exec(), QTestLog::failOnWarning(), QFontconfigDatabase::fallbacksForFamily(), QQuickFontValueType::features(), QImageCapture::fileFormatDescription(), QMediaFormat::fileFormatDescription(), QImageCapture::fileFormatName(), QMediaFormat::fileFormatName(), QZipPrivate::fillFileInfo(), QComposeInputContext::filterEvent(), QmlLsp::QQmlCodeModel::findFilePathsFromFileNames(), QQmlContextData::findObjectId(), QMYSQLDriver::formatValue(), QDBusMessagePrivate::fromDBusMessage(), QUrl::fromEncoded(), QUrl::fromPercentEncoding(), fromSQLTCHAR(), AssimpUtils::generateMeshData(), QCacheUtils::getCachedFilename(), getCurrentTimeString(), QQuickDragEvent::getDataAsString(), getDefaultWinId(), getDeviceABI(), KeyboardModifier::getForEvent< EmscriptenKeyboardEvent >(), getIBaseError(), QSSGQmlUtilities::getIdForAnimation(), QSSGQmlUtilities::getIdForNode(), getImageFormatList(), getLockInfo_helper(), QXcbScreen::getOutputName(), QQuickDesignerSupportPropertyChanges::getProperty(), getRequestedDisplays(), QNearFieldTargetPrivateImpl::getTagTechnology(), OpenXRHelpers::getXrResultAsString(), QIBaseResult::gotoNext(), groupsToString(), gtkSetting(), handle_sqlite_callback(), QOpenGLDebugLoggerPrivate::handleMessage(), QQmlXMLHttpRequest::header(), QQmlXMLHttpRequest::headers(), QQuick3DPhysicsHeightField::heightField(), QQmlTranslation::QsTrData::idForQmlDebug(), QQmlTranslation::QsTrIdData::idForQmlDebug(), QTestLog::ignoreMessage(), QTlsPrivate::X509CertificateSchannel::importPkcs12(), QQmlPluginImporter::importPlugins(), QWaylandInputMethodEventBuilder::indexFromWayland(), QTestLog::info(), QQuickAnimatedImagePrivate::infoForCurrentFrame(), QFontEngineFT::init(), QQmlPrivate::AOTCompiledContext::initGetEnumLookup(), VDMAbstractItemModelDataType::initializeConstructor(), QQDMIncubationTask::initializeRequiredProperties(), QQmlDelegateModelPartsMetaObject::initialValue(), QQmlDataTest::initTestCase(), QSettingsPrivate::iniUnescapedKey(), inOutObject(), QWidgetTextControl::insertFromMimeData(), QQuickTextControl::insertFromMimeData(), Grammar::intern(), QPageSize::key(), keyValueMapsLocation(), QLocale::languageToString(), QQmlJSLinter::lintFile(), QQmlSettingsPrivate::load(), QQuickTextDocumentPrivate::load(), QDefaultOutputMapping::load(), QKmsScreenConfig::loadConfig(), QPpdPrintDevice::loadPageSizes(), loadTzTimeZones(), QBasicPlatformVulkanInstance::loadVulkanLibrary(), QV4::CompiledData::CompilationUnit::localCacheFilePath(), QOpenGLDebugLogger::loggedMessages(), QXkbCommon::lookupString(), QXkbCommon::lookupStringNoKeysymTransformations(), lookupVendorIdInSystemDatabase(), main(), main(), makeCacheKey(), QShaderDescriptionPrivate::makeDoc(), QV4DebugServiceImpl::messageReceived(), QQmlDebugMessageClient::messageReceived(), QQmlVMEMetaObject::metaCall(), QQmlJSCodeGenerator::metaTypeFromName(), QV4Include::method_include(), QV4::ArrayBufferPrototype::method_toString(), QV4::UrlSearchParamsPrototype::method_toString(), QV4::QQmlValueTypeWrapper::method_toString(), QXcbMime::mimeConvertToFormat(), QXcbMime::mimeDataForAtom(), mmErrorMessage(), QQmlLoggingCategory::name(), QQmlProperty::name(), QQmlJS::Dom::PathEls::Root::name(), QQmlJS::Dom::PathEls::Current::name(), QQnxCamera::name(), QQmlPropertyData::name(), QmlLsp::QQmlCodeModel::newDocForOpenFile(), QV4::QObjectWrapperOwnPropertyKeyIterator::next(), QV4::QQmlValueTypeWrapperOwnPropertyKeyIterator::next(), QV4::QObjectWrapper::objectToString(), onTimedTextChangedNative(), QQmlJSTypeReader::operator()(), operator+(), operator+(), operator<<(), QCborMap::operator[](), outputStreamStateCallback(), QSSGQmlUtilities::outputTextureAsset(), QEdidParser::parse(), QPluginParsedMetaData::parse(), parseCmakeBoolean(), QGeoTiledMappingManagerEngineNokia::parseNewVersionInfo(), QNetworkCookiePrivate::parseSetCookieHeaderLine(), parseTestArgs(), QPdfDocument::password(), CompletionRequest::patchInvalidFileForParser(), populateFromPattern(), QDBusConnectionPrivate::prepareHook(), QQmlMetaType::prettyTypeName(), QQmlRenameSymbolSupport::process(), QGstreamerAudioDecoder::processBusMessage(), QGstreamerMediaPlayer::processBusMessage(), QGstreamerMediaEncoder::processBusMessage(), QSvgHandler::processingInstruction(), QDBusAbstractInterfacePrivate::property(), QQmlPropertyMapMetaObject::propertyCreated(), propertyNameListForWritableProperties(), ModelNodeMetaObject::propertyWritten(), pullFiles(), Q_LOGGING_CATEGORY(), qCompileJSFile(), qCompileQmlFile(), qDBusGenerateClassDefXml(), qDBusGenerateMetaObjectXml(), qDBusInterfaceFromClassDef(), qEnvironmentVariable(), qMakeError(), qMakeError(), QQmlTypeLoader::qmldirContent(), qmlProtectModule(), QQmlEngine::qmlRegisterModuleImport(), QQmlEngine::qmlUnregisterModuleImport(), qSaveQmlJSUnitAsCpp(), qt_fontFromString(), qt_fontToString(), qToField(), qtValue(), queryQtPaths(), quick_test_main_with_setup(), QQmlDataBlob::SourceCodeData::readAll(), readArrayBuffer(), QJpegHandlerPrivate::readJpegHeader(), QPngHandlerPrivate::readPngTexts(), QPSQLResult::record(), QMYSQLDriver::record(), AliasRegistrar::registerAliases(), QQmlMetaType::registerCompositeSingletonType(), QQmlMetaType::registerCompositeType(), QLibInputTouch::registerDevice(), QQmlMetaType::registerSequentialContainer(), QQmlMetaType::registerSingletonType(), QQmlMetaType::registerType(), QQuickDesignerSupportPropertyChanges::removeProperty(), QQmlBaseModule< RequestType >::requestHandler(), QQuickDesignerSupportStates::resetStateProperty(), QFontconfigDatabase::resolveFontFamilyAlias(), retrieveLabelViaIoctl(), QMimeDataPrivate::retrieveTypedData(), QSGRhiSupport::rhiBackendName(), rolesToString(), runRcc(), runUic(), QDeviceDiscoveryUDev::scanConnectedDevices(), QLocale::scriptToString(), QGtk3FileDialogHelper::selectedFiles(), QTimeZonePrivate::serialize(), QUtcTimeZonePrivate::serialize(), serializeBlockMemberVar(), QQmlTranslation::QsTrData::serializeForQmltc(), QQmlTranslation::QsTrIdData::serializeForQmltc(), serializeInOutVar(), serverInfoCallback(), QWindowsMediaDeviceSession::setActive(), QWindowsMediaDeviceSession::setAudioOutput(), QPSQLDriverPrivate::setByteaOutput(), QGstreamerCamera::setCamera(), QQmlSslConfiguration::setCiphersList(), QDBusConnectionPrivate::setConnection(), QQmlTableModel::setData(), QPSQLDriverPrivate::setDatestyle(), setMaterialProperties(), QXcbScreen::setMonitor(), QDBusAbstractInterfacePrivate::setProperty(), QV4::QObjectWrapper::setProperty(), QQuickTableViewPrivate::setRequiredProperty(), QQuick3DRenderStats::setRhiContext(), QTextBrowserPrivate::setSource(), setStreamURL(), settings_key_to_host_name(), QPSQLDriverPrivate::setUtcTimeZone(), QtWaylandClient::QWaylandWindow::setWindowTitle(), QXcbWindow::setWindowTitle(), QQmlPropertyCache::signalParameterStringForJS(), QQmlEnginePrivate::singletonInstance(), sinkInfoCallback(), QQmlBinding::slowWrite(), sourceInfoCallback(), QAndroidAudioDecoder::start(), QQmlJS::Dom::FormatTextStatus::stateToString(), QQmlSettingsPrivate::store(), QQmlProfilerEvent::string(), DynamicRoleModelNode::sync(), QLocale::territoryToString(), ArgumentDef::toJson(), FunctionDef::toJson(), PropertyDef::toJson(), ClassDef::toJson(), EnumDef::toJson(), QGString::toQString(), VDMListDelegateDataType::toQString(), QBasicUtf8StringView< UseChar8T >::toString(), QAsn1Element::toString(), QtCbor::ByteData::toUtf8String(), toVariant(), QV4::SequencePrototype::toVariant(), QCoreApplication::translate(), QWaylandInputMethodEventBuilder::trimmedIndexFromWayland(), QNdefNfcTypeRecord::typeInfo(), QuickTestUtil::typeName(), QQmlBaseModule< RequestType >::updatedSnapshot(), QV4::Function::updateInternalClass(), QQuickDesignerSupportStates::updateStateBinding(), QQuickControlsTestUtils::QQuickStyleHelper::updateStyle(), QmlLsp::QQmlCodeModel::url2Path(), CompletionRequest::urlAndPos(), QQmlPropertyPrivate::urlSequence(), QCborMap::value(), VDMAbstractItemModelDataType::value(), QSSGQmlUtilities::valueToQml(), QQuickFontValueType::variableAxes(), vasprintf(), QV4::CompiledData::Unit::verifyHeader(), QMediaFormat::videoCodecDescription(), QMediaFormat::videoCodecName(), QTestLog::warn(), QX11CapturableWindows::windows(), QXcbWindow::windowTitle(), QQmlPropertyPrivate::write(), RCCFileInfo::writeDataBlob(), QSSGQmlUtilities::writeNodeProperties(), and QShaderDescriptionPrivate::writeToStream().

+ Here is the call graph for this function:

◆ fromWCharArray()

QT_WARNING_POP QString QString::fromWCharArray ( const wchar_t * string,
qsizetype size = -1 )
inlinestatic
Since
4.2

Returns a copy of the string, where the encoding of string depends on the size of wchar. If wchar is 4 bytes, the string is interpreted as UCS-4, if wchar is 2 bytes it is interpreted as UTF-16.

If size is -1 (default), the string must be '\0'-terminated.

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

Definition at line 1309 of file qstring.h.

Referenced by QWindowsMediaDevices::QWindowsMediaDevices(), QWindowsPrintDevice::QWindowsPrintDevice(), QSystemLocalePrivate::amText(), QCoreApplication::arguments(), QWindowsPrintDevice::availablePrintDeviceIds(), childKeysOrGroups(), QWindowsMimeRegistry::clipboardFormatName(), QWindowsFontEngine::cloneWithSize(), convertCharArray(), QBuiltInMimes::convertToMime(), QWindowsMimeText::convertToMime(), QWindowsMimeURI::convertToMime(), QWindowsFontDatabase::createEngine(), QSystemLocalePrivate::currencySymbol(), QMimerSQLResult::data(), QWindowsFontDatabase::debugFormat(), QWindowsPrintDevice::defaultPrintDeviceId(), QWindowsTabletSupport::description(), GpuDescription::detect(), QWin32PrintEngine::drawTextItem(), findInPath(), QSystemLocalePrivate::firstDayOfWeek(), QWindowsDirect2DPaintEnginePrivate::fontFaceFromFontEngine(), getCompositionString(), getDevice(), getString(), QFFmpegWindowCaptureUwp::Grabber::grabFrame(), QWindowsSystemProxy::init(), QConfFileSettingsPrivate::initAccess(), QWindowsFontEngine::initFontInfo(), QFFmpegWindowCaptureUwp::Grabber::initializeGrabbingContext(), interfaceListing(), isCapturableWindow(), QWindowsPrintDevice::loadInputSlots(), QWindowsPrintDevice::loadPageSizes(), QWindowsFontDatabaseBase::LOGFONT_to_QFont(), QHostInfoAgent::lookup(), mailCommand(), monitorData(), QSystemLocalePrivate::monthName(), msgBeginFailed(), CMMNotificationClient::OnDeviceAdded(), CMMNotificationClient::OnDeviceRemoved(), CMMNotificationClient::OnDeviceStateChanged(), openWebBrowser(), operator<<(), QSystemLocalePrivate::pmText(), populateBitmapFonts(), populateFontFamilies(), populateFontFamilies(), FileOperationProgressSink::PostDeleteItem(), Q_TRACE_INSTRUMENT(), qAppFileName(), qMakeError(), qSystemDirectory(), qt_QStringFromHString(), QWinSettingsPrivate::readKey(), readLink(), readSymLink(), QMimerSQLResult::record(), QWin32PrintEngine::setGlobalDevMode(), setMonitorDataFromSetupApi(), storeFont(), storeFont(), stringFromOutLineTextMetric(), QWindowsThemeCache::themeName(), QQC2::QWindowsXPStylePrivate::themeName(), QSystemLocalePrivate::toCurrencyString(), QSystemLocalePrivate::toString(), QSystemLocalePrivate::toString(), QSystemLocalePrivate::uiLanguages(), QWinRegistryKey::value(), winIso3116CtryName(), winIso639LangName(), and QSystemLocalePrivate::zeroDigit().

◆ front() [1/2]

QChar & QString::front ( )
inline
Since
5.10

Returns a reference to the first character in the string. Same as {operator[](0)}.

This function is provided for STL compatibility.

Warning
Calling this function on an empty string constitutes undefined behavior.
See also
back(), at(), operator[]()

Definition at line 1347 of file qstring.h.

◆ front() [2/2]

QChar QString::front ( ) const
inline
Since
5.10

Returns the first character in the string. Same as {at(0)}.

This function is provided for STL compatibility.

Warning
Calling this function on an empty string constitutes undefined behavior.
See also
back(), at(), operator[]()

Definition at line 230 of file qstring.h.

References at.

Referenced by QQmlJSImportVisitor::endVisit(), QQmlJSImportVisitor::isImportPrefix(), QPlatformTheme::removeMnemonics(), replace(), QFileInfoGatherer::run(), uuidFromString(), QQmlJSImportVisitor::visit(), QQmlJSImportVisitor::visit(), and QColorOutput::writePrefixedMessage().

+ Here is the caller graph for this function:

◆ indexOf() [1/3]

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

{qstring-first-index-of} {string} {str}

{search-comparison-case-sensitivity} {search}

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

negative-index-start-search-from-end

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

Definition at line 4482 of file qstring.cpp.

References QtPrivate::findString(), size(), str, and unicode().

+ Here is the call graph for this function:

◆ indexOf() [2/3]

qsizetype QString::indexOf ( QLatin1StringView str,
qsizetype from = 0,
Qt::CaseSensitivity cs = Qt::CaseSensitive ) const
Since
4.5

} {qstring-first-index-of} {Latin-1 string viewed by} {str}

{search-comparison-case-sensitivity} {search}

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

negative-index-start-search-from-end

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

Definition at line 4517 of file qstring.cpp.

References QtPrivate::findString(), and str.

Referenced by IssueLocationWithContext::IssueLocationWithContext(), QQuickGridScaledImage::QQuickGridScaledImage(), QTextHtmlImporter::QTextHtmlImporter(), QTextEngine::calculateTabWidth(), QDir::cd(), QDBusPendingCallPrivate::checkReceivedSignature(), cleanPackageName(), QMimeType::comment(), convertToAscii(), QFileSystemEngine::currentPath(), dataToUrls(), QQuickScriptActionPrivate::debugAction(), decodeFsEncString(), QQC2::QWindowsXPStyle::drawControl(), QItemDelegate::drawDisplay(), QFontMetrics::elidedText(), QFontMetricsF::elidedText(), QSQLiteDriver::escapeIdentifier(), QQmlCustomParser::evaluateEnum(), findInBlock(), Widget::firstIndexOfFunction(), language::formatConnection(), QSslCertificate::fromPath(), getBinaryRPaths(), QSSGShaderKeyPropertyBase::getBoolValue(), QDirPrivate::getFilterSepChar(), getLibraryProjectsInOutputFolder(), QSQLiteDriverPrivate::getTableInfo(), QFontMetrics::horizontalAdvance(), QFontMetrics::horizontalAdvance(), QFontMetricsF::horizontalAdvance(), QFontMetricsF::horizontalAdvance(), Widget::index(), Widget::indexOfFunction(), QSslSocketPrivate::isMatchingHostname(), QMenuBar::keyPressEvent(), launchMail(), loadTzTimeZones(), QHostInfo::localDomainName(), lookupVendorIdInSystemDatabase(), make_default_icon_name_from_mimetype_name(), QV4::StringPrototype::method_replace(), QV4::StringPrototype::method_split(), mightBeRichTextImpl(), QKeySequence::mnemonic(), nextField(), QDB2Driver::open(), parseAttributeValues(), QTestPrivate::parseBlackList(), QTextHtmlParser::parseExclamationTag(), DocumentFile::parseFromAnyUri(), Parser::parseInstrument(), Parser::parseMetadata(), Parser::parseParamReplace(), Parser::parsePoint(), Parser::parsePrefix(), parseVersion(), parseVersion(), QQmlMetaType::qmlType(), qQmlJSGenerateLoader(), qt_getImageTextFromDescription(), qt_setWindowTitle_helperHelper(), queryQtPaths(), readGradleProperties(), QConfFileSettingsPrivate::readIniFile(), QQuickFileDialogDelegate::setFile(), QUrlPrivate::setHost(), Utils::TextDocument::setPlainText(), QUndoCommand::setText(), TileProvider::setupProvider(), QQuickTextPrivate::setupTextLayout(), QUrlPrivate::setUserInfo(), QSQLiteDriver::stripDelimiters(), tokenizeLine(), tryDriveUNCFallback(), QMenuPrivate::updateActionRects(), QAuthenticatorPrivate::updateCredentials(), QQuickTextPrivate::updateLayout(), QMacMimeUnicodeText::utiForMime(), and src_gui_text_qsyntaxhighlighter::MyHighlighter::wrapper().

+ Here is the call graph for this function:

◆ indexOf() [3/3]

qsizetype QString::indexOf ( QStringView s,
qsizetype from = 0,
Qt::CaseSensitivity cs = Qt::CaseSensitive ) const
inlinenoexcept

Definition at line 294 of file qstring.h.

References QtPrivate::findString().

+ Here is the call graph for this function:

◆ insert() [1/8]

QT_ASCII_CAST_WARN QString & QString::insert ( qsizetype i,
const char * s )
inline

Definition at line 869 of file qstring.h.

References i, and insert().

+ Here is the call graph for this function:

◆ insert() [2/8]

QT_ASCII_CAST_WARN QString & QString::insert ( qsizetype i,
const QByteArray & s )
inline

Definition at line 871 of file qstring.h.

References i, and insert().

+ Here is the call graph for this function:

◆ insert() [3/8]

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

Definition at line 3105 of file qstring.cpp.

References copy(), d, i, insert(), insert_helper(), and QtPrivate::q_points_into_range().

+ Here is the call graph for this function:

◆ insert() [4/8]

QString & QString::insert ( qsizetype i,
const QString & s )
inline

Definition at line 466 of file qstring.h.

References i, and insert().

Referenced by insert().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ insert() [5/8]

◆ insert() [6/8]

QString & QString::insert ( qsizetype i,
QLatin1StringView s )

Definition at line 3025 of file qstring.cpp.

References i, insert_helper(), and str.

+ Here is the call graph for this function:

◆ insert() [7/8]

QString & QString::insert ( qsizetype i,
QStringView v )
inline

Definition at line 467 of file qstring.h.

References i, and insert().

Referenced by insert().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ insert() [8/8]

QString & QString::insert ( qsizetype i,
QUtf8StringView s )

Definition at line 3048 of file qstring.cpp.

References append(), QUtf8::convertToUnicode(), d, QArrayData::GrowsAtEnd, i, insert_helper(), needsReallocate(), other(), Q_CHECK_PTR(), Q_UNLIKELY, resize(), size(), and swap().

+ Here is the call graph for this function:

◆ isDetached()

bool QString::isDetached ( ) const
inline

Definition at line 1250 of file qstring.h.

References d.

Referenced by QStringAlgorithms< StringType >::simplified_helper(), and QStringAlgorithms< StringType >::trimmed_helper().

+ Here is the caller graph for this function:

◆ isEmpty()

bool QString::isEmpty ( ) const
inlinenoexcept

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 192 of file qstring.h.

References d.

Referenced by QQmlJSCodeGenerator::AccumulatorConverter::AccumulatorConverter(), QtFontStyle::Key::Key(), QAndroidPlatformIconEngine::QAndroidPlatformIconEngine(), QConfFileSettingsPrivate::QConfFileSettingsPrivate(), QDBusMenuItem::QDBusMenuItem(), QEvdevKeyboardManager::QEvdevKeyboardManager(), QEvdevMouseManager::QEvdevMouseManager(), QEvdevTabletManager::QEvdevTabletManager(), QEvdevTouchManager::QEvdevTouchManager(), QEvdevTouchScreenHandler::QEvdevTouchScreenHandler(), QFileDialogArgs::QFileDialogArgs(), QGeoUriProvider::QGeoUriProvider(), QGraphicsTextItem::QGraphicsTextItem(), QKmsDevice::QKmsDevice(), QLeDBusAdvertiser::QLeDBusAdvertiser(), QMacSettingsPrivate::QMacSettingsPrivate(), QNetworkReplyFileImpl::QNetworkReplyFileImpl(), QPlaceManagerEngineNokiaV2::QPlaceManagerEngineNokiaV2(), QQuickGridScaledImage::QQuickGridScaledImage(), QSSGShaderCache::QSSGShaderCache(), QWasmIDBSettingsPrivate::QWasmIDBSettingsPrivate(), QWin32PrintEngine::QWin32PrintEngine(), QWinSettingsPrivate::QWinSettingsPrivate(), QDBusMenuConnection::~QDBusMenuConnection(), QQmlInfo::~QQmlInfo(), QQuickQmlGenerator::~QQuickQmlGenerator(), QSSGShaderCache::~QSSGShaderCache(), QWindowsFontEngine::~QWindowsFontEngine(), QWindowsFontEngineDirectWrite::~QWindowsFontEngineDirectWrite(), QQmlApplicationEnginePrivate::_q_loadTranslations(), QPrintPreviewDialogPrivate::_q_print(), QMessageBox::aboutQt(), QHstsStore::absoluteFilePath(), CPP::WriteInitialization::acceptActionRef(), CustomWidgetsInfo::acceptCustomWidget(), CPP::WriteInitialization::acceptLayoutItem(), CPP::WriteDeclaration::acceptUI(), CPP::WriteInitialization::acceptUI(), CPP::WriteInitialization::acceptWidget(), DatabaseInfo::acceptWidget(), QWindowsMediaDeviceReader::activate(), QTextBrowserPrivate::activateAnchor(), QWidgetTextControlPrivate::activateLinkUnderCursor(), QQuickTextControlPrivate::activateLinkUnderCursor(), QMessageBox::addButton(), QQmlJSImportVisitor::addDefaultProperties(), QFileDialogPrivate::addDefaultSuffixToFiles(), QFileDialogPrivate::addDefaultSuffixToUrls(), QIcon::addFile(), QQmlImports::addFileImport(), addFontToDatabase(), addFontToDatabase(), QQmlJSCodeGenerator::addInclude(), Parser::addIncludesRecursive(), addKey(), QQmlJS::Dom::LineWriter::addNewlinesAutospacerCallback(), QFileSystemModelPrivate::addNode(), QCommandLineParser::addPositionalArgument(), addressLine(), QPainterPath::addText(), QQuickTextNodeEngine::addTextBlock(), QQuickPathText::addToPath(), QWidgetLineControl::allSelected(), QQuickTextInputPrivate::allSelected(), QQuickTextPrivate::anchorAt(), annotateListElements(), QUrlPrivate::appendHost(), QT_BEGIN_NAMESPACE::appendOrganizationAndApp(), appendOrganizationAndApp(), appendOrganizationAndApp(), appendOrganizationAndApp(), QQmlJSLinter::applyFixes(), QCoreApplicationPrivate::appName(), argumentsFromCommandLineAndFile(), QmlTypeRegistrar::argumentsFromCommandLineAndFile(), QNetworkAccessManagerPrivate::authenticationRequired(), QAbstractGeoTileCache::baseCacheDirectory(), QQuickContext2DImageTexture::beginPainting(), bestStyle(), QFontDatabase::bold(), QPainter::boundingRect(), QPainter::boundingRect(), QSvgGradientStyle::brush(), buildMatchRule(), QQmlPropertyCacheCreator< ObjectContainer >::buildMetaObjectRecursively(), QProcEnvValue::bytes(), QAbstractFileIconEngine::cacheKey(), QWindowsFileIconEngine::cacheKey(), QNetworkAccessAuthenticationManager::cacheProxyCredentials(), QAuthenticatorPrivate::calculateResponse(), GeoRoutingManagerEngineEsri::calculateRoute(), QWindowsMimeHtml::canConvertFromMime(), QDBusAbstractInterfacePrivate::canMakeCalls(), QQuickTextInput::canPaste(), QQmlJSTypeResolver::canPrimitivelyConvertFromTo(), DocumentFile::canRead(), QTextMarkdownImporter::cbEnterSpan(), QDir::cd(), QQmlJSUtils::changeHandlerProperty(), QDomBuilder::characters(), QQmlJSImportVisitor::checkDeprecation(), checked_var_value(), QAbstractItemViewPrivate::checkMouseMove(), QQmlJSImportVisitor::checkRequiredProperties(), QPlaceManagerEngineMapbox::childCategories(), QPlaceManagerEngineMapbox::childCategoryIds(), cleanAndroidFiles(), QNetworkRequestFactory::clearPassword(), QNetworkRequestFactory::clearUserName(), QWindowsFontEngine::cloneWithSize(), QWindowsFontEngineDirectWrite::cloneWithSize(), QCupsPrintEnginePrivate::closePrintDevice(), codesignFile(), Collector::collect(), comify(), QIBusPlatformInputContext::commit(), QtWaylandClient::QWaylandTextInputv2::commit(), QQmlJS::Dom::LineWriter::commitLine(), QQuickFolderListModel::componentComplete(), QDeclarativeGeoServiceProvider::componentComplete(), QBluetoothSocketPrivateBluezDBus::connectToServiceHelper(), QPlaceManagerEngineNokiaV2::constructIconUrl(), QQmlJSCodeGenerator::conversion(), QWindowsMimeURI::convertFromMime(), QMacMimeFileUri::convertFromMime(), QMacMimeUrl::convertFromMime(), QQmlJSCodeGenerator::convertStored(), convertToExtendedType(), QQuick3DPhysicsMesh::convexMesh(), copyAndroidSources(), copyPackage(), QXcbWindow::create(), QQmlPreviewFileEngineHandler::create(), WindowCreationData::create(), QNetworkAccessFileBackendFactory::create(), QtObject::createComponent(), createImageNode(), QWindowsFileDialogHelper::createNativeDialog(), QCupsPrinterSupport::createNativePrintEngine(), createRcc(), QUndoGroup::createRedoAction(), QNetworkAccessManager::createRequest(), QSGRhiSupport::createRhi(), QUndoGroup::createUndoAction(), createUseNode(), QWasmVideoOutput::createVideoElement(), QCalendarBackend::dateTimeToString(), QCss::StyleSelector::declarationsForNode(), QV4::Compiler::Codegen::defineFunction(), QSqlTableModel::deleteRowFromTable(), QAndroidInputContext::deleteSurroundingText(), deploy(), QCapturableWindow::description(), QColorSpace::description(), QtAndroidAccessibility::descriptionForInterface(), QCommandLinkButtonPrivate::descriptionHeight(), QQmlJSRegisterContent::descriptiveName(), QUnicodeTables::detachAndConvertCase(), QQuickTextPrivate::determineHorizontalAlignment(), QFileDialog::directory(), QTranslatorPrivate::do_load(), QTextBrowserPrivate::documentModified(), Decoder::doDecode(), QPdfSearchModelPrivate::doSearch(), QNetworkReplyWasmImplPrivate::doSendRequest(), QCtfLibImpl::doTracepoint(), QTextDocumentLayoutPrivate::drawBlock(), QQC2_NAMESPACE::QMacStyle::drawControl(), QQC2::QCommonStyle::drawControl(), QMacStyle::drawControl(), QCommonStyle::drawControl(), QWindows11Style::drawControl(), QItemDelegate::drawDisplay(), QStyle::drawItemText(), QQC2::QStyle::drawItemText(), QPainter::drawText(), dump(), QQmlJS::Dom::ErrorMessage::dump(), QQuickStylePrivate::effectiveStyleName(), QQuickComboBoxPrivate::effectiveTextRole(), QQmlJSImportVisitor::endVisit(), QIconLoader::ensureInitialized(), QQmlJS::Dom::LineWriter::ensureNewline(), QQmlJS::Dom::LineWriter::ensureSpace(), QQmlJS::Dom::LineWriter::ensureSpace(), QDBusMessage::errorMessage(), QUrl::errorString(), QLibrary::errorString(), QImageReader::errorString(), QCommandLineParser::errorText(), QDB2Driver::escapeIdentifier(), QIBaseDriver::escapeIdentifier(), QMimerSQLDriver::escapeIdentifier(), QMYSQLDriver::escapeIdentifier(), QODBCDriver::escapeIdentifier(), QPSQLDriver::escapeIdentifier(), QSQLiteDriver::escapeIdentifier(), QOCIDriver::escapeIdentifier(), QMenu::event(), QFontDef::exactMatch(), QSqlTableModelPrivate::exec(), QWindowsXpNativeFileDialog::existingDirCallback(), DocumentFile::exists(), QPlatformFontDatabase::fallbacksForFamily(), QCoreTextFontDatabase::fallbacksForFamily(), QFontconfigDatabase::fallbacksForFamily(), QIconLoader::fallbackThemeName(), QFontDatabase::families(), QNetworkAccessAuthenticationManager::fetchCachedCredentials(), QNetworkAccessAuthenticationManager::fetchCachedProxyCredentials(), QLibrary::fileName(), FolderIterator::fileType(), QHttpNetworkConnectionPrivate::fillPipeline(), QHttpNetworkConnectionPrivate::fillPipeline(), QQmlDataBlob::finalUrlString(), QStandardPaths::findExecutable(), QmlLsp::QQmlCodeModel::findFilePathsFromFileNames(), QQuickVisualTestUtils::findItem(), QQuickVisualTestUtils::findItems(), findMinGWRuntimePaths(), QLibraryStore::findOrCreate(), findQtPlugins(), findScopeOfSpecialItems(), findSharedLibraries(), findTextEntry(), QDomNode::firstChildElement(), fixedXmlName(), QFontDatabase::font(), QGtk3Interface::font(), QWindowsFontEngineDirectWrite::fontNameSubstitute(), foreach(), QQuickControlsTestUtils::forEachControl(), QPrintDevice::format(), formatInputMethodEvent(), formatLogMessage(), QWindowsMimeHtml::formatsForMime(), QQmlJS::Dom::QmldirFile::fromPathAndCode(), QUrl::fromUserInput(), QQuickStatePrivate::generateActionList(), QQmlJSCodeGenerator::generateEnumLookup(), QQuickQmlGenerator::generateImageNode(), QMimeDatabasePrivate::genericIcon(), QMimeType::genericIconName(), QColorDialog::getColor(), QFontDialogPrivate::getFont(), getIBaseError(), QSSGQmlUtilities::getIdForAnimation(), getSelectedText(), QQmlSslKey::getSslKey(), getWinLocaleName(), QRawFont::glyphIndexesForString(), QFileDialogPrivate::goToDirectory(), QtWayland::HardwareIntegration::hardware_integration_bind_resource(), QDomImplementation::hasFeature(), QSvgNode::hasFilter(), QSSGRenderModel::hasLightmap(), QSvgNode::hasMarkerEnd(), QSvgNode::hasMarkerMid(), QSvgNode::hasMarkerStart(), QSvgNode::hasMask(), QQuickDropAreaPrivate::hasMatchingKey(), QQmlTypeLoaderQmldirContent::hasRedirection(), QWidgetLineControl::hasSelectedText(), QQuickTextInputPrivate::hasSelectedText(), QQuickIconLabelPrivate::hasText(), Driver::headerFileName(), QQuick3DPhysicsHeightField::heightField(), QFileDialogPrivate::helperPrepareShow(), QGraphicsScene::helpEvent(), QAbstractItemDelegate::helpEvent(), QCommandLineParserPrivate::helpText(), QTextBrowserPrivate::highlightLink(), QTextDocumentLayout::hitTest(), QFileSystemEngine::homePath(), QNetworkInterface::humanReadableName(), QMimeDatabasePrivate::icon(), QPlaceManagerEngineNokiaV2::icon(), iconEngineFromSuffix(), QMimeType::iconName(), iconTempPath(), QColorSpacePrivate::identifyColorSpace(), QTextHtmlImporter::import(), QQmlPluginImporter::importDynamicPlugin(), QQuickAnimatedImagePrivate::infoForCurrentFrame(), QWindowsSystemProxy::init(), QFontDialogPrivate::init(), QKeySequenceEditPrivate::init(), QLowEnergyControllerPrivateBluezDBus::init(), QGeoFileTileCache::init(), QGeoFileTileCacheOsm::init(), QTextEditPrivate::init(), QMessageBoxPrivate::init(), QGeoSatelliteInfoSourceGypsy::init(), QPrintPreviewDialogPrivate::init(), QCoreApplicationPrivate::initConsole(), QSocks5SocketEnginePrivate::initialize(), QDBusAbstractInterfacePrivate::initOwnerTracking(), QQmlDataTest::initTestCase(), QmlIR::Parameter::initType(), QWidgetTextControlPrivate::inputMethodEvent(), QComboBox::inputMethodEvent(), QLineEdit::inputMethodEvent(), QPlainTextEdit::inputMethodEvent(), QTextEdit::inputMethodEvent(), QQuickTextInput::insert(), QWidgetTextControlPrivate::insertParagraphSeparator(), QFormLayout::insertRow(), QFormLayout::insertRow(), QSqlTableModel::insertRowIntoTable(), QTextCursor::insertText(), installApk(), QQmlSettingsPrivate::instance(), QFileSystemEntry::isAbsolute(), QInputControl::isAcceptableInput(), QQmlJSMetaProperty::isAlias(), QFontDatabase::isBitmapScalable(), isBypassed(), QFileSystemEntry::isEmpty(), QGlyphRun::isEmpty(), QQmlScriptString::isEmpty(), QQuickIcon::isEmpty(), QPlaceAttributePrivate::isEmpty(), QPlaceSupplierPrivate::isEmpty(), QGeoAddress::isEmpty(), QSSGRenderPath::isEmpty(), Widget::isEmptyFunction(), isHostExcluded(), QQmlJSImportVisitor::isImportPrefix(), QDeclarativePluginParameter::isInitialized(), isIp6(), QFileDialogOptions::isLabelExplicitlySet(), QLibrary::isLibrary(), QQmlFile::isLocalFile(), QPixmapIconEngineEntry::isNull(), QAndroidPlatformIconEngine::isNull(), QWindowsIconEngine::isNull(), QQmlJSMetaProperty::isPrivate(), QQmlJSScope::isResolved(), QTextEngine::isRightToLeft(), QQmlToolingSettings::isSet(), QFontDatabase::isSmoothlyScalable(), QGeoAddress::isTextGenerated(), QMimeMagicResult::isValid(), QMimeType::isValid(), QPageSizePrivate::isValid(), QNetworkInterface::isValid(), TraceRequest::isValid(), BreakPoint::isValid(), QQmlJSMetaEnum::isValid(), QQmlJSMetaMethod::isValid(), QQmlJSMetaProperty::isValid(), QQmlJSMetaPropertyBinding::isValid(), QQmlJSResourceFileMapper::Entry::isValid(), QQmlJSStructuredTypeError::isValid(), QQmlProfilerEventLocation::isValid(), QQmlXmlListModelRole::isValid(), QTgaFile::isValid(), GeoRouteJsonParserEsri::isValid(), QGeoAreaMonitorInfo::isValid(), QFontDatabase::italic(), QStyle::itemTextRect(), QQC2::QStyle::itemTextRect(), Stringify::JO(), QAbstractItemView::keyboardSearch(), QTreeView::keyboardSearch(), QKeySequenceEdit::keyPressEvent(), QComboBox::keyPressEvent(), keysymToQtKey_internal(), QDomNode::lastChildElement(), QODBCResult::lastInsertId(), launchMail(), QWidgetLineControl::layoutDirection(), QQmlJS::Lexer::lex(), QLabelPrivate::linkHovered(), QLibraryPrivate::load(), QQuickAnimatedImage::load(), QQuickBorderImage::load(), SourceResolver::load(), loadTzTimeZones(), QV4::CompiledData::CompilationUnit::localCacheFilePath(), QDateTimePrivate::localNameAtMillis(), QQmlImportDatabase::locateLocalQmldir(), QQmlImportDatabase::lockModule(), QHostInfoAgent::lookup(), QCompletionEngine::lookupCache(), lookupVendorIdInSystemDatabase(), mailCommand(), main(), main(), makeCacheKey(), QQmlLSCompletion::makeSnippet(), mangledIdentifier(), QAbstractItemModel::match(), matchFamilyName(), QCompletionEngine::matchHint(), QUrlPrivate::mergePaths(), Option::messagePrefix(), QV4::ExecutionEngine::metaTypeFromJS(), QV4::QQmlXMLHttpRequestCtor::method_get_response(), QV4::StringPrototype::method_lastIndexOf(), QV4::StringPrototype::method_split(), mightBeRichTextImpl(), QDir::mkdir(), QDir::mkdir(), QDir::mkpath(), moc(), QEglFSKmsScreen::model(), QQmlJS::Dom::Paths::moduleScopePath(), QHeaderView::mouseMoveEvent(), QQuickText::mousePressEvent(), QDeclarativeGeoMapCopyrightNotice::mousePressEvent(), QWidgetTextControlPrivate::mouseReleaseEvent(), QWhatsThat::mouseReleaseEvent(), QQuickText::mouseReleaseEvent(), QDeclarativeGeoMapCopyrightNotice::mouseReleaseEvent(), QQuickTextControlPrivate::mouseReleaseEvent(), QQmlProperty::name(), QFileDialogPrivate::nativeEnterDirectory(), QDomNode::nextSiblingElement(), QFileSystemModelPrivate::node(), QNetworkCookie::normalize(), notfound(), Widget::nullVsEmpty(), objectPathIsForThisDevice(), QV4::QObjectWrapper::objectToString(), QQmlEngine::offlineStoragePath(), QDeclarativeGeoMapCopyrightNotice::onCopyrightsStyleSheetChanged(), QNetworkAccessFileBackend::open(), QDB2Driver::open(), QIBaseDriver::open(), QOCIDriver::open(), QODBCDriver::open(), QPSQLDriver::open(), QQmlDebugServerImpl::open(), QFFmpeg::EncodingFormatContext::openAVIO(), QQmlLocalStorage::openDatabaseSync(), QPdfPrintEnginePrivate::openPrintDevice(), QCupsPrintEnginePrivate::openPrintDevice(), QIOSServices::openUrl(), QAndroidPlatformServices::openUrl(), QPrintDialogPrivate::openWindowsPrintDialogModally(), QQmlJSTypeDescriptionReader::operator()(), operator<<(), operator<<(), operator<<(), operator<<(), QTextEditPrivate::paint(), QVideoFrame::paint(), QFontFamilyDelegate::paint(), QMimeDatabasePrivate::parents(), QEdidParser::parse(), QQmlDirParser::parse(), QCommandLineParserPrivate::parse(), Parser::parse(), QMimeTypeParserBase::parse(), parseAnimateTransformNode(), parseArguments(), parseBaseGradient(), QTestPrivate::parseBlackList(), QDateTimeParser::parseFormat(), QMapboxCommon::parseGeoLocation(), QAuthenticatorPrivate::parseHttpResponse(), parseIpFuture(), parseOptions(), parseOptions(), QCommandLineParserPrivate::parseOptionValue(), parseProvider(), QSocks5SocketEnginePrivate::parseRequestMethodReply(), parseServerList(), QLocalSocketPrivate::parseSockaddr(), QCss::Parser::parseTerm(), parseTracepoint(), QWidgetLineControl::paste(), QStringMatcher::pattern(), QBluetoothSocketPrivateBluezDBus::peerAddress(), QBluetoothSocketPrivateBluezDBus::peerName(), QFontDatabase::pointSizes(), QKeyMapper::possibleKeys(), prefixedName(), QDomNode::previousSiblingElement(), QOCIDriver::primaryIndex(), QODBCDriver::primaryIndex(), QQmlJSImportVisitor::processDefaultProperties(), QQuickTextPrivate::processHoverEvent(), QV4::CompiledData::processInlinComponentType(), QWidgetLineControl::processKeyEvent(), QQmlJSUtils::propertyFromChangedHandler(), qDBusInterfaceFromMetaObject(), qDecodeDataUrl(), qMediaFromUserInput(), QQmlTypeLoader::qmldirContent(), QQmlJS::Dom::ModuleIndex::qmldirsToLoad(), QQmlTypeData::qmlType(), QV4::CompiledData::CompilationUnit::qmlTypeForComponent(), qRelocateResourceFile(), QTest::qSignalDumperCallback(), QTest::qSignalDumperCallbackSlot(), qt_ACE_do(), qt_fontFromString(), qt_mac_applicationName(), qt_registerAliasToFontFamily(), qt_resolveFontFamilyAlias(), queryQtPaths(), rawStandaloneMonthName(), QImageReader::read(), readInputFile(), QJpegHandlerPrivate::readJpegHeader(), QPngHandlerPrivate::readPngTexts(), QComboBoxPrivate::recomputeSizeHint(), QWindowsInputContext::reconvertString(), QOCIDriver::record(), QODBCDriver::record(), QPSQLDriver::record(), QtBluezDiscoveryManager::registerDiscoveryInterest(), QQmlMetaType::registerPluginTypes(), QQuickStylePlugin::registerTypes(), QtQuickControls2Plugin::registerTypes(), QQmlJS::Dom::LineWriter::reindentAndSplit(), QQmlJS::Dom::IndentingLineWriter::reindentAndSplit(), QLibraryStore::releaseLibrary(), QToolBarAreaLayout::remove(), QToolBarAreaLayout::remove(), QPlatformTheme::removeMnemonics(), QToolBarAreaLayoutInfo::removeToolBar(), QtWaylandClient::QWaylandXdgSurface::requestActivate(), QWindowsInputContext::reset(), QOffscreenIntegration::resolveConfigFileConfiguration(), QUrl::resolved(), QFontconfigDatabase::resolveFontFamilyAlias(), QSvgGradientStyle::resolveStops_helper(), QTextBrowserPrivate::resolveUrl(), QDialogButtonBoxPrivate::retranslateStrings(), QMacPasteboard::retrieveData(), QComboBoxPrivate::returnPressed(), QDir::rmdir(), QDir::rmpath(), QHeaderDataProxyModel::roleNames(), QComboBoxPrivate::rowsInserted(), QCtfServer::run(), FileInfoThread::run(), QQmlDebugServerThread::run(), QDBusXmlToCpp::run(), runAdb(), runMoc(), runRcc(), runUic(), QDomElementPrivate::save(), QToolBarAreaLayout::saveState(), scanImports(), RemoteDeviceManager::scheduleJob(), QQmlJSTypeResolver::scopedType(), QEvdevTouchScreenData::screenGeometry(), QQmlTypeData::scriptImported(), QV4::UrlObject::search(), QQuickViewSection::sectionString(), QFileDialog::selectFile(), QLineEditPrivate::selectionChanged(), QSqlTableModel::selectRow(), QSqlTableModel::selectStatement(), QHttpProtocolHandler::sendRequest(), QSocks5SocketEnginePrivate::sendRequestMethod(), QCtfLibImpl::sessionEnabled(), set_text(), QCoreApplication::setApplicationName(), QCoreApplication::setApplicationVersion(), QWindowsMediaDeviceReader::setAudioOutput(), setAVMetadataItemForKey(), QQmlImports::setBaseUrl(), QQuickContext2DTexture::setCanvasWindow(), QAndroidInputContext::setComposingRegion(), QAndroidInputContext::setComposingText(), QQuickTextControlPrivate::setContent(), QWidgetTextControlPrivate::setContent(), QQuickStateGroupPrivate::setCurrentStateInternal(), QLineEditPrivate::setCursorVisible(), QCommandLineOption::setDefaultValue(), QGuiApplication::setDesktopFileName(), QWindowsNativeFileDialogBase::setDirectory(), QWidgetTextControl::setFocusToAnchor(), setFontFamilyFromValues(), QTextEngine::setFormats(), QQuickSpriteGoalAffector::setGoalState(), QmlIR::IRBuilder::setId(), QMessageBox::setInformativeText(), QLibraryPrivate::setLoadHints(), QMediaPlayerPrivate::setMedia(), QQuick3DRenderStatsMeshesModel::setMeshData(), QDeclarativePluginParameter::setName(), QQmlTypePrivate::setName(), QWindowsNativeFileDialogBase::setNameFilters(), QWindowsNativeSaveFileDialog::setNameFilters(), QMdiSubWindowPrivate::setNewWindowTitle(), QQuick3DRenderStatsPassesModel::setPassData(), QTextEngine::setPreeditArea(), QHttpSocketEngine::setProxy(), QAbstractSpinBoxPrivate::setRange(), QFileSystemModel::setRootPath(), QUrl::setScheme(), QTextBrowserPrivate::setSource(), QQuickTextDocumentPrivate::setStatus(), QApplication::setStyleSheet(), QWidget::setStyleSheet(), QDeclarativeGeoMapCopyrightNotice::setStyleSheet(), QImageWriter::setText(), QQuick3DRenderStatsTexturesModel::setTextureData(), QV4::CompiledData::CompilationUnit::setUnitData(), QV4::Compiler::Context::setupFunctionIndices(), TileProvider::setupProvider(), QQmlDMAbstractItemModelData::setValue(), QQmlDMListAccessorData::setValue(), QDeclarativePluginParameter::setValue(), QWindowPrivate::setVisible(), QWidget::setWindowTitle(), QCocoaWindow::setWindowTitle(), QLineEditPrivate::shouldShowPlaceholderText(), QtAndroidDialogHelpers::QAndroidPlatformMessageDialogHelper::show(), QBalloonTip::showBalloon(), QDBusTrayIcon::showMessage(), QWindowsSystemTrayIcon::showMessage(), showParserMessage(), signAAB(), signPackage(), QStringAlgorithms< StringType >::simplified_helper(), QQC2::QCommonStyle::sizeFromContents(), QQC2::QWindowsStyle::sizeFromContents(), QFontDatabase::smoothSizes(), QQmlJSUtils::sourceDirectoryPath(), QAbstractSpinBoxPrivate::specialValue(), splitIntoFamilies(), QSqlDriver::sqlStatement(), QStandardPaths::standardLocations(), QWasmVideoOutput::start(), QLowEnergyControllerPrivateBluezDBus::startAdvertising(), QQmlJSCodeGenerator::startInstruction(), QThreadPoolPrivate::startThread(), QQmlFile::status(), QWasmAudioOutput::stop(), QProcEnvValue::string(), QtFontFoundry::style(), QCss::StyleSelector::styleRulesForNode(), QFontDatabase::styles(), QFontDatabase::styleString(), QFontDatabase::styleString(), QQC2::QCommonStyle::subElementRect(), QCommonStyle::subElementRect(), QLibraryPrivate::suffixes_sys(), QCocoaMenuItem::sync(), QQuickHeaderViewBasePrivate::syncModel(), QSQLiteDriver::tables(), tabTextFor(), QToolBarAreaLayout::takeAt(), QQuickWheelHandlerPrivate::targetMetaProperty(), QFileSystemEngine::tempPath(), QQmlDataTest::testFile(), QSqlError::text(), QGeoAddress::text(), QImage::text(), QClipboard::text(), QQuickTextInputPrivate::textDirection(), QIconLoader::themeName(), QMdiSubWindowPrivate::titleBarOptions(), QCommandLinkButtonPrivate::titleRect(), QJSPrimitiveValue::toBoolean(), QLocale::toCurrencyString(), QLocale::toCurrencyString(), QDBusMessagePrivate::toDBusMessage(), QTextHtmlExporter::toHtml(), QUrlPrivate::toLocalFile(), QQmlPropertyCache::toMetaObjectBuilder(), QNetworkCookie::toRawForm(), QHostAddress::toString(), GpuDescription::toString(), QQmlError::toString(), QQuick3DPhysicsMesh::triangleMesh(), Driver::unique(), QtQuickControls2Plugin::unregisterTypes(), QDeclarativeGeocodeModel::update(), QVideoTextureHelper::SubtitleLayout::update(), QMenuPrivate::updateActionRects(), QQuickStateGroupPrivate::updateAutoState(), QGraphicsSimpleTextItemPrivate::updateBoundingRect(), QQuickListViewPrivate::updateCurrentSection(), QAndroidInputContext::updateCursorPosition(), QGraphicsSvgItemPrivate::updateDefaultSize(), QAbstractSpinBoxPrivate::updateEdit(), QQuickComboBoxPrivate::updateEditText(), QQuickFontDialogImplAttached::updateFamilies(), QDBusTrayIcon::updateIcon(), QQuickTextPrivate::updateLayout(), QQuickTextEdit::updatePaintNode(), QLibraryPrivate::updatePluginState(), QGeoRouteParserOsrmV5ExtensionMapbox::updateQuery(), QSqlTableModel::updateRowInTable(), QFontDialogPrivate::updateSample(), QQuickListViewPrivate::updateSectionCriteria(), QQuickTextPrivate::updateSize(), QFontDialogPrivate::updateSizes(), QQuickImageSelector::updateSource(), QQuick3DModel::updateSpatialNode(), QQuickListViewPrivate::updateStickySections(), QFontDialogPrivate::updateStyles(), QVideoWindowPrivate::updateSubtitle(), QIconLoader::updateSystemTheme(), QMdiSubWindowPrivate::updateWindowTitle(), QQmlFile::url(), QQmlDataBlob::urlString(), QQmlFile::urlToLocalFileOrQrc(), QFileDialogPrivate::userSelectedFiles(), QSpinBoxValidator::validate(), QDateTimeEditPrivate::validateAndInterpret(), QSpinBoxPrivate::validateAndInterpret(), QDoubleSpinBoxPrivate::validateAndInterpret(), VDMAbstractItemModelDataType::value(), VDMListDelegateDataType::value(), QWinRegistryKey::value(), QSSGQmlUtilities::valueToQml(), QTlsPrivate::X509CertificateOpenSSL::verify(), QQmlListModelParser::verifyBindings(), QHeaderView::viewportEvent(), QV4::Compiler::ScanFunctions::visit(), QQmlJSImportVisitor::visit(), QSvgVisitorImpl::visitTextNode(), QQuickStackViewPrivate::warn(), QFontDatabase::weight(), QQmlJS::Dom::ErrorMessage::withItem(), QImageWriter::write(), QQmlJS::Dom::LineWriter::write(), QmlTypeRegistrar::write(), DomUI::write(), DomIncludes::write(), DomInclude::write(), DomResources::write(), DomResource::write(), DomActionGroup::write(), DomAction::write(), DomActionRef::write(), DomButtonGroup::write(), DomButtonGroups::write(), DomCustomWidgets::write(), DomHeader::write(), DomCustomWidget::write(), DomLayoutDefault::write(), DomLayoutFunction::write(), DomTabStops::write(), DomLayout::write(), DomLayoutItem::write(), DomRow::write(), DomColumn::write(), DomItem::write(), DomWidget::write(), DomSpacer::write(), DomColor::write(), DomGradientStop::write(), DomGradient::write(), DomBrush::write(), DomColorRole::write(), DomColorGroup::write(), DomPalette::write(), DomFont::write(), DomPoint::write(), DomRect::write(), DomLocale::write(), DomSizePolicy::write(), DomSize::write(), DomDate::write(), DomTime::write(), DomDateTime::write(), DomStringList::write(), DomResourcePixmap::write(), DomResourceIcon::write(), DomString::write(), DomPointF::write(), DomRectF::write(), DomSizeF::write(), DomChar::write(), DomUrl::write(), DomProperty::write(), DomConnections::write(), DomConnection::write(), DomConnectionHints::write(), DomConnectionHint::write(), DomDesignerData::write(), DomSlots::write(), DomPropertySpecifications::write(), DomPropertyToolTip::write(), DomStringPropertySpecification::write(), QTextMarkdownWriter::writeBlock(), QDtlsPrivateOpenSSL::writeDatagramEncrypted(), QColorOutput::writePrefixedMessage(), QSystemLocalePrivate::zeroDigit(), and QLocaleData::zeroUcs().

◆ isLower()

bool QString::isLower ( ) const

Returns true if the string is lowercase, that is, it's identical to its toLower() folding.

Note that this does not mean that the string does not contain uppercase letters (some uppercase letters do not have a lowercase folding; they are left unchanged by toLower()). For more information, refer to the Unicode standard, section 3.13.

Since
5.12
See also
QChar::toLower(), isUpper()

Definition at line 5598 of file qstring.cpp.

References QtPrivate::isLower(), and qToStringViewIgnoringNull().

+ Here is the call graph for this function:

◆ 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 994 of file qstring.h.

References d.

Referenced by QAnyStringView::QAnyStringView(), QAnyStringView::QAnyStringView(), QDomAttrPrivate::QDomAttrPrivate(), QDomElementPrivate::QDomElementPrivate(), QTextLayout::QTextLayout(), append(), appendToUser(), bluetoothdVersion(), QNetworkAccessAuthenticationManager::cacheProxyCredentials(), QDBusPendingCallPrivate::checkReceivedSignature(), QQmlJSImportVisitor::checkRequiredProperties(), QtWaylandClient::convertData(), QDomImplementation::createDocumentType(), QDomNodeListPrivate::createList(), QQmlDelegateChooser::delegate(), QQmlScriptBlob::done(), QDrag::exec(), find_translation(), getLocaleValue(), QWidgetTextControl::insertFromMimeData(), QQuickTextControl::insertFromMimeData(), QComboBox::insertItem(), QNetworkAuthenticationCredential::isNull(), QSSGRenderPath::isNull(), QtStringBuilder::isNull(), Widget::isNullFunction(), QQmlJS::Dom::ExternalOwningItem::iterateDirectSubpaths(), QTranslator::load(), QV4::StringPrototype::method_lastIndexOf(), QV4::QQmlXMLHttpRequestCtor::method_open(), QXcbMime::mimeConvertToFormat(), Widget::nullVsEmpty(), QMYSQLDriver::open(), QMdiSubWindowPrivate::originalWindowTitle(), QInputDevice::primaryKeyboard(), QPointingDevice::primaryPointingDevice(), qt_convert_to_utf8(), readRegularEmptyFile_snippet(), QDomDocumentTypePrivate::save(), QDomAttrPrivate::save(), QDomElementPrivate::save(), QDomNotationPrivate::save(), QDomEntityPrivate::save(), QUrl::setAuthority(), QProgressDialogPrivate::setCancelButtonText(), QUrl::setFragment(), QUrl::setHost(), QUrl::setPassword(), QUrl::setUserInfo(), QUrl::setUserName(), QWidget::setWindowTitle(), QWidgetLineControl::surroundingText(), QLocale::toCurrencyString(), QLocale::toCurrencyString(), and QLocale::toCurrencyString().

◆ isRightToLeft()

bool QString::isRightToLeft ( ) const

Returns true if the string is read right to left.

See also
QStringView::isRightToLeft()

Definition at line 9307 of file qstring.cpp.

References QtPrivate::isRightToLeft().

Referenced by QTextEngine::isRightToLeft(), QQuickTextEdit::isRightToLeft(), QQuickTextInput::isRightToLeft(), QWidgetLineControl::layoutDirection(), and QLabelPrivate::textDirection().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isSharedWith()

bool QString::isSharedWith ( const QString & other) const
inline

Definition at line 223 of file qstring.h.

References d, and other().

+ Here is the call graph for this function:

◆ isUpper()

bool QString::isUpper ( ) const

Returns true if the string is uppercase, that is, it's identical to its toUpper() folding.

Note that this does not mean that the string does not contain lowercase letters (some lowercase letters do not have a uppercase folding; they are left unchanged by toUpper()). For more information, refer to the Unicode standard, section 3.13.

Since
5.12
See also
QChar::toUpper(), isLower()

Definition at line 5580 of file qstring.cpp.

References QtPrivate::isUpper(), and qToStringViewIgnoringNull().

+ Here is the call graph for this function:

◆ isValidUtf16()

bool QString::isValidUtf16 ( ) const
inlinenoexcept
Since
5.15

Returns true if the string contains valid UTF-16 encoded data, or false otherwise.

Note that this function does not perform any special validation of the data; it merely checks if it can be successfully decoded from UTF-16. The data is assumed to be in host byte order; the presence of a BOM is meaningless.

See also
QStringView::isValidUtf16()

Definition at line 997 of file qstring.h.

References QStringView::isValidUtf16().

+ Here is the call graph for this function:

◆ last() [1/2]

QString QString::last ( qsizetype n) &&
inline

Definition at line 407 of file qstring.h.

◆ last() [2/2]

QString QString::last ( qsizetype n) const &
inline

Definition at line 392 of file qstring.h.

Referenced by addDependencyImportError(), QQmlDelayedCallQueue::addUniquelyAndExecuteLater(), QmlLsp::QQmlCodeModel::buildPathsForFileUrl(), and Widget::lastFunction().

+ Here is the caller graph for this function:

◆ lastIndexOf() [1/7]

qsizetype QString::lastIndexOf ( const QString & str,
qsizetype from,
Qt::CaseSensitivity cs = Qt::CaseSensitive ) const

{qstring-last-index-of} {string} {str}

negative-index-start-search-from-end

Returns -1 if str is not found.

{search-comparison-case-sensitivity} {search}

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
Note
When searching for a 0-length str, the match at the end of the data is excluded from the search by a negative from, even though {-1} is normally thought of as searching from the end of the string: the match at the end is after the last character, so it is excluded. To include such a final empty match, either give a positive value for from or omit the from parameter entirely.
See also
indexOf(), contains(), count()

Definition at line 4551 of file qstring.cpp.

References QtPrivate::lastIndexOf(), and str.

+ Here is the call graph for this function:

◆ lastIndexOf() [2/7]

qsizetype QString::lastIndexOf ( const QString & s,
Qt::CaseSensitivity cs = Qt::CaseSensitive ) const
inline

Definition at line 303 of file qstring.h.

References lastIndexOf().

+ Here is the call graph for this function:

◆ lastIndexOf() [3/7]

◆ lastIndexOf() [4/7]

qsizetype QString::lastIndexOf ( QLatin1StringView s,
qsizetype from,
Qt::CaseSensitivity cs = Qt::CaseSensitive ) const

Definition at line 4599 of file qstring.cpp.

References QtPrivate::lastIndexOf(), and str.

+ Here is the call graph for this function:

◆ lastIndexOf() [5/7]

qsizetype QString::lastIndexOf ( QLatin1StringView s,
Qt::CaseSensitivity cs = Qt::CaseSensitive ) const
inline

Definition at line 300 of file qstring.h.

References lastIndexOf().

+ Here is the call graph for this function:

◆ lastIndexOf() [6/7]

qsizetype QString::lastIndexOf ( QStringView s,
qsizetype from,
Qt::CaseSensitivity cs = Qt::CaseSensitive ) const
inlinenoexcept

Definition at line 309 of file qstring.h.

References QtPrivate::lastIndexOf().

+ Here is the call graph for this function:

◆ lastIndexOf() [7/7]

qsizetype QString::lastIndexOf ( QStringView s,
Qt::CaseSensitivity cs = Qt::CaseSensitive ) const
inlinenoexcept

Definition at line 307 of file qstring.h.

References lastIndexOf().

+ Here is the call graph for this function:

◆ left() [1/2]

QString QString::left ( qsizetype n) &&
inline

Definition at line 369 of file qstring.h.

◆ left() [2/2]

QString QString::left ( qsizetype n) const &
inline

Definition at line 363 of file qstring.h.

Referenced by QIconTheme::QIconTheme(), QQuickGridScaledImage::QQuickGridScaledImage(), _q_createLegacyEngine_recursive(), QQmlImports::addFileImport(), QToolBarAreaLayout::apply(), QQmlJSLinter::applyFixes(), QMimeType::comment(), computeElidedText(), QGnomeThemePrivate::configureFonts(), QQmlNotifierEndpoint::connect(), createDirectoryWithParents(), QMimerSQLResult::data(), QtPrivate::QCalendarModel::dayName(), QQmlTypeData::done(), QQC2::QWindowsStyle::drawControl(), QMacStyle::drawControl(), QWindows11Style::drawControl(), QQuickVisualTestUtils::dumpTree(), enumsToValues(), QQmlCustomParser::evaluateEnum(), AndroidAbstractFileEngine::fileName(), QQmlPreviewFileEngine::fileName(), QQmlJSScope::findType(), QWindowsFontDatabase::fontEngine(), language::formatConnection(), QAndroidInputContext::getCursorCapsMode(), QV4::RegExp::getSubstitution(), QAndroidInputContext::getTextBeforeCursor(), QWaylandInputMethodEventBuilder::indexFromWayland(), QSqlRecord::indexOf(), QPlaceManagerEngineNokiaV2::initializeCategories(), QWaylandTextInputV3Private::inputMethodQuery(), QQuickTextInput::insert(), Utils::TextCursor::insertText(), QmlImportScanResult::Module::installPath(), QSslSocketPrivate::isMatchingHostname(), QToolBarAreaLayoutInfo::itemRect(), QFileDialogPrivate::maxNameLength(), QV4::RegExpPrototype::method_get_leftContext(), QV4::StringPrototype::method_split(), QV4::JsonObject::method_stringify(), QNetworkCookie::normalize(), QDB2Driver::open(), QV4::Script::parse(), parseFontName(), DocumentFile::parseFromAnyUri(), parseVersion(), QFileSystemEntry::path(), preprocessMetadata(), qSplitTableAndOwner(), qt_getImageTextFromDescription(), qt_split_namespace(), readDependenciesFromElf(), readGradleProperties(), QFileSystemEngine::removeDirectory(), DocumentFile::rename(), PropertyChangesValidatorPass::run(), runMoc(), QUrlPrivate::setScheme(), QUndoCommand::setText(), QWidgetLineControl::textBeforeSelection(), QQuickTextInputPrivate::textBeforeSelection(), QWaylandInputMethodEventBuilder::trimmedIndexFromWayland(), QAuthenticatorPrivate::updateCredentials(), QQmlTypeLoader::Blob::updateQmldir(), QMacMimeUnicodeText::utiForMime(), QDateTimeEditPrivate::validateAndInterpret(), QQmlDelegateModelPrivate::variantValue(), and TestHTTPServer::wait().

◆ leftJustified()

QString QString::leftJustified ( qsizetype width,
QChar fill = u' ',
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 7022 of file qstring.cpp.

References d, and fill().

Referenced by Widget::leftJustifiedFunction(), qFillBufferWithString(), Widget::resizeFunction(), and wrapText().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ length()

qsizetype QString::length ( ) const
inlinenoexcept

Returns the number of characters in this string.

Equivalent to size().

See also
resize()

Definition at line 191 of file qstring.h.

References d.

Referenced by QOCIDateTime::QOCIDateTime(), QtAndroidMenu::addAllMenuItemsToMenu(), addNextCluster(), QQuick3DParticleRepeller::affectParticle(), QFileSystemEntry::baseName(), bezierAtT(), QWaylandInputMethodEventBuilder::buildPreedit(), QQnxInputContext::checkSpelling(), QWasmLocalStorageSettingsPrivate::children(), QFileSystemEntry::completeBaseName(), QWindowsMimeText::convertFromMime(), QWindowsMimeURI::convertFromMime(), QBuiltInMimes::convertFromMime(), QTextLayout::createLine(), QTextLine::cursorToX(), QAndroidInputContext::deleteSurroundingText(), QPainter::drawText(), QQmlJS::Dom::AttachedInfo::ensure(), QDB2Result::exec(), QODBCResult::exec(), QOCICols::execBatch(), QFileSystemEntry::fileName(), QQmlJS::Dom::AttachedInfo::find(), QQmlJSScope::findType(), QAndroidInputContext::getCursorCapsMode(), QAndroidInputContext::getExtractedText(), KeyboardModifier::getForEvent< EmscriptenKeyboardEvent >(), getSelectedText(), getTextAfterCursor(), QAndroidInputContext::getTextBeforeCursor(), getTextBeforeCursor(), QTextLine::glyphRuns(), QAndroidInputContext::isComposing(), QQmlFile::isLocalFile(), isSpecialKey(), QQmlFile::isSynchronous(), QTextEngine::justify(), QTextEngine::leadingSpaceWidth(), QTextEngine::lineNumberForTextPosition(), QGeoFileTileCache::loadTiles(), QTextCursorPrivate::movePosition(), nextBezier(), QtAndroidMenu::onPrepareOptionsMenu(), QOCIDriver::open(), Parser::parse(), Parser::parseMetadata(), parseOtoolLibraryLine(), QFileSystemEntry::path(), QPainterPath::percentAtLength(), preprocessMetadata(), QQmlDocumentFormatting::process(), QQmlRangeFormatting::process(), qFillBufferWithString(), QQml_isFileCaseCorrect(), qt_mac_removeMnemonics(), QQC2_NAMESPACE::qt_mac_removeMnemonics(), qt_radial_gradient_adapt_focal_point(), QAndroidSystemLocale::query(), QRasterPaintEnginePrivate::rasterizeLine_dashed(), QPinchGestureRecognizer::recognize(), QWindowsInputContext::reconvertString(), PropertyChangesValidatorPass::run(), QWaylandTextInputV3Private::sendInputMethodEvent(), QAndroidInputContext::setComposingRegion(), QAndroidInputContext::setComposingText(), QTextLine::setLineWidth(), QTextLine::setNumColumns(), QTextLine::setNumColumns(), QAndroidInputContext::setSelection(), QTextEngine::shapeLine(), QWindowsDirect2DPaintEnginePrivate::stroke(), QRasterPaintEngine::stroke(), QMimerSQLDriver::tables(), toSpannableString(), QQmlLocaleValueType::toString(), AppendText::undo(), QAndroidInputContext::updateCursorPosition(), QWinRegistryKey::value(), src_gui_text_qsyntaxhighlighter::MyHighlighter::wrapper(), and QtWaylandClient::QWaylandTextInputv3::zwp_text_input_v3_done().

◆ localeAwareCompare() [1/4]

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

Definition at line 6907 of file qstring.cpp.

References other().

Referenced by QStringView::localeAwareCompare(), QV4::StringPrototype::method_localeCompare(), and QQmlLocale::method_localeCompare().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ 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.

See also
compare(), QLocale, {Comparing Strings}

Definition at line 722 of file qstring.h.

References s2.

◆ localeAwareCompare() [3/4]

int QString::localeAwareCompare ( QStringView s) const
inline

Definition at line 1495 of file qstring.h.

◆ localeAwareCompare() [4/4]

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

Definition at line 1497 of file qstring.h.

References s2.

◆ max_size()

qsizetype QString::max_size ( )
inlinestaticconstexprnoexcept
Since
6.8

This function is provided for STL compatibility. It returns the maximum number of elements that the string can theoretically hold. In practice, the number can be much smaller, limited by the amount of memory available to the system.

Definition at line 964 of file qstring.h.

Referenced by QCborStreamReaderPrivate::readStringChunk_unicode().

+ Here is the caller graph for this function:

◆ mid() [1/2]

QString QString::mid ( qsizetype position,
qsizetype n = -1 ) &&

Definition at line 5318 of file qstring.cpp.

References position(), and resize().

+ Here is the call graph for this function:

◆ mid() [2/2]

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

Definition at line 5300 of file qstring.cpp.

References position().

Referenced by QQmlJS::Dom::IndentInfo::IndentInfo(), IssueLocationWithContext::IssueLocationWithContext(), QQuickGridScaledImage::QQuickGridScaledImage(), QTextHtmlImporter::QTextHtmlImporter(), QGeoFileTileCache::~QGeoFileTileCache(), absoluteFilePath(), QQmlJS::Dom::QmlFile::addComponent(), QMimeAllGlobPatterns::addGlob(), QFileSystemWatcher::addPaths(), QQmlJSLinter::applyFixes(), QV4::PropertyKey::asFunctionName(), QFileSystemEntry::baseName(), QmlIR::Object::bindingAsString(), QCommonStylePrivate::calculateElidedText(), QQC2::QCommonStylePrivate::calculateElidedText(), QV4::Compiler::ScanFunctions::checkDirectivePrologue(), QMacSettingsPrivate::children(), cleanPackageName(), comify(), QQmlJS::Dom::LineWriter::commitLine(), QFileSystemEntry::completeBaseName(), QFileSystemEntry::completeSuffix(), QGnomeThemePrivate::configureFonts(), copyQtFiles(), AndroidAssetsFileEngineHandler::create(), QIBusPlatformInputContextPrivate::createConnection(), createImageNode(), deployQmlImports(), deployTranslations(), QV4::Symbol::descriptiveString(), doFilter(), QQmlTypeData::done(), QQC2::QWindowsStyle::drawControl(), QWindows11Style::drawControl(), QItemDelegate::drawDisplay(), QQmlJS::Dom::Token::dump(), src_gui_text_qtextlayout::Wrapper::elided(), QFontMetrics::elidedText(), QFontMetricsF::elidedText(), QQuickTextPrivate::elidedText(), QTextEngine::elidedText(), QQmlJS::Dom::QQmlDomAstCreator::endVisit(), QResourcePrivate::ensureChildren(), QQmlCustomParser::evaluateEnum(), fileArchitecture(), QFileSystemEntry::fileName(), AndroidAbstractFileEngine::fileName(), QQmlPreviewFileEngine::fileName(), filterSpecs(), Parser::findEnumValues(), QQmlJSScope::findType(), QQuickFolderBreadcrumbBarPrivate::folderBaseName(), getBinaryRPaths(), QSSGShaderKeyPropertyBase::getBoolValue(), QV4::getElementIntFallback(), getLibraryProjectsInOutputFolder(), getQtLibsFromElf(), QV4::RegExp::getSubstitution(), QAndroidInputContext::getTextAfterCursor(), QQmlJS::Dom::LineWriter::handleTrailingSpace(), QtPrivate::QCalendarDateSectionValidator::highlightString(), imageId(), QWaylandInputMethodEventBuilder::indexFromWayland(), QSqlRecord::indexOf(), QWaylandInputMethodEventBuilder::indexToWayland(), QPlaceManagerEngineNokiaV2::initializeCategories(), QWidgetTextControl::inputMethodQuery(), QWaylandTextInputV3Private::inputMethodQuery(), Utils::TextCursor::insertText(), QToolBarAreaLayoutInfo::insertToolBarBreak(), QSslSocketPrivate::isMatchingHostname(), QQuickTextInput::isRightToLeft(), keyName(), SourceResolver::load(), QHostInfo::localDomainName(), QPdfDocument::metaData(), QV4::RegExpPrototype::method_get_rightContext(), QV4::StringPrototype::method_split(), QQmlJS::Engine::midRef(), mightBeRichTextImpl(), QMacMimeAny::mimeForUti(), moduleNameToOptionName(), QTextDocumentPrivate::move(), nearestWordWrapIndex(), nextField(), QDB2Driver::open(), AndroidContentFileEngine::open(), QQmlDirParser::parse(), QTestPrivate::parseBlackList(), QSvgHandler::parseCSStoXMLAttrs(), parseExtendedAttributes(), parseFont(), parseFontName(), DocumentFile::parseFromAnyUri(), Parser::parseInstrument(), Parser::parseMetadata(), parseOtoolLibraryLine(), Parser::parseParamReplace(), Parser::parsePoint(), Parser::parsePrefix(), QLocalSocketPrivate::parseSockaddr(), parseVersion(), QQmlJSScope::prettyName(), QQmlRangeFormatting::process(), qExtractFontFamiliesFromString(), qRegisterNotificationCallbacks(), qt_punycodeDecoder(), qt_split_namespace(), QAndroidSystemLocale::query(), readDependenciesFromElf(), readGradleProperties(), QOffscreenIntegration::resolveConfigFileConfiguration(), runMoc(), QDomEntityPrivate::save(), QWidgetLineControl::selectedText(), Utils::TextCursor::selectedText(), QQuickTextInputPrivate::selectedText(), QAndroidInputContext::setComposingRegion(), AndroidMediaMetadataRetriever::setDataSource(), QQmlJS::Dom::LineWriter::setLineIndent(), QV4::UrlObject::setSearch(), QUndoCommand::setText(), TileProvider::setupProvider(), QQuickTextPrivate::setupTextLayout(), QNdefNfcUriRecord::setUri(), splitIntoFamilies(), QQmlScriptString::stringLiteral(), QSqlDriver::stripDelimiters(), QSQLiteDriver::stripDelimiters(), QAbstractSpinBoxPrivate::stripped(), QDomCharacterDataPrivate::substringData(), QFileSystemEntry::suffix(), QMimeType::suffixes(), Utils::TextBlock::text(), QLineEditPrivate::textAfterCursor(), QWidgetLineControl::textAfterSelection(), QQuickTextInputPrivate::textAfterSelection(), QLineEditPrivate::textBeforeCursor(), QNetworkCookie::toRawForm(), QWaylandInputMethodEventBuilder::trimmedIndexFromWayland(), QQuickComboBoxPrivate::tryComplete(), QAuthenticatorPrivate::updateCredentials(), QFileInfoGatherer::updateFile(), QQuickTextPrivate::updateLayout(), updateLibsXml(), QFileDialogPrivate::updateOkButton(), QtWaylandClient::QWaylandTextInputv1::updateState(), QtWaylandClient::QWaylandTextInputv2::updateState(), QtWaylandClient::QWaylandTextInputv3::updateState(), QQmlJS::Dom::QQmlDomAstCreator::visit(), QQmlJS::Dom::ScriptFormatter::visit(), QQmlJS::Dom::ScriptFormatter::visit(), QQmlJS::Dom::QQmlDomAstCreator::visit(), QQmlJS::Dom::QQmlDomAstCreator::visit(), QV4::Compiler::ScanFunctions::visit(), QQmlJSImportVisitor::visit(), wrapText(), writeAttribute(), and QTextMarkdownWriter::writeBlock().

+ Here is the call graph for this function:

◆ normalized()

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

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

Definition at line 8475 of file qstring.cpp.

References copy(), and qt_string_normalize().

Referenced by _hb_qt_unicode_compose(), _hb_qt_unicode_decompose(), QFseventsFileSystemWatcherEngine::addPaths(), QFileSystemIterator::advance(), QMacMimeFileUri::convertFromMime(), QMacMimeUrl::convertFromMime(), QMacMimeFileUri::convertToMime(), QMacMimeUrl::convertToMime(), QV4::StringPrototype::method_normalize(), and sortParticles().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ number() [1/7]

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

Returns a string representing the floating-point number n.

Returns a string that represents n, formatted according to the specified format and precision.

For formats with an exponent, the exponent will show its sign and have at least two digits, left-padding the exponent with zero if needed.

See also
setNum(), QLocale::toString(), QLocale::FloatingPointPrecisionOption, {Number Formats}

Definition at line 8142 of file qstring.cpp.

References QLocaleData::DFDecimal, QLocaleData::DFExponent, QLocaleData::DFSignificantDigits, form, QtMiscUtils::isAsciiUpper(), qdtoBasicLatin(), qWarning, and QtMiscUtils::toAsciiLower().

+ Here is the call graph for this function:

◆ number() [2/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 8084 of file qstring.cpp.

References base, and number.

Referenced by QGeoFileTileCacheNokia::QGeoFileTileCacheNokia(), QGeoTiledMapPrivate::QGeoTiledMapPrivate(), QWindowsMessageWindowClassContext::QWindowsMessageWindowClassContext(), ShmServerBuffer::ShmServerBuffer(), QDB2Result::~QDB2Result(), QGeoFileTileCache::~QGeoFileTileCache(), QFontDatabasePrivate::addAppFont(), addAtForBoundingArea(), addDependencyImportError(), QUrlPrivate::appendAuthority(), QIBaseResult::applyScale(), Widget::argFunction(), QV4::PropertyKey::asFunctionName(), MainWindow::averageItems(), QV4::CompiledData::CompilationUnit::bindingValueAsString(), boundingBoxToLtrb(), boundingBoxToLtrb(), QSSGQmlUtilities::builtinQmlType(), GeoRoutingManagerEngineEsri::calculateRoute(), QV4::CallMethod(), QTextMarkdownImporter::cbText(), checkArgumentsObjectUseInSignalHandlers(), QODBCDriverPrivate::checkDriver(), QOpenVGContext::checkErrors(), WorkspaceHandlers::clientInitialized(), QCupsPrintEnginePrivate::closePrintDevice(), Collector::collect(), colorValue(), QQuickStateGroup::componentComplete(), QBluetoothSocketPrivateWinRT::connectToServiceHelper(), QV4::ExecutionEngine::consoleCountHelper(), QQmlJSCodeGenerator::convertContained(), QV4::RuntimeHelpers::convertToString(), QFileDialogPrivate::createDirectory(), QKmsDevice::createScreenForConnector(), QODBCResult::data(), QMimerSQLResult::data(), QQmlBindPrivate::decodeBinding(), QXcbScreen::defaultName(), QCapturableWindow::description(), diagnosticErrorMessage(), dirIconPixmapCacheKey(), QWindowsVistaStylePrivate::drawBackgroundThruNativeBuffer(), QQC2::QWindowsXPStylePrivate::drawBackgroundThruNativeBuffer(), QQmlJS::Dom::Token::dump(), QmlLsp::OpenDocumentSnapshot::dump(), QV4::Moth::dumpArguments(), QQuickLayout::dumpLayoutTreeRecursive(), encodeText(), QQuickItemGrabResultPrivate::ensureImageInCache(), QUrl::errorString(), QQmlComponent::errorString(), QJSEngine::evaluate(), QIBaseResult::exec(), Recognizer::expand(), QQmlJS::Dom::ModuleIndex::exportsWithNameAndMinorVersion(), QQmlBoundSignalExpression::expressionIdentifier(), QWindowsFontDatabase::fontEngine(), QQmlJS::AST::FormalParameterList::formals(), formatLogMessage(), formatNumber(), QTest::Internal::formatTryTimeoutDebugMessage(), QDB2Driver::formatValue(), QIBaseDriver::formatValue(), QMYSQLDriver::formatValue(), QOCIDriver::formatValue(), QODBCDriver::formatValue(), QSqlDriver::formatValue(), QQmlJS::Dom::Path::fromString(), QQmlJSCodeGenerator::generate_CallPropertyLookup(), QQmlJSCodeGenerator::generate_CallQmlContextPropertyLookup(), QQmlJSCodeGenerator::generate_CmpEqInt(), QQmlJSCodeGenerator::generate_CmpNeInt(), QQmlJSCodeGenerator::generate_DefineObjectLiteral(), QQmlJSCodeGenerator::generate_GetIterator(), QQmlJSCodeGenerator::generate_IteratorNext(), QQmlJSCodeGenerator::generate_LoadConst(), QQmlJSCodeGenerator::generate_LoadGlobalLookup(), QQmlJSCodeGenerator::generate_LoadInt(), QQmlJSCodeGenerator::generate_LoadQmlContextPropertyLookup(), QQmlJSCodeGenerator::generate_MoveConst(), QQmlJSCodeGenerator::generate_SetLookup(), QQmlJSCodeGenerator::generate_StoreNameSloppy(), QQmlJSCodeGenerator::generateEnumLookup(), QQmlJSCodeGenerator::generateSetInstructionPointer(), QGeoCodingManagerEngineMapbox::geocode(), GeoCodingManagerEngineEsri::geocode(), QGeoCodingManagerEngineMapbox::geocode(), QGeoCodingManagerEngineOsm::geocode(), QGeoCodingManagerEngineNokia::geocode(), QSSGQmlUtilities::getAnimationSourceName(), QPixmapStylePrivate::getCachedPixmap(), getExtractedText(), QQmlJSCodeGenerator::getLookupPreparation(), QXcbScreen::getName(), QPlaceManagerEngineNokiaV2::getPlaceContent(), QGeoTileFetcherMapbox::getTileImage(), getUBMemberSizeWarning(), QQmlJS::Dom::DomUniverse::guaranteeUniverse(), QTreeModel::headerData(), Driver::headerFileName(), ICOReader::iconAt(), QCommonStylePrivate::iconFromMacTheme(), importImp(), QTreeModel::insertColumns(), QTextCursor::insertImage(), isAutoValue(), QIBaseDriverPrivate::isError(), QIBaseResultPrivate::isError(), QTextList::itemText(), QQmlJS::Dom::ModuleIndex::iterateDirectSubpaths(), QQmlJS::Dom::DomEnvironment::iterateDirectSubpaths(), Stringify::JA(), jsStack(), QPdfPageNavigator::jump(), QPdfPageNavigator::jump(), QXmlTestLogger::leaveTestFunction(), loadLibs(), QGeoFileTileCache::loadTiles(), QHostInfoAgent::lookup(), main(), main(), QQmlJS::Dom::Version::majorString(), QQmlJS::Dom::Version::majorSymbolicString(), makeFpString(), makeString(), mangledIdentifier(), maxExpression(), message(), QV4::ConsoleObject::method_count(), QQuickJSContext2D::method_get_fillStyle(), QV4::ErrorObject::method_get_stack(), QQuickJSContext2D::method_get_strokeStyle(), QV4::UrlPrototype::method_setPort(), minExpression(), QCalendarWidget::minimumSizeHint(), QQmlJS::Dom::Version::minorString(), QQmlJS::Dom::Paths::moduleIndexPath(), QQmlJS::Dom::PathEls::Index::name(), QWindowsScreen::name(), QColor::name(), QDateTimeParser::SectionNode::name(), QNativeSocketEnginePrivate::nativeReceiveDatagram(), Recognizer::nextToken(), Widget::numberFunction(), QV4::RuntimeHelpers::numberToString(), object_name_for_button(), QV4::QObjectWrapper::objectToString(), QQmlSA::DebugPropertyPass::onBinding(), QQmlSA::DebugPropertyPass::onRead(), QQmlSA::DebugPropertyPass::onWrite(), QDB2Driver::open(), QPSQLDriver::open(), QQmlJSTypeDescriptionReader::operator()(), QGeoJson::operator<<(), QGeoJson::operator<<(), QPdfDocument::pageLabel(), QQuickUniversalFocusRectangle::paint(), QStaticTextPrivate::paintText(), QEdidParser::parse(), QQuickStyledTextPrivate::parseTag(), QQmlJS::Dom::ModuleScope::pathFromOwner(), pixelToPoint(), QAbstractFileIconEngine::pixmap(), QSvgIconEnginePrivate::pmcKey(), QQuickMonthModelPrivate::populate(), QXcbUnixServices::portalWindowIdentifier(), QNetworkDiskCachePrivate::prepareLayout(), QV4::Function::prettyName(), QDB2Driver::primaryIndex(), QODBCDriver::primaryIndex(), printLogcat(), printPage(), processNode(), QQmlMetaTypeData::propertyCache(), qDB2Warn(), qDB2Warn(), qdbus_loadLibDBus(), qDBusNewConnection(), QSvgPaintEngine::qfontToSvg(), qGetBinaryData(), qMakeError(), qMakeError(), qMakeError(), qMakeError(), qMakeFieldInfo(), qMakePreparedStmtId(), qMakeStmtError(), QQmlJS::Dom::ModuleIndex::qmldirsToLoad(), QSvgPaintEngine::qpenToSvg(), qt_socket_getPortAndAddress(), queryQtPaths(), qWarnODBCHandle(), QColorDialogStaticData::readSettings(), QDB2Driver::record(), QSqlRelationalTableModelSql::relTablePrefix(), QGeoRouteParserOsrmV5Private::requestUrl(), QGeoRouteParserOsrmV4Private::requestUrl(), QV4::IdentifierTable::resolveId(), GeoCodingManagerEngineEsri::reverseGeocode(), QGeoCodingManagerEngineMapbox::reverseGeocode(), QGeoCodingManagerEngineOsm::reverseGeocode(), QDoubleSpinBoxPrivate::round(), ValueLookupJob::run(), QQmlSA::DebugElementPass::run(), QQmlJSCodeGenerator::run(), QV4::MemoryManager::runGC(), runningUnderDebugger(), runQmlImportScanner(), QSSGBufferManager::runtimeMeshSourceName(), QPlaceManagerEngineNokiaV2::search(), PlaceManagerEngineEsri::search(), QPlaceManagerEngineOsm::search(), QQuickFontDialogImplAttached::selectFontInListViews(), QSqlRelationalTableModel::selectStatement(), QWindowsIntegration::setApplicationBadge(), QNetworkDiskCache::setCacheDirectory(), QTreeModel::setColumnCount(), QLibrary::setFileNameAndVersion(), QSGCurveGlyphNode::setGlyphs(), QSGDistanceFieldGlyphNode::setGlyphs(), QV4::UrlObject::setHost(), QV4::Object::setIndexed(), QCUPSSupport::setJobPriority(), QQmlJSCodeGenerator::setLookupPreparation(), QUrl::setPort(), QV4::UrlObject::setPort(), QV4::UrlObject::setUrl(), sinkInfoCallback(), QIBaseResult::size(), sm_performSaveYourself(), QQmlJSUtils::sourceDirectoryPath(), sourceInfoCallback(), sql_intro_snippets(), QQC2::QCommonStyle::standardIcon(), QDateTimeParser::stateName(), QXmlTestLogger::stopLogging(), QQmlJS::Dom::Version::stringValue(), MainWindow::sumItems(), QDB2Driver::tables(), QtPrivate::QCalendarDayValidator::text(), QtPrivate::QCalendarMonthValidator::text(), QtPrivate::QCalendarYearValidator::text(), QSpinBox::textFromValue(), QtAndroidAccessibility::textFromValue(), TileProvider::tileAddress(), QGeoFileTileCacheMapbox::tileSpecToFilename(), QGeoFileTileCacheNokia::tileSpecToFilename(), QGeoFileTileCacheOsm::tileSpecToFilename(), QGeoFileTileCache::tileSpecToFilenameDefault(), QSchannelBackend::tlsLibraryBuildVersionString(), QSchannelBackend::tlsLibraryVersionString(), QQmlDebugTranslation::TranslationIssue::toDebugString(), QTextHtmlExporter::toHtml(), toMetadata(), toNumericString(), QV4::PropertyKey::toQString(), QSettingsGroup::toString(), QVersionNumber::toString(), QPageRanges::toString(), QFont::toString(), QBenchmarkContext::toString(), QJSPrimitiveValue::toString(), QQmlError::toString(), QTest::toString(), QGeoCoordinate::toString(), ToString(), toVariant(), QV4::SequencePrototype::toVariant(), translate_color(), Driver::unique(), QNetworkDiskCachePrivate::uniqueFileName(), QPdfPageNavigator::update(), QQuickMultiEffectPrivate::updateEffectShaders(), QV4::Function::updateInternalClass(), QPrintPreviewDialogPrivate::updateNavActions(), QPrintPreviewDialogPrivate::updatePageNumLabel(), QLibraryPrivate::updatePluginState(), QFontDialogPrivate::updateSizes(), CompletionRequest::urlAndPos(), QSSGQmlUtilities::variantToQml(), variantToString(), QV4::UrlSearchParamsCtor::virtualCallAsConstructor(), QQmlJS::Dom::AstDumper::visit(), QQmlJS::Dom::AstDumper::visit(), QQmlJS::Dom::AstDumper::visit(), QQmlJS::Dom::AstDumper::visit(), QQmlJS::Dom::ScriptFormatter::visit(), QQmlJS::Dom::AstDumper::visit(), QQmlJS::Dom::AstDumper::visit(), QQmlJS::Dom::AstDumper::visit(), QQmlJS::Dom::AstDumper::visit(), QQmlJS::Dom::AstDumper::visit(), QQmlJS::Dom::AstDumper::visit(), QQmlJS::Dom::AstDumper::visit(), QQmlJS::Dom::AstDumper::visit(), qfontdatabase_snippets::wrapper(), QQmlJS::Dom::FileWriter::write(), DomUI::write(), DomCustomWidget::write(), DomLayoutDefault::write(), DomLayoutItem::write(), DomItem::write(), DomColor::write(), DomGradientStop::write(), DomGradient::write(), DomFont::write(), DomPoint::write(), DomRect::write(), DomSizePolicy::write(), DomSize::write(), DomDate::write(), DomTime::write(), DomDateTime::write(), DomPointF::write(), DomRectF::write(), DomSizeF::write(), DomChar::write(), DomProperty::write(), DomConnectionHint::write(), writeAttribute(), QTextMarkdownWriter::writeBlock(), QTextOdfWriter::writeBlock(), QTextOdfWriter::writeBlockFormat(), QTextOdfWriter::writeCharacterFormat(), writeCtfMacro(), QTextOdfWriter::writeFrame(), QTextOdfWriter::writeListFormat(), QColorDialogStaticData::writeSettings(), and QTextOdfWriter::writeTableFormat().

◆ 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.

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.

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 8066 of file qstring.cpp.

References base, and number.

◆ number() [4/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 8100 of file qstring.cpp.

References base, qulltoBasicLatin(), and qWarning.

+ Here is the call graph for this function:

◆ number() [5/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 8119 of file qstring.cpp.

References base, qulltoBasicLatin(), and qWarning.

+ Here is the call graph for this function:

◆ number() [6/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 8092 of file qstring.cpp.

References base, and number.

◆ number() [7/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 8076 of file qstring.cpp.

References base, and number.

◆ operator std::u16string_view()

QString::operator std::u16string_view ( ) const
inlinenoexcept
Since
6.7

Converts this QString object to a {std::u16string_view} object.

Definition at line 1479 of file qstring.h.

References d.

◆ operator+=() [1/7]

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

Definition at line 873 of file qstring.h.

References append().

+ Here is the call graph for this function:

◆ operator+=() [2/7]

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

Definition at line 875 of file qstring.h.

References append().

+ Here is the call graph for this function:

◆ operator+=() [3/7]

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 (\l{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 534 of file qstring.h.

References append().

+ Here is the call graph for this function:

◆ operator+=() [4/7]

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

Definition at line 532 of file qstring.h.

References append().

+ Here is the call graph for this function:

◆ operator+=() [5/7]

QString & QString::operator+= ( QLatin1StringView s)
inline

Definition at line 536 of file qstring.h.

References append().

+ Here is the call graph for this function:

◆ operator+=() [6/7]

QString & QString::operator+= ( QStringView v)
inline

Definition at line 535 of file qstring.h.

References append().

+ Here is the call graph for this function:

◆ operator+=() [7/7]

QString & QString::operator+= ( QUtf8StringView s)
inline

Definition at line 537 of file qstring.h.

References append().

+ Here is the call graph for this function:

◆ operator=() [1/5]

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

Definition at line 844 of file qstring.h.

References ch, and clear().

+ Here is the call graph for this function:

◆ operator=() [2/5]

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

Definition at line 852 of file qstring.h.

References clear().

+ Here is the call graph for this function:

◆ operator=() [3/5]

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

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

Definition at line 2837 of file qstring.cpp.

References d, and other().

+ Here is the call graph for this function:

◆ operator=() [4/5]

QString & QString::operator= ( QChar c)

Definition at line 2901 of file qstring.cpp.

References ch.

◆ operator=() [5/5]

QString & QString::operator= ( QLatin1StringView latin1)

Definition at line 2857 of file qstring.cpp.

References capacity, d, other(), and qt_from_latin1().

+ Here is the call graph for this function:

◆ operator[]() [1/2]

QChar & QString::operator[] ( qsizetype position)
inline

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

Example:

if (str[0] == QChar('?'))
str[0] = QChar('_');
See also
at()

Definition at line 1345 of file qstring.h.

References i.

◆ operator[]() [2/2]

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

Definition at line 1228 of file qstring.h.

References d, and i.

◆ prepend() [1/8]

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

Definition at line 861 of file qstring.h.

References prepend().

+ Here is the call graph for this function:

◆ prepend() [2/8]

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

Definition at line 863 of file qstring.h.

References prepend().

+ Here is the call graph for this function:

◆ prepend() [3/8]

QString & QString::prepend ( const QChar * uc,
qsizetype len )
inline

Definition at line 479 of file qstring.h.

References insert().

+ Here is the call graph for this function:

◆ prepend() [4/8]

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

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

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

Example:

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

Definition at line 480 of file qstring.h.

References insert().

+ Here is the call graph for this function:

◆ prepend() [5/8]

◆ prepend() [6/8]

QString & QString::prepend ( QLatin1StringView s)
inline

Definition at line 482 of file qstring.h.

References insert().

+ Here is the call graph for this function:

◆ prepend() [7/8]

QString & QString::prepend ( QStringView v)
inline

Definition at line 481 of file qstring.h.

References prepend().

Referenced by prepend().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ prepend() [8/8]

QString & QString::prepend ( QUtf8StringView s)
inline

Definition at line 483 of file qstring.h.

References insert().

+ Here is the call graph for this function:

◆ push_back() [1/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 958 of file qstring.h.

References append().

+ Here is the call graph for this function:

◆ push_back() [2/2]

void QString::push_back ( QChar c)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Appends the given ch character onto the end of this string.

Definition at line 957 of file qstring.h.

References append().

Referenced by QGeoTiledMappingManagerEngineOsm::QGeoTiledMappingManagerEngineOsm(), QV4::StringPrototype::method_split(), qExtractFontFamiliesFromString(), QCocoaMessageDialog::show(), and translationNameFilters().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ push_front() [1/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 960 of file qstring.h.

References prepend().

+ Here is the call graph for this function:

◆ push_front() [2/2]

void QString::push_front ( QChar c)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Prepends the given ch character to the beginning of this string.

Definition at line 959 of file qstring.h.

References prepend().

+ Here is the call graph for this function:

◆ QT_CORE_INLINE_SINCE() [1/2]

static QString static QString QString::QT_CORE_INLINE_SINCE ( 6 ,
7  )

◆ QT_CORE_INLINE_SINCE() [2/2]

QString::QT_CORE_INLINE_SINCE ( 6 ,
7  )

◆ rbegin() [1/2]

QString::reverse_iterator QString::rbegin ( )
inline
Since
5.6

Returns a \l{STL-style iterators}{STL-style} reverse iterator pointing to the first character in the string, in reverse order.

iterator-invalidation-func-desc

See also
begin(), crbegin(), rend()

Definition at line 942 of file qstring.h.

Referenced by QAndroidInputContext::longPress().

+ Here is the caller graph for this function:

◆ rbegin() [2/2]

QString::const_reverse_iterator QString::rbegin ( ) const
inline
Since
5.6 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 944 of file qstring.h.

◆ remove() [1/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.

{search-comparison-case-sensitivity} {search}

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

shrinking-erase

See also
replace()

Definition at line 3547 of file qstring.cpp.

References d, QArrayDataPointer< T >::data(), QtPrivate::q_points_into_range(), qToStringViewIgnoringNull(), QVarLengthArray(), removeStringImpl(), size(), and str.

+ Here is the call graph for this function:

◆ 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.

{search-comparison-case-sensitivity} {search}

Example:

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

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

shrinking-erase

See also
replace()

Definition at line 3627 of file qstring.cpp.

References begin(), Qt::CaseSensitive, ch, copy(), d, indexOf(), it, match(), and Qt::Uninitialized.

+ Here is the call graph for this function:

◆ remove() [3/4]

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

Removes every occurrence of the given Latin-1 string viewed by str from this string, and returns a reference to this string.

{search-comparison-case-sensitivity} {search}

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

shrinking-erase

See also
replace()

Definition at line 3572 of file qstring.cpp.

References removeStringImpl(), and str.

+ Here is the call graph for this function:

◆ remove() [4/4]

QString & QString::remove ( qsizetype position,
qsizetype 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.

If n is <= 0 nothing is changed.

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

! [shrinking-erase] Element removal will preserve the string's capacity and not reduce the amount of allocated memory. To shed extra capacity and free as much memory as possible, call squeeze() after the last change to the string's size. ! [shrinking-erase]

See also
insert(), replace()

Definition at line 3466 of file qstring.cpp.

References begin(), copy(), d, pos, swap(), and Qt::Uninitialized.

Referenced by QFactoryLoader::QFactoryLoader(), QPrintPreviewDialogPrivate::_q_zoomFactorChanged(), QGeoFileTileCache::clearAll(), AndroidAssetsFileEngineHandler::create(), QFileSystemEngine::currentPath(), QCalendarBackend::dateTimeToString(), QDomCharacterDataPrivate::deleteData(), fontKeys(), QSslCertificate::fromPath(), QAndroidInputContext::getTextAfterCursor(), QtAndroidDialogHelpers::htmlText(), QSQLiteResultPrivate::initColumns(), AndroidContentFileEngine::mkdir(), parseExtendedAttributes(), QCss::Parser::parseSimpleSelector(), QCss::Parser::parseTerm(), qt_font_from_string(), Driver::qtify(), QDir::relativeFilePath(), Widget::removeFunction(), removeOptionalQuotes(), AndroidContentFileEngine::rmdir(), QSSGQmlUtilities::sanitizeQmlId(), QFileDialogOptions::setDefaultSuffix(), QQmlJSUtils::sourceDirectoryPath(), QSSGQmlUtilities::stripParentDirectory(), QSvgNode::styleProperty(), styleUri(), QDoubleSpinBox::textFromValue(), QSpinBox::textFromValue(), and QUrlPrivate::toLocalFile().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeAt()

QString & QString::removeAt ( qsizetype pos)
inline
Since
6.5

Removes the character at index pos. If pos is out of bounds (i.e. pos >= size()), this function does nothing.

See also
remove()

Definition at line 555 of file qstring.h.

References pos, and remove().

Referenced by QToolBarAreaLayout::remove(), QToolBarAreaLayout::remove(), QToolBarAreaLayoutInfo::removeToolBar(), and QToolBarAreaLayout::takeAt().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeFirst()

QString & QString::removeFirst ( )
inline
Since
6.5

Removes the first character in this string. If the string is empty, this function does nothing.

See also
remove()

Definition at line 557 of file qstring.h.

References remove().

+ Here is the call graph for this function:

◆ removeIf()

template<typename Predicate >
template< typename Predicate > QString & QString::removeIf ( Predicate pred)
inline
Since
6.1

Removes all elements for which the predicate pred returns true from the string. Returns a reference to the string.

See also
remove()

Definition at line 561 of file qstring.h.

◆ removeLast()

QString & QString::removeLast ( )
inline
Since
6.5

Removes the last character in this string. If the string is empty, this function does nothing.

See also
remove()

Definition at line 558 of file qstring.h.

References remove().

Referenced by QmlLsp::QQmlCodeModel::buildPathsForFileUrl().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ rend() [1/2]

QString::reverse_iterator QString::rend ( )
inline
Since
5.6

Returns a \l{STL-style iterators}{STL-style} reverse iterator pointing just after the last character in the string, in reverse order.

iterator-invalidation-func-desc

See also
end(), crend(), rbegin()

Definition at line 943 of file qstring.h.

References begin().

+ Here is the call graph for this function:

◆ rend() [2/2]

QString::const_reverse_iterator QString::rend ( ) const
inline
Since
5.6 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 945 of file qstring.h.

References begin().

+ Here is the call graph for this function:

◆ repeated()

QString QString::repeated ( qsizetype times) const
Since
4.5

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

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

Example:

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

Definition at line 8375 of file qstring.cpp.

References d.

◆ replace() [1/11]

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

Definition at line 3861 of file qstring.cpp.

References Qt::CaseSensitive, d, matcher, and replace_helper().

+ Here is the call graph for this function:

◆ replace() [2/11]

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

Definition at line 3846 of file qstring.cpp.

References constData(), and size().

+ Here is the call graph for this function:

◆ replace() [3/11]

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

Definition at line 4041 of file qstring.cpp.

References constData(), front(), qt_from_latin1_to_qvla(), size(), and QArrayDataPointer< T >::size.

+ Here is the call graph for this function:

◆ replace() [4/11]

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

Definition at line 3945 of file qstring.cpp.

References Qt::CaseSensitive, ch, d, foldCase(), indexOf(), other(), swap(), and Qt::Uninitialized.

+ Here is the call graph for this function:

◆ replace() [5/11]

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

Definition at line 3903 of file qstring.cpp.

References begin(), Qt::CaseSensitive, ch, d, i, QtPrivate::qustrchr(), remove(), replace_helper(), and view.

+ Here is the call graph for this function:

◆ replace() [6/11]

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

Definition at line 4062 of file qstring.cpp.

References qt_from_latin1_to_qvla(), and size().

+ Here is the call graph for this function:

◆ replace() [7/11]

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

Definition at line 4020 of file qstring.cpp.

References QLatin1StringView::front(), qt_from_latin1_to_qvla(), and QLatin1StringView::size().

+ Here is the call graph for this function:

◆ replace() [8/11]

Definition at line 3996 of file qstring.cpp.

References QLatin1StringView::front(), qt_from_latin1_to_qvla(), QLatin1StringView::size(), and size().

+ Here is the call graph for this function:

◆ replace() [9/11]

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

Definition at line 3805 of file qstring.cpp.

References pos, QSpan(), and replace_helper().

+ Here is the call graph for this function:

◆ replace() [10/11]

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

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

Note
If the specified position index is within the string, but position + n goes outside the strings range, then n will be adjusted to stop at the end of the string.

Example:

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

Definition at line 3793 of file qstring.cpp.

References pos.

◆ replace() [11/11]

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

Definition at line 3824 of file qstring.cpp.

References pos.

Referenced by FolderIterator::FolderIterator(), QWasmLocalStorageSettingsPrivate::QWasmLocalStorageSettingsPrivate(), comify(), convertMnemonics(), QWindowsMimeText::convertToMime(), AndroidAssetsFileEngineHandler::create(), QQmlJS::Dom::LineWriter::ensureSpace(), QQmlDirParser::errors(), QDB2Driver::escapeIdentifier(), QIBaseDriver::escapeIdentifier(), QMimerSQLDriver::escapeIdentifier(), QMYSQLDriver::escapeIdentifier(), QPSQLDriver::escapeIdentifier(), QOCIDriver::escapeIdentifier(), Recognizer::expand(), findInBlock(), QGeoCodingManagerEngineNokia::geocode(), Driver::headerFileName(), QtAndroidDialogHelpers::htmlText(), QQmlDelegateModelItemMetaType::initializeMetaObject(), QQmlDelegateModelItemMetaType::initializePrototype(), launchMail(), loadCubeMap(), StringEnum::mapName(), QPdfDocument::metaData(), QMacMimeAny::mimeForUti(), Widget::modify(), QQmlEngine::offlineStoragePath(), CppGenerator::operator()(), QVideoFrame::paint(), QGraphicsSimpleTextItem::paint(), parseAttributeValues(), parseTestArgs(), parseUri(), QQmlRangeFormatting::process(), qQmlJSSymbolNamespaceForPath(), qtResourceNameForFile(), quoteNewline(), readSymLink(), QDomCharacterDataPrivate::replaceData(), Widget::replaceFunction(), QItemDelegatePrivate::replaceNewLine(), replacePercentN(), QmlTypeRegistrar::runExtract(), scanImports(), QToolButton::setDefaultAction(), QQuickTextPrivate::setupTextLayout(), tabTextFor(), QAction::text(), QAbstractItemDelegatePrivate::textForRole(), QQC2::QCommonStylePrivate::toolButtonElideText(), QVideoTextureHelper::SubtitleLayout::update(), QGraphicsSimpleTextItemPrivate::updateBoundingRect(), QMdiSubWindowPrivate::updateInternalWindowTitle(), QQuickTextPrivate::updateLayout(), QSvgVisitorImpl::visitTextNode(), TestHTTPServer::wait(), and QmlTypeRegistrar::write().

◆ reserve()

void QString::reserve ( qsizetype size)
inline

Ensures the string has space for at least size characters.

If you know in advance how large a string will be, you can call this function to save repeated reallocation while building it. This can improve performance when building a string incrementally. A long sequence of operations that add to a string may trigger several reallocations, the last of which may leave you with significantly more space than you need. This is less efficient than doing a single allocation of the right size at the start.

If in doubt about how much space shall be needed, it is usually better to use an upper bound as size, or a high estimate of the most likely size, if a strict upper bound would be much bigger than this. If size is an underestimate, the string will grow as needed once the reserved size is exceeded, which may lead to a larger allocation than your best overestimate would have and will slow the operation that triggers it.

Warning
reserve() reserves memory but does not change the size of the string. Accessing data beyond the end of the string is undefined behavior. If you need to access memory beyond the current end of the string, use 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:

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

Definition at line 1325 of file qstring.h.

References capacity, d, QArrayData::KeepSize, and qMax().

Referenced by _hb_qt_unicode_compose(), QXmlStreamReaderPrivate::clearTextBuffer(), QNetworkInformationPrivate::create(), QLocaleData::doubleToString(), QMimeXMLProvider::ensureLoaded(), QDB2Driver::formatValue(), QSqlRelationalTableModelPrivate::fullyQualifiedFieldName(), make_where_clause(), mangledIdentifier(), QV4::StringPrototype::method_replace(), QQuickStyledTextPrivate::parse(), parseIp6(), q_fourccToString(), qDBusInterfaceFromMetaObject(), QtPrivate::QStringList_join(), QtPrivate::QStringList_join(), QWavefrontMesh::readData(), QConfFileSettingsPrivate::readIniSection(), QDomElementPrivate::save(), QQmlJS::Lexer::setCode(), QWidgetLineControl::setEchoMode(), QQmlSignalNames::signalNameToHandlerName(), QSqlDriver::sqlStatement(), QTextBlock::text(), QTextHtmlExporter::toHtml(), QVersionNumber::toString(), QIPAddressUtils::toString(), and typeNameToXml().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ resize() [1/2]

void QString::resize ( qsizetype 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 beyond position size are excluded from the string.

Note
While resize() will grow the capacity if needed, it never shrinks capacity. To shed excess capacity, use squeeze().

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 the \l {QString::}{resize(qsizetype, QChar)} overload.

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(), squeeze()

Definition at line 2668 of file qstring.cpp.

References d, QArrayData::Grow, and needsReallocate().

Referenced by QXmlStreamPrivateTagStack::addToStringStorage(), addZeroPrefixedInt(), Widget::characterReference(), QXmlStreamReaderPrivate::clearTextBuffer(), QCalendarBackend::dateTimeToString(), decode(), decodeFsEncString(), QRegularExpression::errorString(), insert_helper(), QSysInfo::machineHostName(), QV4::StringPrototype::method_padEnd(), QV4::StringPrototype::method_padStart(), parseAttributeValues(), performBitwiseOperationInPlace(), QTextDocumentPrivate::plainText(), replace_in_place(), Widget::resizeFunction(), QQmlJS::Lexer::scanRegExp(), QStringAlgorithms< StringType >::simplified_helper(), toStdWString(), QHashedCStringRef::toUtf16(), QStringAlgorithms< StringType >::trimmed_helper_inplace(), and QSystemLocalePrivate::update().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ resize() [2/2]

void QString::resize ( qsizetype newSize,
QChar fillChar )

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

Since
5.7

Unlike \l {QString::}{resize(qsizetype)}, this overload initializes the new characters to fillChar:

QString t = "Hello";
r.resize(t.size() + 10, 'X');
// t == "HelloXXXXXXXXXX"

Definition at line 2690 of file qstring.cpp.

References d, and resize().

+ Here is the call graph for this function:

◆ resizeForOverwrite()

void QString::resizeForOverwrite ( qsizetype size)
Since
6.8

Sets the size of the string to size characters. If the size of the string grows, the new characters are uninitialized.

The behavior is identical to {resize(size)}.

See also
resize()

Definition at line 2711 of file qstring.cpp.

References resize().

+ Here is the call graph for this function:

◆ right() [1/2]

QString QString::right ( qsizetype n) &&
inline

Definition at line 381 of file qstring.h.

◆ right() [2/2]

QString QString::right ( qsizetype n) const &
inline

Definition at line 375 of file qstring.h.

Referenced by QToolBarAreaLayout::apply(), computeElidedText(), enumsToValues(), QAndroidInputContext::getTextBeforeCursor(), QWaylandTextInputV3Private::inputMethodQuery(), QMimeAllGlobPatterns::matchingGlobs(), parseIntOption(), preprocessMetadata(), queryQtPaths(), and QImageReader::read().

+ Here is the caller graph for this function:

◆ rightJustified()

QString QString::rightJustified ( qsizetype width,
QChar fill = u' ',
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 7061 of file qstring.cpp.

References d, and fill().

Referenced by Widget::rightJustifiedFunction().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ section() [1/2]

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

Definition at line 5088 of file qstring.cpp.

References Qt::CaseInsensitive, Qt::CaseSensitive, i, QStringView::isEmpty(), Qt::KeepEmptyParts, ret, sep, and QStringView::split().

+ Here is the call graph for this function:

◆ section() [2/2]

QString QString::section ( QChar sep,
qsizetype start,
qsizetype 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 \l{SectionFlags}.

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 1284 of file qstring.h.

Referenced by qtVersion(), Widget::sectionFunction(), QSqlRelationalTableModel::selectStatement(), and QQuickListViewPrivate::updateCurrentSection().

+ Here is the caller graph for this function:

◆ setNum() [1/10]

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

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Sets the string to the printed value of n, formatted according to the given format and precision, and returns a reference to the string.

See also
number(), QLocale::FloatingPointPrecisionOption, {Number Formats}

Definition at line 8026 of file qstring.cpp.

References number.

◆ setNum() [2/10]

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

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Sets the string to the printed value of n, formatted according to the given format and precision, and returns a reference to the string.

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.

See also
number()

Definition at line 1269 of file qstring.h.

◆ 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.

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.

See also
number()

Definition at line 1261 of file qstring.h.

References base.

◆ setNum() [4/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 1265 of file qstring.h.

References base.

◆ setNum() [5/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 7994 of file qstring.cpp.

References base, and number.

◆ setNum() [6/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 8002 of file qstring.cpp.

References base, and number.

◆ setNum() [7/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 1257 of file qstring.h.

References base.

Referenced by QDomElement::setAttribute(), QDomElement::setAttribute(), QDomElement::setAttribute(), QDomElement::setAttribute(), QDomElement::setAttributeNS(), QDomElement::setAttributeNS(), QDomElement::setAttributeNS(), QLabel::setNum(), QLabel::setNum(), and Widget::setNumFunction().

+ Here is the caller graph for this function:

◆ setNum() [8/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 1263 of file qstring.h.

References base.

◆ setNum() [9/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 1267 of file qstring.h.

References base.

◆ setNum() [10/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 1259 of file qstring.h.

References base.

◆ setRawData()

QString & QString::setRawData ( const QChar * unicode,
qsizetype size )
Since
4.7

Resets the QString to use 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.

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 9501 of file qstring.cpp.

References clear().

+ Here is the call graph for this function:

◆ setUnicode()

QString & QString::setUnicode ( const QChar * unicode,
qsizetype size )

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

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

See also
unicode(), setUtf16()

Definition at line 6100 of file qstring.cpp.

References d, and resize().

+ Here is the call graph for this function:

◆ setUtf16()

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

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

If unicode is \nullptr, 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 1343 of file qstring.h.

◆ shrink_to_fit()

void QString::shrink_to_fit ( )
inline
Since
5.10

This function is provided for STL compatibility. It is equivalent to squeeze().

See also
squeeze()

Definition at line 961 of file qstring.h.

◆ simplified() [1/2]

QString QString::simplified ( ) &&
inline

Definition at line 453 of file qstring.h.

◆ simplified() [2/2]

QString QString::simplified ( ) const &
inline

◆ size()

qsizetype QString::size ( ) const
inlinenoexcept

Returns the number of characters in this string.

The last character in the string is at position size() - 1.

Example:

QString str = "World";
qsizetype n = str.size(); // n == 5
str.data()[0]; // returns 'W'
str.data()[4]; // returns 'd'
See also
isEmpty(), resize()

Definition at line 186 of file qstring.h.

References d.

Referenced by QQmlJS::Dom::IndentInfo::IndentInfo(), KeyEvent::KeyEvent(), QTextEngine::LayoutData::LayoutData(), QAnyStringView::QAnyStringView(), QAnyStringView::QAnyStringView(), QHashedStringRef::QHashedStringRef(), QHashedStringRef::QHashedStringRef(), _q_createLegacyEngine_recursive(), QQmlTypeLoader::absoluteFilePath(), QQuickComboBoxPrivate::acceptInput(), QIconLoaderEngine::actualSize(), QQmlTypeNameCache::add(), QQmlTypeNameCache::add(), QWindowsFontDatabase::addApplicationFont(), addDependencyImportError(), QQmlImportDatabase::addImportPath(), addLexToken(), QQmlImportDatabase::addPluginPath(), QQuickTextNodeEngine::addTextBlock(), QXmlStreamPrivateTagStack::addToStringStorage(), addZeroPrefixedInt(), advanceStringIndex(), allocateStringFn(), QWidgetLineControl::allSelected(), QQuickTextInputPrivate::allSelected(), append(), QCborStreamWriter::append(), QToolBarAreaLayout::apply(), QQmlJSLinter::applyFixes(), QIBaseResult::applyScale(), QV4::PropertyKey::asFunctionName(), Widget::atFunction(), QTextEngine::attributes(), QPainter::boundingRect(), QFontMetricsF::boundingRect(), QFontMetrics::boundingRect(), QFontMetrics::boundingRect(), QFontMetricsF::boundingRect(), QWaylandInputMethodEventBuilder::buildCommit(), QtWaylandClient::calculateOffset(), QV4::CompiledData::String::calculateSize(), QTextEngine::calculateTabWidth(), canonicalOrderHelper(), Utils::TextDocument::characterCount(), QMacSettingsPrivate::children(), QConfFileSettingsPrivate::children(), cleanPackageName(), QWidgetLineControl::clear(), QQuickTextInputPrivate::clear(), QXmlStreamReaderPrivate::clearSym(), QDateTimeEditPrivate::closestSection(), QLocalePrivate::codeToLanguage(), QLocalePrivate::codeToScript(), QLocalePrivate::codeToTerritory(), QQmlJS::Dom::LineWriter::column(), comify(), QQmlJS::Dom::LineWriter::commitLine(), QWindowsInputContext::composition(), computeElidedText(), QQmlNotifierEndpoint::connect(), QUnicodeTables::convertCase(), convertMnemonics(), convertToExtendedType(), count(), countRepeat(), QNetworkAccessFileBackendFactory::create(), QV4::Heap::StringOrSymbol::createHashValue(), QTextLayout::createLine(), createLinkTitle(), QToolBarAreaLayout::currentGapIndex(), QQmlJS::Dom::LineWriter::currentSourceLocation(), QTextLine::cursorToX(), dataToUrls(), QCalendarBackend::dateTimeToString(), decode(), decodeFsEncString(), QToolBarAreaLayout::deleteAllLayoutItems(), QQmlJSUtils::didYouMean(), directoryMatchesSize(), directorySizeDistance(), QSGInternalTextNode::doAddTextLayout(), doParseMountInfo(), QPdfSearchModelPrivate::doSearch(), QLocaleData::doubleToString(), QVideoTextureHelper::SubtitleLayout::draw(), QTextLayout::drawCursor(), QPainter::drawText(), QPainter::drawText(), QPainter::drawText(), QPainter::drawText(), QmlLsp::OpenDocumentSnapshot::dump(), QAbstractSpinBoxPrivate::editorCursorPositionChanged(), QDateTimeEditPrivate::editorCursorPositionChanged(), QTextEngine::elidedText(), encodeText(), QWidgetLineControl::end(), QQuickTextInputPrivate::end(), QWidgetLineControl::end(), QSettings::endArray(), QSettings::endGroup(), QQmlJS::Dom::LineWriter::endSourceLocation(), QQmlJS::Dom::LineWriter::ensureSpace(), QQmlJS::Dom::LineWriter::ensureSpace(), QRegularExpression::errorString(), QRegularExpression::escape(), QQmlCustomParser::evaluateEnum(), QMenu::event(), QSqlResult::exec(), QSQLiteResult::exec(), QBenchmarkValgrindUtils::extractResult(), QSvgText::fastBounds(), QDateTimeParser::fieldInfo(), fileFromPath(), QV4::Moth::BytecodeGenerator::finalize(), find_translation(), QStandardPaths::findExecutable(), findFilesRecursively(), findInBlock(), QTextEngine::findItem(), QtPrivate::findString(), findTextEntry(), QToolBarAreaLayout::findToolBar(), QQmlJS::Dom::LineWriter::flush(), QTextEngine::formatIndex(), QSqlDriver::formatValue(), QSqlRelationalTableModelPrivate::fullyQualifiedFieldName(), QToolBarAreaLayoutInfo::gapIndex(), generateFileName(), QV4::getElementIntFallback(), getMessage(), LiteralBindingCheckBase::getProperty(), QPdfDocument::getSelectionAtIndex(), QToolBarAreaLayout::getStyleOptionInfo(), QV4::RegExp::getSubstitution(), QRawFont::glyphIndexesForString(), QTextLayout::glyphRuns(), QXcbKeyboard::handleKeyEvent(), QQmlJS::Dom::LineWriter::handleTrailingSpace(), QTextHtmlParserNode::hasOnlyWhitespace(), Driver::headerFileName(), QCommandLineParserPrivate::helpText(), QtPrivate::QCalendarDateSectionValidator::highlightString(), QTextDocumentLayout::hitTest(), QFontMetrics::horizontalAdvance(), QFontMetrics::horizontalAdvance(), QFontMetricsF::horizontalAdvance(), QFontMetricsF::horizontalAdvance(), ignoreProxyFor(), QQmlConnectionSlotDispatcher::impl(), indexOf(), QToolBarAreaLayout::indexOf(), iniChopTrailingSpaces(), QSettingsPrivate::iniEscapedString(), QSettingsPrivate::iniUnescapedKey(), QSettingsPrivate::iniUnescapedStringList(), QWidgetTextControlPrivate::inputMethodEvent(), QTextDocumentPrivate::insert(), QQuickTextInput::insert(), insert(), insert(), QTextDocumentPrivate::insertBlock(), QToolBarAreaLayoutInfo::insertItem(), QTextCursor::insertText(), QToolBarAreaLayoutInfo::insertToolBarBreak(), QWindowsInputContext::invokeAction(), is_valid_domain_name(), QInputControl::isAcceptableInput(), QSqlDriver::isIdentifierEscaped(), QMYSQLDriver::isIdentifierEscaped(), QODBCDriver::isIdentifierEscaped(), QQmlFile::isLocalFile(), QAndroidPlatformIconEngine::isNull(), QWindowsIconEngine::isNull(), isParentOf(), QQmlFile::isSynchronous(), QTextLayout::isValidCursorPosition(), QToolBarAreaLayout::item(), QToolBarAreaLayout::itemAt(), QTextEngine::itemize(), QTextEngine::justify(), QuickTestEvent::keyClickChar(), QuickTestEvent::keyPressChar(), QMenu::keyPressEvent(), QMenuBar::keyPressEvent(), QTextEdit::keyPressEvent(), QAbstractSpinBox::keyPressEvent(), QuickTestEvent::keyReleaseChar(), QTextEngine::lineNumberForTextPosition(), QTranslator::load(), lookupVendorIdInSystemDatabase(), QSysInfo::machineHostName(), mangledIdentifier(), QDirListingPrivate::matchesFilters(), QMimeGlobPattern::matchFileName(), menuItemInfoSetText(), QV4::StringPrototype::method_charAt(), QV4::StringPrototype::method_charCodeAt(), QV4::StringIteratorPrototype::method_next(), QV4::StringPrototype::method_padEnd(), QV4::StringPrototype::method_padStart(), QV4::StringPrototype::method_replace(), QV4::StringPrototype::method_split(), mightBeRichTextImpl(), minimalPattern(), QKeySequence::mnemonic(), QQuickTextInput::moveCursorSelection(), QToolBarAreaLayoutInfo::moveToolBar(), QSqlResultPrivate::namedToPositionalBinding(), QV4::ExecutionEngine::newIdentifier(), StringObjectOwnPropertyKeyIterator::next(), QTextLayout::nextCursorPosition(), nextField(), QTextEngine::nextLogicalPosition(), nextNonWhitespace(), normalizationQuickCheckHelper(), QQmlError::operator<<(), QQuickStyledTextPrivate::parse(), QTextHtmlParser::parse(), parseAnimateColorNode(), parseAttributeValues(), QTestPrivate::parseBlackList(), parseColorValue(), parseFlags(), parseFont(), parseFontName(), SyncScanner::parseHeader(), QHttpHeaderParser::parseHeaders(), parseInt(), parseIntOption(), parseIp6(), parseIpFuture(), QQuickSvgParser::parsePathDataFast(), parsePathDataFast(), parseTransformationMatrix(), parseVersion(), QTextHtmlParser::parseWord(), QLoggingRule::pass(), performBitwiseOperationInPlace(), QWindowsFontDatabaseFT::populateFamily(), QWindowsFontDatabase::populateFamily(), QSqlResultPrivate::positionalToNamedBinding(), positionIsFollowedBySpaces(), QTextLayout::previousCursorPosition(), QTextEngine::previousLogicalPosition(), QWidgetLineControl::processInputMethodEvent(), QCss::Selector::pseudoClass(), pythonRoot(), QQmlTypeLoader::qmldirContent(), QQmlMetaType::qmlType(), qQmlJSSymbolNamespaceForPath(), QTest::qt_asprintf(), qt_cbor_decoder_advance(), qt_cbor_decoder_can_read(), qt_cbor_decoder_read(), qt_cbor_decoder_transfer_string(), qt_color_from_string(), qt_from_latin1_to_qvla(), qt_getEnglishName(), qt_mac_removeMnemonics(), QQC2_NAMESPACE::qt_mac_removeMnemonics(), qt_normalizePathSegments(), qt_punycodeDecoder(), qt_u_strToCase(), qtModule(), queryQtPaths(), quote(), QtPrivate::qustrchr(), readInputFile(), QWindowsInputContext::reconvertString(), QV4::Compiler::StringTableGenerator::registerString(), QQmlJS::Dom::IndentingLineWriter::reindentAndSplit(), remove(), QToolBarAreaLayout::remove(), QFileSystemEngine::removeDirectory(), QPlatformTheme::removeMnemonics(), QToolBarAreaLayoutInfo::removeToolBar(), QToolBarAreaLayoutInfo::removeToolBarBreak(), replace(), replace(), replace(), replace(), replacePercentN(), QTipLabel::restartExpireTimer(), runMoc(), runUic(), sanitizeNameForDBus(), QToolBarAreaLayout::saveState(), QWhatsThisPrivate::say(), QRhiD3D::sdrWhiteLevelInNits(), QDateTimeEditPrivate::sectionAt(), QDateTimeParser::sectionSize(), QWidgetLineControl::selectAll(), QQuickTextInputPrivate::selectAll(), QSqlTableModel::selectRow(), QLineEditPrivate::sendMouseEventToInputContext(), QQuickTextInputPrivate::sendMouseEventToInputContext(), serializeString(), set_text(), QSettings::setArrayIndex(), QUrl::setAuthority(), QQmlSslConfiguration::setCiphersList(), QQmlJS::Lexer::setCode(), QWidgetLineControl::setCursorPosition(), QQuickTextInputPrivate::setCursorPosition(), QFileDialogOptions::setDefaultSuffix(), QmlIR::IRBuilder::setId(), QQmlJS::Dom::LineWriter::setLineIndent(), QTextLine::setLineWidth(), setMonitorDataFromSetupApi(), QQuickTextInput::setPasswordCharacter(), Utils::TextDocument::setPlainText(), QUrl::setScheme(), QWidgetLineControl::setSelection(), QQuickTextInputPrivate::setSelection(), QQuickTextEdit::setText(), TileProvider::setupProvider(), QQuickTextPrivate::setupTextLayout(), QQmlPropertyCache::signalParameterStringForJS(), QStringAlgorithms< StringType >::simplified_helper(), Widget::sizeFunction(), QDateTimeParser::skipToNextSection(), splitIntoFamilies(), QV4::Heap::String::startsWithUpper(), QNetworkReplyWasmImplPrivate::stateChange(), QV4::CompiledData::Unit::stringAtInternal(), stringList_contains(), QSettingsPrivate::stringListToVariantList(), QQmlScriptString::stringLiteral(), QV4::stringToArrayIndex(), QSQLiteDriver::stripDelimiters(), QAbstractSpinBoxPrivate::stripped(), QToolBarAreaLayout::takeAt(), QLineEditPrivate::textChanged(), QQmlLSUtils::textOffsetFrom(), QFontMetrics::tightBoundingRect(), QFontMetricsF::tightBoundingRect(), QFontMetrics::tightBoundingRect(), QFontMetricsF::tightBoundingRect(), toDouble(), QIcc::toIccProfile(), QVideoTextureHelper::SubtitleLayout::toImage(), tokenizeLine(), QToolBarAreaLayout::toolBarBreak(), QIPAddressUtils::toString(), toVariant(), QQuickComboBoxPrivate::tryComplete(), QSystemLocalePrivate::uiLanguages(), QToolBarAreaLayout::unplug(), unquote(), QAbstractSpinBoxPrivate::updateEdit(), QDateTimeEditPrivate::updateEdit(), QQuickComboBoxPrivate::updateEditText(), QFileInfoGatherer::updateFile(), QQuickTextInputPrivate::updateHorizontalScroll(), QtWaylandClient::QWaylandTextInputv1::updateState(), QtWaylandClient::QWaylandTextInputv2::updateState(), QQuickTextInputPrivate::updateVerticalScroll(), QQmlImports::urlFromLocalFileOrQrcOrUrl(), QFileDialogPrivate::useNameFilter(), uuidFromString(), uuidFromString(), uuidFromString(), QSpinBoxValidator::validate(), QDateTimeEditPrivate::validateAndInterpret(), QLocaleData::validateChars(), QSSGQmlUtilities::valueToQml(), versionUriList(), TestHTTPServer::wait(), wrapInFunction(), wrapText(), write_pbm_image(), write_xbm_image(), QTextMarkdownWriter::writeBlock(), RCCFileInfo::writeDataName(), QTextMarkdownWriter::writeFrame(), QSSGMesh::MeshInternal::writeMeshData(), writeStr(), writeString(), xpmHash(), QTextLine::xToCursor(), and QLocaleData::zeroUcs().

◆ slice() [1/2]

QString & QString::slice ( qsizetype pos)
inline
Since
6.8 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Modifies this string to start at position pos and extending to its end, and returns a reference to this string.

Note
The behavior is undefined if pos < 0 or pos > size().
See also
sliced(), first(), last(), chopped(), chop(), truncate()

Definition at line 201 of file qstring.h.

References pos, and remove().

Referenced by Widget::sliceFunction().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ slice() [2/2]

QString & QString::slice ( qsizetype pos,
qsizetype n )
inline
Since
6.8

Modifies this string to start at position pos, extending for n characters (code points), and returns a reference to this string.

Note
The behavior is undefined if pos < 0, n < 0, or pos + n > size().
See also
sliced(), first(), last(), chopped(), chop(), truncate()

Definition at line 203 of file qstring.h.

References pos, remove(), and resize().

+ Here is the call graph for this function:

◆ sliced() [1/4]

QString QString::sliced ( qsizetype pos) &&
inline

Definition at line 409 of file qstring.h.

References pos.

◆ sliced() [2/4]

◆ sliced() [3/4]

QString QString::sliced ( qsizetype pos,
qsizetype n ) &&
inline

Definition at line 411 of file qstring.h.

References pos.

◆ sliced() [4/4]

QString QString::sliced ( qsizetype pos,
qsizetype n ) const &
inline

Definition at line 396 of file qstring.h.

References begin(), and pos.

+ Here is the call graph for this function:

◆ split() [1/3]

QStringList QString::split ( const QRegularExpression & sep,
Qt::SplitBehavior behavior = Qt::KeepEmptyParts ) const

◆ split() [2/3]

QStringList QString::split ( const QString & sep,
Qt::SplitBehavior behavior = Qt::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 Qt::SkipEmptyParts, empty entries don't appear in the result. By default, empty entries are kept.

Example:

QString str = QStringLiteral("a,,b,c");
QStringList list1 = str.split(u',');
// list1: [ "a", "", "b", "c" ]
// list2: [ "a", "b", "c" ]

If sep is empty, split() returns an empty string, followed by each of the string's characters, followed by another empty string:

QString str = "abc";
auto parts = str.split(QString());
// parts: {"", "a", "b", "c", ""}

To understand this behavior, recall that the empty string matches everywhere, so the above is qualitatively the same as:

QString str = "/a/b/c/";
auto parts = str.split(u'/');
// parts: {"", "a", "b", "c", ""}
See also
QStringList::join(), section()
Since
5.14

Definition at line 8218 of file qstring.cpp.

References sep.

Referenced by QEvdevTouchScreenHandler::QEvdevTouchScreenHandler(), CPP::WriteDeclaration::acceptUI(), QSSGRuntimeUtils::applyPropertyValue(), buildAndroidProject(), QmlLsp::QQmlCodeModel::buildPathsForFileUrl(), QSSGShaderCache::compileForRhi(), QtWaylandClient::convertData(), QLinuxMediaDevice::deviceName(), QGeoFileTileCacheMapbox::filenameToTileSpec(), QGeoFileTileCacheNokia::filenameToTileSpec(), QGeoFileTileCacheOsm::filenameToTileSpec(), QGeoFileTileCache::filenameToTileSpecDefault(), FolderIterator::fileType(), Parser::findEnumValues(), fixupFramework(), QPageRanges::fromString(), QQuickQmlGenerator::generateRootNode(), QQmlToolingUtils::getAndWarnForInvalidDirsFromEnv(), ignoreProxyFor(), QQmlJS::Dom::Binding::isSignalHandler(), QKeySequence::listFromString(), QEvdevKeyboardManager::loadKeymap(), mergeGradleProperties(), QV4::QQmlXMLHttpRequestCtor::method_overrideMimeType(), QXcbMime::mimeConvertToFormat(), AndroidContentFileEngine::mkdir(), QQmlError::operator<<(), parseAnimateColorNode(), parseArguments(), QGeoTiledMappingManagerEngineNokia::parseNewVersionInfo(), QQmlJS::Dom::ModuleIndex::qmldirsToLoad(), QAndroidSystemLocale::query(), readInputFile(), QtWaylandClient::QWaylandDisplay::registry_global(), QV4::UrlObject::setHost(), QQuick3DRenderStatsMeshesModel::setMeshData(), QQuick3DRenderStatsPassesModel::setPassData(), QQuick3DRenderStatsTexturesModel::setTextureData(), Widget::splitCaseSensitiveFunction(), Widget::splitFunction(), splitIntoFamilies(), stringToList(), QCtfLibImpl::tracepointEnabled(), and QFileDialogPrivate::typedFiles().

+ Here is the caller graph for this function:

◆ split() [3/3]

QStringList QString::split ( QChar sep,
Qt::SplitBehavior behavior = Qt::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.

Since
5.14

Definition at line 8227 of file qstring.cpp.

References sep.

◆ 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 1333 of file qstring.h.

References capacity, d, and QArrayData::KeepSize.

◆ 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.

{search-comparison-case-sensitivity} {search}

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

Definition at line 5455 of file qstring.cpp.

Referenced by QFactoryLoader::QFactoryLoader(), QQuickGridScaledImage::QQuickGridScaledImage(), QPixmapIconEngine::addFile(), QQmlImports::addFileImport(), addFontToDatabase(), addFontToDatabase(), Parser::addIncludesRecursive(), QFileSystemWatcher::addPaths(), QFseventsFileSystemWatcherEngine::addPaths(), QFileDialogPrivate::autoCompleteFileName(), QQmlJS::Dom::PathEls::Filter::checkName(), QMacSettingsPrivate::children(), QQmlPreviewFileEngineHandler::create(), QIBusPlatformInputContextPrivate::createConnection(), createImageNode(), QCalendarBackend::dateTimeToString(), deployPlugin(), deployPlugins(), deployQmlImports(), dirsList(), doFilter(), QPdfEnginePrivate::drawTextItem(), QDB2Driver::escapeIdentifier(), QIBaseDriver::escapeIdentifier(), QMimerSQLDriver::escapeIdentifier(), QMYSQLDriver::escapeIdentifier(), QODBCDriver::escapeIdentifier(), QPSQLDriver::escapeIdentifier(), QBenchmarkValgrindUtils::extractResult(), fileArchitecture(), QIOSFileEngineAssetsLibrary::fileFlags(), QCompletionEngine::filterHistory(), QNetworkAuthenticationCache::findClosestMatch(), QQuickControlsTestUtils::forEachControl(), QDirectFbBlitterPlatformPixmap::fromFile(), getLibraryProjectsInOutputFolder(), getQtLibsFromElf(), QSSGInputUtil::getStreamForFile(), QSettingsPrivate::iniEscapedString(), TileProvider::isHTTPS(), QSqlDriver::isIdentifierEscaped(), QMYSQLDriver::isIdentifierEscaped(), QODBCDriver::isIdentifierEscaped(), QQmlFile::isLocalFile(), isParentOf(), QCoreTextFontDatabase::isPrivateFontFamily(), itemToDialogUrl(), launchMail(), QHostInfo::localDomainName(), lookupVendorIdInSystemDatabase(), mangledIdentifier(), matchesSeparator(), QPdfDocument::metaData(), QMimeDatabase::mimeTypeForUrl(), QNetworkCookie::normalize(), objectPathIsForThisDevice(), QV4::Script::parse(), Parser::parse(), QTestPrivate::parseBlackList(), parseColorValue(), parseExtendedAttributes(), QAuthenticatorPrivate::parseHttpResponse(), parseIntOption(), parseProvider(), preprocessMetadata(), QGlobalNetworkProxy::proxyForQuery(), qmlsqldatabase_executeSql(), qQmlJSSymbolNamespaceForPath(), qRelocateResourceFile(), qt_punycodeDecoder(), qtModule(), QAndroidSystemLocale::query(), queryQtPaths(), readGradleProperties(), QConfFileSettingsPrivate::readIniFile(), QConfFileSettingsPrivate::readIniSection(), QDir::relativeFilePath(), QPlatformTheme::removeMnemonics(), removeOptionalQuotes(), QUrl::resolved(), QDomEntityPrivate::save(), QDeviceDiscoveryUDev::scanConnectedDevices(), QFileDialogOptions::setDefaultSuffix(), QV4::UrlObject::setSearch(), QNdefNfcUriRecord::setUri(), splitIntoFamilies(), Widget::startsWithFunction(), QSettingsPrivate::stringListToVariantList(), QAbstractSpinBoxPrivate::stripped(), styleUri(), QQmlDataTest::testFileUrl(), QNetworkCookie::toRawForm(), QUrl::toString(), QQuickComboBoxPrivate::tryComplete(), QGeoMapMapboxGLPrivate::updateSceneGraph(), QV4::UrlCtor::virtualCallAsConstructor(), QQmlJSImportVisitor::visit(), QDockWidgetLayout::wmSupportsNativeWindowDeco(), and QSSGQmlUtilities::writeNodeProperties().

◆ startsWith() [2/4]

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

Definition at line 5474 of file qstring.cpp.

References at, Qt::CaseSensitive, and foldCase().

+ Here is the call graph for this function:

◆ startsWith() [3/4]

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

Definition at line 5463 of file qstring.cpp.

◆ startsWith() [4/4]

bool QString::startsWith ( QStringView str,
Qt::CaseSensitivity cs = Qt::CaseSensitive ) const
inlinenoexcept
Since
5.10 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Returns true if the string starts with the string view str; otherwise returns false.

{search-comparison-case-sensitivity} {search}

See also
endsWith()

Definition at line 417 of file qstring.h.

References QtPrivate::startsWith().

+ Here is the call graph for this function:

◆ swap()

void QString::swap ( QString & other)
inlinenoexcept
Since
4.8

Swaps string other with this string. This operation is very fast and never fails.

Definition at line 185 of file qstring.h.

References d, and other().

Referenced by insert_helper(), prepareForBitwiseOperation(), and replace_with_copy().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ toCaseFolded() [1/2]

QString QString::toCaseFolded ( ) &&
inline

Definition at line 445 of file qstring.h.

◆ toCaseFolded() [2/2]

QString QString::toCaseFolded ( ) const &
inline

Definition at line 443 of file qstring.h.

Referenced by QFontconfigDatabase::fallbacksForFamily().

+ Here is the caller graph for this function:

◆ toDouble()

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

Returns the string converted to a double value.

Returns an infinity if the conversion overflows or 0.0 if the conversion fails for other reasons (e.g. underflow).

If ok is not \nullptr, failure is reported by setting *{ok} to false, and success by setting *{ok} to true.

QString str = "1234.56";
double val = str.toDouble(); // val == 1234.56
Warning
The QString content may only contain valid numerical characters which includes the plus/minus sign, the character e used in scientific notation, and the decimal point. Including the unit or additional characters leads to a conversion error.
bool ok;
double d;
d = QString( "1234.56e-02" ).toDouble(&ok); // ok == true, d == 12.3456
d = QString( "1234.56e-02 Volt" ).toDouble(&ok); // ok == false, d == 0

The string conversion will always happen in the 'C' locale. For locale-dependent conversion use QLocale::toDouble()

d = QString( "1234,56" ).toDouble(&ok); // ok == false
d = QString( "1234.56" ).toDouble(&ok); // ok == true, d == 1234.56

For historical reasons, this function does not handle thousands group separators. If you need to convert such numbers, use QLocale::toDouble().

d = QString( "1,234,567.89" ).toDouble(&ok); // ok == false
d = QString( "1234567.89" ).toDouble(&ok); // ok == true

This function ignores leading and trailing whitespace.

See also
number(), QLocale::setDefault(), QLocale::toDouble(), trimmed()

Definition at line 7904 of file qstring.cpp.

References ok, and QStringView::toDouble().

Referenced by qEnvironmentVariableOptionalReal(), setWidthAttribute(), Widget::toDoubleFunction(), and wrapInFunction().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ toFloat()

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

Returns the string converted to a float value.

Returns an infinity if the conversion overflows or 0.0 if the conversion fails for other reasons (e.g. underflow).

If ok is not \nullptr, failure is reported by setting *{ok} to false, and success by setting *{ok} to true.

Warning
The QString content may only contain valid numerical characters which includes the plus/minus sign, the character e used in scientific notation, and the decimal point. Including the unit or additional characters leads to a conversion error.

The string conversion will always happen in the 'C' locale. For locale-dependent conversion use QLocale::toFloat()

For historical reasons, this function does not handle thousands group separators. If you need to convert such numbers, use QLocale::toFloat().

Example:

QString str1 = "1234.56";
str1.toFloat(); // returns 1234.56
bool ok;
QString str2 = "R2D2";
str2.toFloat(&ok); // returns 0.0, sets ok to false
QString str3 = "1234.56 Volt";
str3.toFloat(&ok); // returns 0.0, sets ok to false

This function ignores leading and trailing whitespace.

See also
number(), toDouble(), toInt(), QLocale::toFloat(), trimmed()

Definition at line 7950 of file qstring.cpp.

References QLocaleData::convertDoubleToFloat(), ok, and toDouble().

Referenced by QPrintPreviewDialogPrivate::_q_zoomFactorChanged(), QGnomeThemePrivate::configureFonts(), Widget::toFloatFunction(), and wrapInFunction().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ toHtmlEscaped()

QString QString::toHtmlEscaped ( ) const
Since
5.0

Converts a plain text string to an HTML string with HTML metacharacters {<}, {>}, {&}, and {"} replaced by HTML entities.

Example:

QString plain = "#include <QtCore>"
QString html = plain.toHtmlEscaped();
// html == "#include &lt;QtCore&gt;"

Definition at line 10174 of file qstring.cpp.

References ch, QStringView::first(), pos, qToStringViewIgnoringNull(), and QStringView::sliced().

Referenced by QtAndroidDialogHelpers::htmlText(), and QSvgVisitorImpl::visitTextNode().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ toInt()

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

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 ok is not \nullptr, failure is reported by setting *{ok} to false, and success by setting *{ok} to true.

If base is 0, the C language convention is used: if the string begins with "0x", base 16 is used; otherwise, if the string begins with "0b", base 2 is used; otherwise, if the string begins with "0", base 8 is used; otherwise, base 10 is used.

The string conversion will always happen in the 'C' locale. For locale-dependent conversion use QLocale::toInt()

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

This function ignores leading and trailing whitespace.

Note
Support for the "0b" prefix was added in Qt 6.4.
See also
number(), toUInt(), toDouble(), QLocale::toInt()

Definition at line 731 of file qstring.h.

References base, and ok.

Referenced by GeoTiledMappingManagerEngineEsri::GeoTiledMappingManagerEngineEsri(), QGeoMappingManagerEngineMapboxGL::QGeoMappingManagerEngineMapboxGL(), QGeoTiledMappingManagerEngineMapbox::QGeoTiledMappingManagerEngineMapbox(), QGeoTiledMappingManagerEngineNokia::QGeoTiledMappingManagerEngineNokia(), QGeoTiledMappingManagerEngineOsm::QGeoTiledMappingManagerEngineOsm(), QQuickGridScaledImage::QQuickGridScaledImage(), QPrintPreviewDialogPrivate::_q_pageNumEdited(), checked_var_value(), QIBusPlatformInputContextPrivate::createConnection(), GeoMapSource::mapStyle(), Recognizer::parse(), QMimeTypeParserBase::parse(), parseCmakeBoolean(), parseEarlyArguments(), parseIntOption(), QHttpHeaderParser::parseStatus(), parseVersion(), qtVersion(), QGLXContext::queryDummyContext(), runRcc(), setAVMetadataItemForKey(), QFontDialogPrivate::sizeChanged(), sql_intro_snippets(), QPpdPrintDevice::state(), Widget::toIntFunction(), QFontDialogPrivate::updateSample(), and wrapInFunction().

+ Here is the caller graph for this function:

◆ tokenize() [1/3]

template<typename Needle , typename... Flags>
auto QString::tokenize ( Needle && needle,
Flags... flags ) && -> decltype(qTokenize(std::move(*this), std::forward<Needle>(needle), flags...))
inlinenoexcept

Definition at line 611 of file qstring.h.

References qTokenize().

+ Here is the call graph for this function:

◆ tokenize() [2/3]

template<typename Needle , typename... Flags>
auto QString::tokenize ( Needle && needle,
Flags... flags ) const && -> decltype(qTokenize(std::move(*this), std::forward<Needle>(needle), flags...))
inlinenoexcept

Definition at line 605 of file qstring.h.

References qTokenize().

+ Here is the call graph for this function:

◆ tokenize() [3/3]

template<typename Needle , typename... Flags>
auto QString::tokenize ( Needle && needle,
Flags... flags ) const & -> decltype(qTokenize(*this, std::forward<Needle>(needle), flags...))
inlinenoexcept

Definition at line 599 of file qstring.h.

References qTokenize(), and qToStringViewIgnoringNull().

Referenced by qt_getImageTextFromDescription(), and QDir::relativeFilePath().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ toLatin1() [1/2]

QByteArray QString::toLatin1 ( ) &&
inline

Definition at line 632 of file qstring.h.

◆ toLatin1() [2/2]

QByteArray QString::toLatin1 ( ) const &
inline

Definition at line 630 of file qstring.h.

Referenced by GeoCodingManagerEngineEsri::GeoCodingManagerEngineEsri(), GeoRoutingManagerEngineEsri::GeoRoutingManagerEngineEsri(), GeoTiledMappingManagerEngineEsri::GeoTiledMappingManagerEngineEsri(), QEglFSKmsScreen::QEglFSKmsScreen(), QGeoCodingManagerEngineMapbox::QGeoCodingManagerEngineMapbox(), QGeoCodingManagerEngineOsm::QGeoCodingManagerEngineOsm(), QGeoRoutingManagerEngineMapbox::QGeoRoutingManagerEngineMapbox(), QGeoRoutingManagerEngineOsm::QGeoRoutingManagerEngineOsm(), QGeoTiledMappingManagerEngineMapbox::QGeoTiledMappingManagerEngineMapbox(), QGeoTiledMappingManagerEngineOsm::QGeoTiledMappingManagerEngineOsm(), QPlaceManagerEngineMapbox::QPlaceManagerEngineMapbox(), QPlaceManagerEngineOsm::QPlaceManagerEngineOsm(), QGeoFileTileCache::~QGeoFileTileCache(), QAbstractSocketPrivate::_q_connectToNextAddress(), QSSGRenderReflectionMap::addReflectionMapEntry(), QImageReaderWriterHelpers::appendImagePluginMimeTypes(), QQuickAnimatorPrivate::apply(), QSocks5PasswordAuthenticator::beginAuthenticate(), QSctpSocketPrivate::canReadNotification(), QLocalePrivate::codeToScript(), QAbstractSocket::connectToHost(), convertToExtendedType(), createReadHandlerHelper(), createWriteHandlerHelper(), QDeclarativeSearchResultModel::data(), QAuthenticatorPrivate::digestMd5Response(), QPainter::drawText(), QPainter::drawText(), QPainter::drawText(), QPainter::drawText(), QPdfEnginePrivate::drawTextItem(), QuickTestResult::expectFail(), QAbstractSocketPrivate::fetchConnectionParameters(), QNativeSocketEnginePrivate::fetchConnectionParameters(), QGtk3Interface::fileIcon(), QHostInfoAgent::fromName(), getQtLibsFromElf(), QSSGInputUtil::getStreamForTextureFile(), getWinLocaleName(), QHttpNetworkRequestPrivate::header(), QGeoSatelliteInfoSourceGypsy::init(), QAbstractSocketPrivate::initSocketLayer(), QHostInfoAgent::lookup(), QSysInfo::machineUniqueId(), makeCacheKey(), msgConnect(), openFramebufferDevice(), QDateTimeParser::parse(), QHttpNetworkConnectionPrivate::prepareRequest(), qDecodeDataUrl(), QImageReader::read(), QAbstractSocketPrivate::readFromSocket(), QXcbDropData::retrieveData_sys(), QDeclarativeGeoMap::setActiveMapType(), QTextBrowserPrivate::setSource(), QXcbWindow::setWindowRole(), QHttpSocketEngine::slotSocketConnected(), QUrl::toAce(), toDouble(), toDouble(), QUrl::toEncoded(), updateStringsXml(), QTextDocumentWriter::write(), QPNGImageWriter::writeImage(), QPdfEnginePrivate::writeTail(), and QSctpSocketPrivate::writeToSocket().

◆ toLocal8Bit() [1/2]

QByteArray QString::toLocal8Bit ( ) &&
inline

Definition at line 640 of file qstring.h.

◆ toLocal8Bit() [2/2]

◆ toLong()

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

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 ok is not \nullptr, failure is reported by setting *{ok} to false, and success by setting *{ok} to true.

If base is 0, the C language convention is used: if the string begins with "0x", base 16 is used; otherwise, if the string begins with "0b", base 2 is used; otherwise, if the string begins with "0", base 8 is used; otherwise, base 10 is used.

The string conversion will always happen in the 'C' locale. For locale-dependent conversion use QLocale::toLongLong()

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

This function ignores leading and trailing whitespace.

Note
Support for the "0b" prefix was added in Qt 6.4.
See also
number(), toULong(), toInt(), QLocale::toInt()

Definition at line 735 of file qstring.h.

References base, and ok.

Referenced by Widget::toLongFunction(), and wrapInFunction().

+ Here is the caller graph for this function:

◆ toLongLong()

QString::toLongLong ( bool * ok = nullptr,
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 ok is not \nullptr, failure is reported by setting *{ok} to false, and success by setting *{ok} to true.

If base is 0, the C language convention is used: if the string begins with "0x", base 16 is used; otherwise, if the string begins with "0b", base 2 is used; otherwise, if the string begins with "0", base 8 is used; otherwise, base 10 is used.

The string conversion will always happen in the 'C' locale. For locale-dependent conversion use QLocale::toLongLong()

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

This function ignores leading and trailing whitespace.

Note
Support for the "0b" prefix was added in Qt 6.4.
See also
number(), toULongLong(), toInt(), QLocale::toLongLong()

Referenced by Widget::toLongLongFunction().

+ Here is the caller graph for this function:

◆ toLower() [1/2]

QString QString::toLower ( ) &&
inline

Definition at line 437 of file qstring.h.

◆ toLower() [2/2]

QString QString::toLower ( ) const &
inline

Definition at line 435 of file qstring.h.

Referenced by GeoTiledMappingManagerEngineEsri::GeoTiledMappingManagerEngineEsri(), QGeoTiledMappingManagerEngineMapbox::QGeoTiledMappingManagerEngineMapbox(), QGeoTiledMappingManagerEngineNokia::QGeoTiledMappingManagerEngineNokia(), QGeoTiledMappingManagerEngineOsm::QGeoTiledMappingManagerEngineOsm(), QMimeBinaryProvider::addFileNameMatches(), QMimeAllGlobPatterns::addGlob(), QQmlEngine::addImageProvider(), QODBCDriverPrivate::adjustCase(), QCss::StyleSheet::buildIndexes(), QLocalePrivate::codeToLanguage(), QLocalePrivate::codeToScript(), comify(), QMacMimeFileUri::convertToMime(), QMacMimeUrl::convertToMime(), QPlatformInputContextFactory::create(), MyStylePlugin::create(), createReadHandlerHelper(), createWriteHandlerHelper(), QCalendarBackend::dateTimeToString(), Recognizer::expand(), find_translation(), getFontWeight(), QSSGAssetImportManager::getOptionsForFile(), QTextStreamPrivate::getReal(), QQmlEngine::imageProvider(), QQmlEnginePrivate::imageProvider(), QSSGAssetImportManager::importFile(), QSortedModelEngine::indexHint(), QFont::insertSubstitution(), QFont::insertSubstitutions(), QCompletionEngine::lookupCache(), QMimeGlobPattern::matchFileName(), QCompletionEngine::matchHint(), QMimeAllGlobPatterns::matchingGlobs(), moduleNameToOptionName(), QFileSystemModelPrivate::node(), QTextHtmlStyleSelector::nodeNames(), QDateTimeParser::parse(), QTextHtmlParser::parseAttributes(), QTextHtmlParser::parseCloseTag(), QTextHtmlParser::parseTag(), QQuickNinePatchImage::pixmapChange(), Q_GLOBAL_STATIC_WITH_ARGS(), QQmlEngine::removeImageProvider(), QFont::removeSubstitutions(), QComboBoxPrivate::returnPressed(), QCompletionEngine::saveInCache(), QQuickShapePrivate::selectRendererType(), QDesktopServices::setUrlHandler(), QFont::substitutes(), QLocale::toLower(), Widget::toLowerFunction(), QSvgVisitorImpl::visitTextNode(), QXcbConnection::windowManagerName(), QTextDocumentWriter::write(), DomUI::write(), DomIncludes::write(), DomInclude::write(), DomResources::write(), DomResource::write(), DomActionGroup::write(), DomAction::write(), DomActionRef::write(), DomButtonGroup::write(), DomButtonGroups::write(), DomCustomWidgets::write(), DomHeader::write(), DomCustomWidget::write(), DomLayoutDefault::write(), DomLayoutFunction::write(), DomTabStops::write(), DomLayout::write(), DomLayoutItem::write(), DomRow::write(), DomColumn::write(), DomItem::write(), DomWidget::write(), DomSpacer::write(), DomColor::write(), DomGradientStop::write(), DomGradient::write(), DomBrush::write(), DomColorRole::write(), DomColorGroup::write(), DomPalette::write(), DomFont::write(), DomPoint::write(), DomRect::write(), DomLocale::write(), DomSizePolicy::write(), DomSize::write(), DomDate::write(), DomTime::write(), DomDateTime::write(), DomStringList::write(), DomResourcePixmap::write(), DomResourceIcon::write(), DomString::write(), DomPointF::write(), DomRectF::write(), DomSizeF::write(), DomChar::write(), DomUrl::write(), DomProperty::write(), DomConnections::write(), DomConnection::write(), DomConnectionHints::write(), DomConnectionHint::write(), DomDesignerData::write(), DomSlots::write(), DomPropertySpecifications::write(), DomPropertyToolTip::write(), and DomStringPropertySpecification::write().

◆ toShort()

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

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 ok is not \nullptr, failure is reported by setting *{ok} to false, and success by setting *{ok} to true.

If base is 0, the C language convention is used: if the string begins with "0x", base 16 is used; otherwise, if the string begins with "0b", base 2 is used; otherwise, if the string begins with "0", base 8 is used; otherwise, base 10 is used.

The string conversion will always happen in the 'C' locale. For locale-dependent conversion use QLocale::toShort()

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

This function ignores leading and trailing whitespace.

Note
Support for the "0b" prefix was added in Qt 6.4.
See also
number(), toUShort(), toInt(), QLocale::toShort()

Definition at line 727 of file qstring.h.

References base, and ok.

Referenced by Widget::toShortFunction().

+ Here is the caller graph for this function:

◆ 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 toUtf8() function.

This method is mostly useful to pass a QString to a function that accepts a std::string object.

See also
toLatin1(), toUtf8(), toLocal8Bit(), QByteArray::toStdString()

Definition at line 1444 of file qstring.h.

Referenced by qstdweb::FileUrlRegistration::~FileUrlRegistration(), QWasmVideoOutput::createVideoElement(), QWasmLocalStorageSettingsPrivate::get(), QFileDialog::getOpenFileContent(), QLinuxMediaDevice::parseLink(), QLinuxMediaDevice::parsePad(), QWasmLocalStorageSettingsPrivate::remove(), QWasmLocalStorageSettingsPrivate::set(), QWasmAudioOutput::setSource(), and TitleBar::setTitle().

+ Here is the caller graph for this function:

◆ toStdU16String()

std::u16string QString::toStdU16String ( ) const
inline
Since
5.5

Returns a std::u16string object with the data contained in this QString. The Unicode data is the same as returned by the utf16() method.

See also
utf16(), toStdWString(), toStdU32String()

Definition at line 1464 of file qstring.h.

◆ toStdU32String()

std::u32string QString::toStdU32String ( ) const
inline
Since
5.5

Returns a std::u32string object with the data contained in this QString. The Unicode data is the same as returned by the toUcs4() method.

See also
toUcs4(), toStdWString(), toStdU16String()

Definition at line 1470 of file qstring.h.

Referenced by qt_punycodeDecoder().

+ Here is the caller graph for this function:

◆ toStdWString()

std::wstring QString::toStdWString ( ) const
inline

Returns a std::wstring object with the data contained in this QString.

The std::wstring is encoded in UTF-16 on platforms where wchar_t is 2 bytes wide (for example, Windows) and in UTF-32 on platforms where wchar_t is 4 bytes wide (most Unix systems).

This method is mostly useful to pass a QString to a function that accepts a std::wstring object.

See also
utf16(), toLatin1(), toUtf8(), toLocal8Bit(), toStdU16String(), toStdU32String()

Definition at line 1450 of file qstring.h.

References data(), resize(), and str.

Referenced by QWindowsDirect2DIntegration::create(), and operator<<().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ toUcs4()

QList< uint > QString::toUcs4 ( ) const
Since
4.2

Returns a UCS-4/UTF-32 representation of the string as a QList<uint>.

UCS-4 is a Unicode codec and therefore it is lossless. All characters from this string will be encoded in UCS-4. Any invalid sequence of code units in this string is replaced by the Unicode's replacement character (QChar::ReplacementCharacter, which corresponds to {U+FFFD}).

The returned list is not \0'-terminated.

See also
fromUtf8(), toUtf8(), toLatin1(), toLocal8Bit(), QStringEncoder, fromUcs4(), toWCharArray()

Definition at line 5823 of file qstring.cpp.

References qt_convert_to_ucs4().

+ Here is the call graph for this function:

◆ toUInt()

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

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 ok is not \nullptr, failure is reported by setting *{ok} to false, and success by setting *{ok} to true.

If base is 0, the C language convention is used: if the string begins with "0x", base 16 is used; otherwise, if the string begins with "0b", base 2 is used; otherwise, if the string begins with "0", base 8 is used; otherwise, base 10 is used.

The string conversion will always happen in the 'C' locale. For locale-dependent conversion use QLocale::toUInt()

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

This function ignores leading and trailing whitespace.

Note
Support for the "0b" prefix was added in Qt 6.4.
See also
number(), toInt(), QLocale::toUInt()

Definition at line 733 of file qstring.h.

References base, and ok.

Referenced by runRcc(), Widget::toUIntFunction(), and QIBusPlatformInputContext::update().

+ Here is the caller graph for this function:

◆ toULong()

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

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 ok is not \nullptr, failure is reported by setting *{ok} to false, and success by setting *{ok} to true.

If base is 0, the C language convention is used: if the string begins with "0x", base 16 is used; otherwise, if the string begins with "0b", base 2 is used; otherwise, if the string begins with "0", base 8 is used; otherwise, base 10 is used.

The string conversion will always happen in the 'C' locale. For locale-dependent conversion use QLocale::toULongLong()

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

This function ignores leading and trailing whitespace.

Note
Support for the "0b" prefix was added in Qt 6.4.
See also
number(), QLocale::toUInt()

Definition at line 737 of file qstring.h.

References base, and ok.

Referenced by Widget::toULongFunction().

+ Here is the caller graph for this function:

◆ toULongLong()

QString::toULongLong ( bool * ok = nullptr,
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 ok is not \nullptr, failure is reported by setting *{ok} to false, and success by setting *{ok} to true.

If base is 0, the C language convention is used: if the string begins with "0x", base 16 is used; otherwise, if the string begins with "0b", base 2 is used; otherwise, if the string begins with "0", base 8 is used; otherwise, base 10 is used.

The string conversion will always happen in the 'C' locale. For locale-dependent conversion use QLocale::toULongLong()

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

This function ignores leading and trailing whitespace.

Note
Support for the "0b" prefix was added in Qt 6.4.
See also
number(), toLongLong(), QLocale::toULongLong()

Referenced by Widget::toULongLongFunction().

+ Here is the caller graph for this function:

◆ toUpper() [1/2]

QString QString::toUpper ( ) &&
inline

Definition at line 441 of file qstring.h.

◆ toUpper() [2/2]

◆ toUShort()

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

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 ok is not \nullptr, failure is reported by setting *{ok} to false, and success by setting *{ok} to true.

If base is 0, the C language convention is used: if the string begins with "0x", base 16 is used; otherwise, if the string begins with "0b", base 2 is used; otherwise, if the string begins with "0", base 8 is used; otherwise, base 10 is used.

The string conversion will always happen in the 'C' locale. For locale-dependent conversion use QLocale::toUShort()

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

This function ignores leading and trailing whitespace.

Note
Support for the "0b" prefix was added in Qt 6.4.
See also
number(), toShort(), QLocale::toUShort()

Definition at line 729 of file qstring.h.

References base, and ok.

Referenced by Widget::toUShortFunction().

+ Here is the caller graph for this function:

◆ toUtf8() [1/2]

QByteArray QString::toUtf8 ( ) &&
inline

Definition at line 636 of file qstring.h.

◆ toUtf8() [2/2]

QByteArray QString::toUtf8 ( ) const &
inline

Definition at line 634 of file qstring.h.

Referenced by _q_lower(), _q_upper(), QCborStreamWriter::append(), QtStringBuilder::appendToByteArray(), applyMetaDataToTagSetter(), buildAndroidProject(), byteArrayFromBuffer(), QmlLsp::codeActionHandler(), computeFaceIndex(), QLowEnergyControllerPrivateWinRT::connectToDevice(), QWindowsMimeHtml::convertFromMime(), convertToExtendedType(), QWindowsMimeText::convertToMime(), QXcbWindow::create(), QGtk3MenuItem::create(), QRhiMetal::create(), QQuickDragAttachedPrivate::createMimeData(), QQmlTableModel::data(), QQmlDelegateChooser::delegate(), deserializeBlockMemberVar(), deserializeInOutVar(), QNetworkReplyWasmImplPrivate::doSendRequest(), QCtfLibImpl::doTracepoint(), dumpAttributeVariant(), QQmlCustomParser::evaluateEnum(), QODBCResult::exec(), QPSQLDriverPrivate::exec(), QuickTestResult::expectFailContinue(), QFontconfigDatabase::fallbacksForFamily(), FontProvider::fetchFont(), genVulkanFunctionsPC(), QWaylandMimeHelper::getByteArray(), QNearFieldTargetPrivateImpl::getTagTechnology(), QQnxClipboard::MimeData::hasFormat(), host_name_to_settings_key(), QWaylandInputMethodEventBuilder::indexFromWayland(), QWaylandInputMethodEventBuilder::indexToWayland(), QQmlDelegateModelItemMetaType::initializeMetaObject(), QBasicPlatformVulkanInstance::initInstance(), QQmlPrivate::initValueLookup(), QuickTestResultPrivate::intern(), QQnxAbstractNavigator::invokeUrl(), QShaderDescriptionPrivate::loadFromStream(), makeCacheKey(), QDBusMessagePrivate::makeLocal(), QmlLsp::messageToDiagnostic_helper(), QV4::QQmlXMLHttpRequestCtor::method_send(), QQmlEngine::offlineStorageDatabaseFilePath(), QMimerSQLDriver::open(), QMYSQLDriver::open(), AndroidAbstractFileEngine::open(), QFFmpeg::EncodingFormatContext::openAVIO(), operator>>(), Moc::parsePluginData(), QSSGBufferManager::primitivePath(), QQmlRangeFormatting::process(), Q_LOGGING_CATEGORY(), qDBusPropertyGet(), qDBusPropertySet(), qFillBufferWithString(), qRelocateResourceFile(), qSaveQmlJSUnitAsCpp(), qt_color_from_string(), RCCResourceLibrary::readFiles(), readInputFile(), QMYSQLDriver::record(), QQmlMetaType::registerPluginTypes(), QtQuickControls2Plugin::registerTypes(), removePendingQPropertyBinding(), QFontconfigDatabase::resolveFontFamilyAlias(), QSSGShaderUtils::resolveShader(), QQnxClipboard::MimeData::retrieveData(), QHeaderDataProxyModel::roleNames(), QmlTypeRegistrar::runExtract(), runRcc(), QPSQLDriverPrivate::sendQuery(), QQmlTableModel::setData(), AndroidAbstractFileEngine::setFileName(), QPdfDocument::setPassword(), QGtk3MenuItem::setText(), QNdefNfcUriRecord::setUri(), QQmlDMAbstractItemModelData::setValue(), QXcbWindow::setWindowIconText(), QDomDocument::toByteArray(), QDBusMessagePrivate::toDBusMessage(), QQmlPropertyCache::toMetaObjectBuilder(), QNetworkCookie::toRawForm(), QV4::ExecutableCompilationUnit::translateFrom(), QWaylandInputMethodEventBuilder::trimmedIndexFromWayland(), QtQuickControls2Plugin::unregisterTypes(), QQuickListViewPrivate::updateSectionCriteria(), QtWaylandClient::QWaylandTextInputv1::updateState(), QtWaylandClient::QWaylandTextInputv2::updateState(), QtWaylandClient::QWaylandTextInputv3::updateState(), ModelNodeMetaObject::updateValues(), ModelNodeMetaObject::updateValues(), VDMAbstractItemModelDataType::value(), VDMObjectDelegateDataType::value(), QQmlObjectModel::variantValue(), QV4::ModelObject::virtualPut(), and RCCFileInfo::writeDataBlob().

◆ toWCharArray()

QT_WARNING_PUSH qsizetype QString::toWCharArray ( wchar_t * array) const
inline
Since
4.2

Fills the array with the data contained in this QString object. The array is encoded in UTF-16 on platforms where wchar_t is 2 bytes wide (e.g. windows) and in UCS-4 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).

This function 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(), toLatin1(), toUtf8(), toLocal8Bit(), toStdWString(), QStringView::toWCharArray()

Definition at line 1291 of file qstring.h.

References qToStringViewIgnoringNull(), and QStringView::toWCharArray().

Referenced by QQnxInputContext::checkSpelling(), QWindowsFontDatabaseFT::populateFamily(), QWindowsFontDatabase::populateFamily(), qt_getEnglishName(), QWindowsNativeFileDialogBase::setNameFilters(), and toSpannableString().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ trimmed() [1/2]

QString QString::trimmed ( ) &&
inline

Definition at line 449 of file qstring.h.

◆ trimmed() [2/2]

QString QString::trimmed ( ) const &
inline

Definition at line 447 of file qstring.h.

Referenced by QQuickGridScaledImage::QQuickGridScaledImage(), Parser::addIncludesRecursive(), createImageNode(), QQmlJS::Dom::LineWriter::ensureNewline(), enumsToValues(), fileArchitecture(), filterSpecs(), Parser::findEnumValues(), QUrl::fromUserInput(), getQtLibsFromElf(), QQmlDebugTranslationServicePrivate::getStyleNameForFont(), gradleBuildFlags(), QGeoSatelliteInfoSourceGypsy::init(), QQuickStackElement::load(), loadTzTimeZones(), QHostInfo::localDomainName(), maybeEscapeFirstChar(), mergeGradleProperties(), QtAndroidFileDialogHelper::nameFilterExtensions(), nextField(), Parser::parse(), parseClockValue(), QTextHtmlParser::parseCloseTag(), parseCompOp(), parseExtendedAttributes(), parseFont(), QHttpHeaderParser::parseHeaders(), parseLength(), QT_BEGIN_NAMESPACE::parseLocation(), QGeoTiledMappingManagerEngineNokia::parseNewVersionInfo(), parseOthers(), parseOtoolLibraryLine(), parseProvider(), parseRenderingHints(), parseTestArgs(), queryQtPaths(), quick_test_main_with_setup(), readGradleProperties(), QConfFileSettingsPrivate::readIniFile(), QConfFileSettingsPrivate::readIniSection(), QQmlJS::Dom::IndentingLineWriter::reindentAndSplit(), QUrl::setUserInfo(), QAbstractSpinBoxPrivate::stripped(), Widget::trimmedFunction(), updateAndroidManifest(), updateLibsXml(), and QPdfPageSelectorSpinBox::valueFromText().

+ Here is the caller graph for this function:

◆ truncate()

void QString::truncate ( qsizetype 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 == "Vlad"

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

See also
chop(), resize(), first(), QStringView::truncate()

Definition at line 6319 of file qstring.cpp.

References pos, and resize().

Referenced by decode(), QQmlData::destroyed(), QLCDNumberPrivate::drawString(), QStandardPaths::findExecutable(), QmlTypesClassDescription::findType(), QAndroidInputContext::getCursorCapsMode(), QAndroidInputContext::getTextAfterCursor(), iniChopTrailingSpaces(), QSysInfo::machineHostName(), QAbstractSpinBox::minimumSizeHint(), QTestPrivate::parseBlackList(), qt_getEnglishName(), QPlatformTheme::removeMnemonics(), QSqlRelationalTableModel::selectStatement(), QWindowsNativeFileDialogBase::setNameFilters(), QAbstractSpinBox::sizeHint(), Widget::truncateFunction(), and uuidFromString().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unicode()

const QChar * QString::unicode ( ) const
inline

Returns a Unicode representation of the string.

The result remains valid until the string is modified.

Note
The returned string may not be '\0'-terminated. Use size() to determine the length of the array.
See also
utf16(), fromRawData()

Definition at line 1230 of file qstring.h.

Referenced by QLocalePrivate::codeToLanguage(), QLocalePrivate::codeToTerritory(), QWindowsMimeText::convertFromMime(), QBuiltInMimes::convertFromMime(), count(), QSQLiteResult::exec(), indexOf(), QTextEngine::itemize(), keysymToQtKey_internal(), QMimeGlobPattern::matchFileName(), parseNumbersArray(), parseNumbersArray(), parseNumbersList(), QTextDocumentPrivate::plainText(), sanitizeNameForDBus(), QQmlJS::Lexer::setCode(), toDouble(), toDouble(), toKeyOrUnicode(), and RCCFileInfo::writeDataName().

+ Here is the caller graph for this function:

◆ utf16()

◆ vasprintf()

QString QString::vasprintf ( const char * cformat,
va_list ap )
static
Since
5.5

Equivalent method to asprintf(), but takes a va_list ap instead a list of variable arguments. See the asprintf() 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
asprintf()

Definition at line 7357 of file qstring.cpp.

References append_utf8(), arg, base, QLocaleData::c(), QLocaleData::CapitalEorX, cb, ch, d, QLocaleData::DFDecimal, QLocaleData::DFExponent, QLocaleData::DFSignificantDigits, form, fromUtf8(), i, QtMiscUtils::isAsciiDigit(), QtMiscUtils::isAsciiUpper(), QLocaleData::LeftAdjusted, lm_h, lm_hh, lm_j, lm_L, lm_l, lm_ll, lm_none, lm_t, lm_z, parse_field_width(), parse_flag_characters(), parse_length_modifier(), qstrlen(), qstrnlen(), QLocaleData::ShowBase, and QtMiscUtils::toAsciiLower().

Referenced by qErrnoWarning(), qErrnoWarning(), qffmpegLogCallback(), qt_message(), and QByteArray::qvsnprintf().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Friends And Related Symbol Documentation

◆ ::tst_QString

friend class ::tst_QString
friend

Definition at line 132 of file qstring.h.

◆ comparesEqual [1/9]

bool comparesEqual ( const QString & lhs,
const char * rhs )
friend

Definition at line 916 of file qstring.h.

◆ comparesEqual [2/9]

bool comparesEqual ( const QString & lhs,
const QByteArray & rhs )
friend

Definition at line 907 of file qstring.h.

◆ comparesEqual [3/9]

bool comparesEqual ( const QString & lhs,
QByteArrayView rhs )
friend

Definition at line 893 of file qstring.h.

◆ comparesEqual [4/9]

bool comparesEqual ( const QString & lhs,
QChar rhs )
friend

Definition at line 814 of file qstring.h.

◆ comparesEqual [5/9]

bool comparesEqual ( const QString & s1,
const char16_t * s2 )
friend

Definition at line 807 of file qstring.h.

◆ comparesEqual [6/9]

bool comparesEqual ( const QString & s1,
const QString & s2 )
friend

Definition at line 765 of file qstring.h.

◆ comparesEqual [7/9]

bool comparesEqual ( const QString & s1,
QLatin1StringView s2 )
friend

Definition at line 790 of file qstring.h.

◆ comparesEqual [8/9]

Q_WEAK_OVERLOAD friend bool comparesEqual ( const QString & s1,
QUtf8StringView s2 )
friend

Definition at line 772 of file qstring.h.

◆ comparesEqual [9/9]

bool comparesEqual ( const QString & s1,
std::nullptr_t  )
friend

Definition at line 801 of file qstring.h.

◆ compareThreeWay [1/9]

Qt::strong_ordering compareThreeWay ( const QString & lhs,
const char * rhs )
friend

Definition at line 919 of file qstring.h.

◆ compareThreeWay [2/9]

Qt::strong_ordering compareThreeWay ( const QString & lhs,
const QByteArray & rhs )
friend

Definition at line 910 of file qstring.h.

◆ compareThreeWay [3/9]

Qt::strong_ordering compareThreeWay ( const QString & lhs,
QByteArrayView rhs )
friend

Definition at line 899 of file qstring.h.

◆ compareThreeWay [4/9]

Qt::strong_ordering compareThreeWay ( const QString & lhs,
QChar rhs )
friend

Definition at line 816 of file qstring.h.

◆ compareThreeWay [5/9]

Qt::strong_ordering compareThreeWay ( const QString & s1,
const char16_t * s2 )
friend

Definition at line 809 of file qstring.h.

◆ compareThreeWay [6/9]

Qt::strong_ordering compareThreeWay ( const QString & s1,
const QString & s2 )
friend

Definition at line 767 of file qstring.h.

◆ compareThreeWay [7/9]

Qt::strong_ordering compareThreeWay ( const QString & s1,
QLatin1StringView s2 )
friend

Definition at line 793 of file qstring.h.

◆ compareThreeWay [8/9]

Q_WEAK_OVERLOAD friend Qt::strong_ordering compareThreeWay ( const QString & s1,
QUtf8StringView s2 )
friend

Definition at line 775 of file qstring.h.

◆ compareThreeWay [9/9]

Qt::strong_ordering compareThreeWay ( const QString & s1,
std::nullptr_t  )
friend

Definition at line 803 of file qstring.h.

◆ erase() [1/2]

template< typename T > qsizetype erase ( QString & s,
const T & t )
related
Since
6.1

Removes all elements that compare equal to t from the string s. Returns the number of elements removed, if any.

See also
erase_if

Definition at line 1601 of file qstring.h.

◆ erase [2/2]

template<typename T >
template< typename T > qsizetype erase ( QString & s,
const T & t )
friend
Since
6.1

Removes all elements that compare equal to t from the string s. Returns the number of elements removed, if any.

See also
erase_if

Definition at line 1601 of file qstring.h.

◆ erase_if() [1/2]

template< typename Predicate > qsizetype erase_if ( QString & s,
Predicate pred )
related
Since
6.1

Removes all elements for which the predicate pred returns true from the string s. Returns the number of elements removed, if any.

See also
erase

Definition at line 1607 of file qstring.h.

◆ erase_if [2/2]

template<typename Predicate >
template< typename Predicate > qsizetype erase_if ( QString & s,
Predicate pred )
friend
Since
6.1

Removes all elements for which the predicate pred returns true from the string s. Returns the number of elements removed, if any.

See also
erase

Definition at line 1607 of file qstring.h.

◆ operator""_s()

operator""_s ( const char16_t * str,
size_t size )
related

\macro QStringLiteral(str)

The macro generates the data for a QString out of the string literal str at compile time. Creating a QString from it is free in this case, and the generated string data is stored in the read-only segment of the compiled object file.

If you have code that looks like this:

// hasAttribute takes a QString argument
if (node.hasAttribute("http-contents-length")) //...

then a temporary QString will be created to be passed as the {hasAttribute} function parameter. This can be quite expensive, as it involves a memory allocation and the copy/conversion of the data into QString's internal encoding.

This cost can be avoided by using QStringLiteral instead:

In this case, QString's internal data will be generated at compile time; no conversion or allocation will occur at runtime.

Using QStringLiteral instead of a double quoted plain C++ string literal can significantly speed up creation of QString instances from data known at compile time.

Note
QLatin1StringView can still be more efficient than QStringLiteral when the string is passed to a function that has an overload taking QLatin1StringView and this overload avoids conversion to QString. For instance, QString::operator==() can compare to a QLatin1StringView directly:
Note
Some compilers have bugs encoding strings containing characters outside the US-ASCII character set. Make sure you prefix your string with {u} in those cases. It is optional otherwise.
See also
QByteArrayLiteral
Since
6.4

Literal operator that creates a QString out of the first size characters in the char16_t string literal str.

The QString is created at compile time, and the generated string data is stored in the read-only segment of the compiled object file. Duplicate literals may share the same read-only memory. This functionality is interchangeable with QStringLiteral, but saves typing when many string literals are present in the code.

The following code creates a QString:

auto str = u"hello"_s;
QString str
[2]
See also
Qt::Literals::StringLiterals

Definition at line 1615 of file qstring.h.

References str.

◆ operator+() [1/3]

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::fromUtf8() function).

See also
QString::fromUtf8()

Definition at line 1433 of file qstring.h.

References fromUtf8(), and s2.

+ Here is the call graph for this function:

◆ operator+() [2/3]

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::fromUtf8() function).

See also
QString::fromUtf8()

Definition at line 1429 of file qstring.h.

References s2.

◆ operator+() [3/3]

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

Returns a string which is the result of concatenating s1 and s2.

Definition at line 1420 of file qstring.h.

◆ 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 9558 of file qstring.cpp.

◆ 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 9589 of file qstring.cpp.

◆ QAbstractConcatenable

friend struct QAbstractConcatenable
friend

Definition at line 1063 of file qstring.h.

◆ QByteArray

friend class QByteArray
friend

Definition at line 1062 of file qstring.h.

◆ QStringView

friend class QStringView
friend

Definition at line 1061 of file qstring.h.

Member Data Documentation

◆ cs [1/2]

◆ cs [2/2]

Definition at line 299 of file qstring.h.

◆ from [1/2]

◆ from [2/2]

qsizetype QString::from

Definition at line 299 of file qstring.h.


The documentation for this class was generated from the following files: