Logo Search packages:      
Sourcecode: qt4-x11 version File versions  Download package

Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | Friends | Related Functions

QString Class Reference

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

Inheritance diagram for QString:
Inheritance graph
[legend]
Collaboration diagram for QString:
Collaboration graph
[legend]

List of all members.

Classes

struct  Data
struct  Null

Public Types

typedef const QCharconst_iterator
typedef const_iterator ConstIterator
typedef DataDataPtr
typedef QChariterator
typedef iterator Iterator
enum  NormalizationForm { NormalizationForm_D, NormalizationForm_C, NormalizationForm_KD, NormalizationForm_KC }
enum  SectionFlag {
  SectionDefault = 0x00, SectionSkipEmpty = 0x01, SectionIncludeLeadingSep = 0x02, SectionIncludeTrailingSep = 0x04,
  SectionCaseInsensitiveSeps = 0x08
}
enum  SplitBehavior { KeepEmptyParts, SkipEmptyParts }

Public Member Functions

QStringappend (QChar c)
QT_ASCII_CAST_WARN QStringappend (const char *s)
QT_ASCII_CAST_WARN QStringappend (const QByteArray &s)
QStringappend (const QString &s)
QStringappend (const QStringRef &s)
QStringappend (const QLatin1String &s)
QString arg (long a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
QString arg (ulong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
QString arg (int a, int fieldWidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
QString arg (uint a, int fieldWidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
QString arg (ushort a, int fieldWidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
QString arg (double a, int fieldWidth=0, char fmt= 'g', int prec=-1, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
QString arg (char a, int fieldWidth=0, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
QString arg (qulonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
QString arg (const QString &a, int fieldWidth=0, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
QString arg (short a, int fieldWidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
QString arg (const QString &a1, const QString &a2) const Q_REQUIRED_RESULT
QString arg (QChar a, int fieldWidth=0, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
QString arg (const QString &a1, const QString &a2, const QString &a3) const Q_REQUIRED_RESULT
QString arg (const QString &a1, const QString &a2, const QString &a3, const QString &a4, const QString &a5, const QString &a6) const Q_REQUIRED_RESULT
QString arg (qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
QString arg (const QString &a1, const QString &a2, const QString &a3, const QString &a4, const QString &a5) const Q_REQUIRED_RESULT
QString arg (const QString &a1, const QString &a2, const QString &a3, const QString &a4, const QString &a5, const QString &a6, const QString &a7) const Q_REQUIRED_RESULT
QString arg (const QString &a1, const QString &a2, const QString &a3, const QString &a4) const Q_REQUIRED_RESULT
QString arg (const QString &a1, const QString &a2, const QString &a3, const QString &a4, const QString &a5, const QString &a6, const QString &a7, const QString &a8) const Q_REQUIRED_RESULT
QString arg (const QString &a1, const QString &a2, const QString &a3, const QString &a4, const QString &a5, const QString &a6, const QString &a7, const QString &a8, const QString &a9) const Q_REQUIRED_RESULT
const QChar at (int i) const
const_iterator begin () const
iterator begin ()
int capacity () const
void chop (int n)
void clear ()
int compare (const QString &s) const
int compare (const QString &s, Qt::CaseSensitivity cs) const
int compare (const QLatin1String &other, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
int compare (const QStringRef &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
const_iterator constBegin () const
const QCharconstData () const
const_iterator constEnd () const
QBool contains (const QRegExp &rx) const
 [8]
QBool contains (QRegExp &rx) const
QBool contains (QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
QBool contains (const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
int count (QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
int count (const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
int count () const
int count (const QRegExp &) const
QChardata ()
const QChardata () const
DataPtrdata_ptr ()
void detach ()
iterator end ()
const_iterator end () const
bool endsWith (const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
bool endsWith (const QLatin1String &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
bool endsWith (const QChar &c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
QStringfill (QChar c, int size=-1)
int indexOf (const QRegExp &, int from=0) const
int indexOf (QRegExp &, int from=0) const
int indexOf (QChar c, int from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
int indexOf (const QString &s, int from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
int indexOf (const QLatin1String &s, int from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
QStringinsert (int i, QChar c)
QStringinsert (int i, const QChar *uc, int len)
QStringinsert (int i, const QString &s)
QStringinsert (int i, const QLatin1String &s)
bool isDetached () const
bool isEmpty () const
bool isNull () const
bool isRightToLeft () const
bool isSimpleText () const
int lastIndexOf (const QRegExp &, int from=-1) const
int lastIndexOf (QRegExp &, int from=-1) const
int lastIndexOf (QChar c, int from=-1, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
int lastIndexOf (const QLatin1String &s, int from=-1, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
int lastIndexOf (const QString &s, int from=-1, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
QString left (int n) const Q_REQUIRED_RESULT
QString leftJustified (int width, QChar fill=QLatin1Char(' '), bool trunc=false) const Q_REQUIRED_RESULT
QStringRef leftRef (int n) const Q_REQUIRED_RESULT
int length () const
int localeAwareCompare (const QString &s) const
int localeAwareCompare (const QStringRef &s) const
QString mid (int position, int n=-1) const Q_REQUIRED_RESULT
QStringRef midRef (int position, int n=-1) const Q_REQUIRED_RESULT
QString normalized (NormalizationForm mode) const Q_REQUIRED_RESULT
QString normalized (NormalizationForm mode, QChar::UnicodeVersion version) const Q_REQUIRED_RESULT
bool operator!= (const QString &s) const
bool operator!= (const QLatin1String &s) const
QT_ASCII_CAST_WARN bool operator!= (const char *s) const
QT_ASCII_CAST_WARN bool operator!= (const QByteArray &s) const
QStringoperator+= (const QLatin1String &s)
QT_ASCII_CAST_WARN QStringoperator+= (const char *s)
QT_ASCII_CAST_WARN QStringoperator+= (const QByteArray &s)
QStringoperator+= (const QStringRef &s)
QStringoperator+= (const QString &s)
QStringoperator+= (QChar c)
QStringoperator+= (QChar::SpecialCharacter c)
QT_ASCII_CAST_WARN QStringoperator+= (char c)
bool operator< (const QString &s) const
bool operator< (const QLatin1String &s) const
QT_ASCII_CAST_WARN bool operator< (const char *s) const
QT_ASCII_CAST_WARN bool operator< (const QByteArray &s) const
QT_ASCII_CAST_WARN bool operator<= (const char *s2) const
bool operator<= (const QString &s) const
bool operator<= (const QLatin1String &s) const
QT_ASCII_CAST_WARN bool operator<= (const QByteArray &s) const
QT_ASCII_CAST_WARN QStringoperator= (const QByteArray &a)
QStringoperator= (const QString &)
QStringoperator= (const QLatin1String &)
QT_ASCII_CAST_WARN QStringoperator= (const char *ch)
QT_ASCII_CAST_WARN QStringoperator= (char c)
QStringoperator= (QChar c)
QStringoperator= (const Null &)
QT_ASCII_CAST_WARN bool operator== (const char *s) const
bool operator== (const QString &s) const
QT_ASCII_CAST_WARN bool operator== (const QByteArray &s) const
bool operator== (const QLatin1String &s) const
bool operator> (const QString &s) const
bool operator> (const QLatin1String &s) const
QT_ASCII_CAST_WARN bool operator> (const char *s2) const
QT_ASCII_CAST_WARN bool operator> (const QByteArray &s) const
bool operator>= (const QLatin1String &s) const
QT_ASCII_CAST_WARN bool operator>= (const QByteArray &s) const
bool operator>= (const QString &s) const
QT_ASCII_CAST_WARN bool operator>= (const char *s2) const
QCharRef operator[] (uint i)
const QChar operator[] (uint i) const
const QChar operator[] (int i) const
QCharRef operator[] (int i)
QStringprepend (const QString &s)
QT_ASCII_CAST_WARN QStringprepend (const char *s)
QT_ASCII_CAST_WARN QStringprepend (const QByteArray &s)
QStringprepend (QChar c)
QStringprepend (const QLatin1String &s)
void push_back (QChar c)
void push_back (const QString &s)
void push_front (const QString &s)
void push_front (QChar c)
 QString (int size, QChar c)
 QString ()
 QString (const QString &)
 QString (const QChar *unicode, int size)
 QString (QChar c)
 QString (const QLatin1String &latin1)
QT_ASCII_CAST_WARN_CONSTRUCTOR QString (const char *ch)
 QString (const Null &)
QT_ASCII_CAST_WARN_CONSTRUCTOR QString (const QByteArray &a)
QStringremove (int i, int len)
QStringremove (QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive)
QStringremove (const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive)
QStringremove (const QRegExp &rx)
QString repeated (int times) const
QStringreplace (QChar c, const QString &after, Qt::CaseSensitivity cs=Qt::CaseSensitive)
QStringreplace (const QLatin1String &before, const QLatin1String &after, Qt::CaseSensitivity cs=Qt::CaseSensitive)
QStringreplace (int i, int len, const QChar *s, int slen)
QStringreplace (const QRegExp &rx, const QString &after)
QStringreplace (int i, int len, QChar after)
QStringreplace (int i, int len, const QString &after)
QStringreplace (QChar before, QChar after, Qt::CaseSensitivity cs=Qt::CaseSensitive)
QStringreplace (const QChar *before, int blen, const QChar *after, int alen, Qt::CaseSensitivity cs=Qt::CaseSensitive)
QStringreplace (const QLatin1String &before, const QString &after, Qt::CaseSensitivity cs=Qt::CaseSensitive)
QStringreplace (const QString &before, const QLatin1String &after, Qt::CaseSensitivity cs=Qt::CaseSensitive)
QStringreplace (const QString &before, const QString &after, Qt::CaseSensitivity cs=Qt::CaseSensitive)
QStringreplace (QChar c, const QLatin1String &after, Qt::CaseSensitivity cs=Qt::CaseSensitive)
void reserve (int size)
void resize (int size)
QString right (int n) const Q_REQUIRED_RESULT
QString rightJustified (int width, QChar fill=QLatin1Char(' '), bool trunc=false) const Q_REQUIRED_RESULT
QStringRef rightRef (int n) const Q_REQUIRED_RESULT
QString section (const QString &in_sep, int start, int end=-1, SectionFlags flags=SectionDefault) const
QString section (const QRegExp &reg, int start, int end=-1, SectionFlags flags=SectionDefault) const
QString section (QChar sep, int start, int end=-1, SectionFlags flags=SectionDefault) const
QStringsetNum (int, int base=10)
QStringsetNum (ulong, int base=10)
QStringsetNum (double, char f='g', int prec=6)
QStringsetNum (short, int base=10)
QStringsetNum (qlonglong, int base=10)
QStringsetNum (ushort, int base=10)
QStringsetNum (uint, int base=10)
QStringsetNum (qulonglong, int base=10)
QStringsetNum (long, int base=10)
QStringsetNum (float, char f='g', int prec=6)
QStringsetUnicode (const QChar *unicode, int size)
QStringsetUtf16 (const ushort *utf16, int size)
QString simplified () const Q_REQUIRED_RESULT
int size () const
QStringList split (const QChar &sep, SplitBehavior behavior=KeepEmptyParts, Qt::CaseSensitivity cs=Qt::CaseSensitive) const Q_REQUIRED_RESULT
QStringList split (const QRegExp &sep, SplitBehavior behavior=KeepEmptyParts) const Q_REQUIRED_RESULT
QStringList split (const QString &sep, SplitBehavior behavior=KeepEmptyParts, Qt::CaseSensitivity cs=Qt::CaseSensitive) const Q_REQUIRED_RESULT
QStringsprintf (const char *format,...)
void squeeze ()
bool startsWith (const QChar &c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
bool startsWith (const QLatin1String &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
bool startsWith (const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
QByteArray toAscii () const Q_REQUIRED_RESULT
QString toCaseFolded () const Q_REQUIRED_RESULT
double toDouble (bool *ok=0) const
float toFloat (bool *ok=0) const
int toInt (bool *ok=0, int base=10) const
QByteArray toLatin1 () const Q_REQUIRED_RESULT
QByteArray toLocal8Bit () const Q_REQUIRED_RESULT
long toLong (bool *ok=0, int base=10) const
qlonglong toLongLong (bool *ok=0, int base=10) const
QString toLower () const Q_REQUIRED_RESULT
short toShort (bool *ok=0, int base=10) const
std::string toStdString () const
QStdWString toStdWString () const
QVector< uint > toUcs4 () const Q_REQUIRED_RESULT
uint toUInt (bool *ok=0, int base=10) const
ulong toULong (bool *ok=0, int base=10) const
qulonglong toULongLong (bool *ok=0, int base=10) const
QString toUpper () const Q_REQUIRED_RESULT
ushort toUShort (bool *ok=0, int base=10) const
QByteArray toUtf8 () const Q_REQUIRED_RESULT
int toWCharArray (wchar_t *array) const
QString trimmed () const Q_REQUIRED_RESULT
void truncate (int pos)
const QCharunicode () const
const ushort * utf16 () const
QStringvsprintf (const char *format, va_list ap)
 ~QString ()

Static Public Member Functions

static int compare (const QString &s1, const QString &s2)
static int compare (const QString &s1, const QString &s2, Qt::CaseSensitivity cs)
static int compare (const QString &s1, const QLatin1String &s2, Qt::CaseSensitivity cs=Qt::CaseSensitive)
static int compare (const QLatin1String &s1, const QString &s2, Qt::CaseSensitivity cs=Qt::CaseSensitive)
static int compare (const QString &s1, const QStringRef &s2, Qt::CaseSensitivity=Qt::CaseSensitive)
static QString fromAscii (const char *, int size=-1)
static QString fromLatin1 (const char *, int size=-1)
static QString fromLocal8Bit (const char *, int size=-1)
static QString fromRawData (const QChar *, int size)
static QString fromStdString (const std::string &s)
static QString fromStdWString (const QStdWString &s)
static QString fromUcs4 (const uint *, int size=-1)
static QString fromUtf16 (const ushort *, int size=-1)
static QString fromUtf8 (const char *, int size=-1)
static QString fromWCharArray (const wchar_t *, int size=-1)
static int localeAwareCompare (const QString &s1, const QString &s2)
static int localeAwareCompare (const QString &s1, const QStringRef &s2)
static QString number (ulong, int base=10)
static QString number (long, int base=10)
static QString number (uint, int base=10)
static QString number (double, char f='g', int prec=6)
static QString number (qulonglong, int base=10)
static QString number (qlonglong, int base=10)
static QString number (int, int base=10)

Static Public Attributes

static const Null null = { }

Private Member Functions

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

Static Private Member Functions

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

Private Attributes

Datad

Static Private Attributes

static QTextCodeccodecForCStrings
static Data shared_empty
static Data shared_null

Friends

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

Related Functions

(Note that these are not member functions.)


bool operator!= (const char *s1, const QString &s2)
const QString operator+ (const QString &s1, const char *s2)
const QString operator+ (const char *s1, const QString &s2)
const QString operator+ (const QString &s, char ch)
const QString operator+ (char ch, const QString &s)
const QString operator+ (const QString &s1, const QString &s2)
bool operator< (const char *s1, const QString &s2)
QDataStreamoperator<< (QDataStream &stream, const QString &string)
bool operator<= (const char *s1, const QString &s2)
bool operator==operator== (const char *s1, const QString &s2)()
bool operator> (const char *s1, const QString &s2)
bool operator>= (const char *s1, const QString &s2)
QDataStreamoperator>> (QDataStream &stream, QString &string)

Detailed Description

The QString class provides a Unicode character string.

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

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

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

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

Definition at line 90 of file qstring.h.


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

Generated by  Doxygen 1.6.0   Back to index