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

QString Class Reference

Inheritance diagram for QString:

QDBusObjectPath QDBusSignature

List of all members.


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 { Qtopia Core}).

Definition at line 69 of file qstring.h.


Public Types

typedef const QCharconst_iterator
typedef const_iterator ConstIterator
typedef iterator Iterator
typedef QChariterator
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

QT_ASCII_CAST_WARN QStringappend (const QByteArray &s)
QT_ASCII_CAST_WARN QStringappend (const char *s)
QStringappend (const QLatin1String &s)
QStringappend (const QString &s)
QStringappend (QChar c)
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 Q_REQUIRED_RESULT
QString arg (const QString &a1, const QString &a2) const Q_REQUIRED_RESULT
QString arg (const QString &a, int fieldWidth=0, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
QString arg (QChar a, int fieldWidth=0, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
QString arg (char a, int fieldWidth=0, 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 (ushort a, int fieldWidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
QString arg (short a, int fieldWidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
QString arg (uint 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 (ulong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
QString arg (long a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
QString arg (qulonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
QString arg (qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) 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 QLatin1String &other, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
int compare (const QString &s, Qt::CaseSensitivity cs) const
int compare (const QString &s) const
const_iterator constBegin () const
const QCharconstData () const
const_iterator constEnd () const
QBool contains (const QRegExp &rx) const
QBool contains (const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
QBool contains (QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
int count (const QRegExp &) const
int count (const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
int count (QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
int count () const
const QChardata () const
QChardata ()
void detach ()
const_iterator end () const
iterator end ()
bool endsWith (const QChar &c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
bool endsWith (const QLatin1String &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
bool endsWith (const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
QStringfill (QChar c, int size=-1)
int indexOf (const QRegExp &, int from=0) const
int indexOf (const QString &s, int from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
int indexOf (QChar c, int from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
QStringinsert (int i, const QLatin1String &s)
QStringinsert (int i, const QString &s)
QStringinsert (int i, const QChar *uc, int len)
QStringinsert (int i, QChar c)
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 (const QString &s, int from=-1, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
int lastIndexOf (QChar c, int from=-1, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
QString left (int len) const Q_REQUIRED_RESULT
QString leftJustified (int width, QChar fill=QLatin1Char(' '), bool trunc=false) const Q_REQUIRED_RESULT
int length () const
int localeAwareCompare (const QString &s) const
QString mid (int i, int len=-1) const Q_REQUIRED_RESULT
QString normalized (NormalizationForm mode, QChar::UnicodeVersion version) const Q_REQUIRED_RESULT
QString normalized (NormalizationForm mode) const Q_REQUIRED_RESULT
QT_ASCII_CAST_WARN bool operator!= (const QByteArray &s) const
QT_ASCII_CAST_WARN bool operator!= (const char *s) const
bool operator!= (const QLatin1String &s) const
bool operator!= (const QString &s) const
QT_ASCII_CAST_WARN QStringoperator+= (char c)
QT_ASCII_CAST_WARN QStringoperator+= (const QByteArray &s)
QT_ASCII_CAST_WARN QStringoperator+= (const char *s)
QStringoperator+= (const QLatin1String &s)
QStringoperator+= (const QString &s)
QStringoperator+= (QChar::SpecialCharacter c)
QStringoperator+= (QChar c)
QT_ASCII_CAST_WARN bool operator< (const QByteArray &s) const
QT_ASCII_CAST_WARN bool operator< (const char *s) const
bool operator< (const QLatin1String &s) const
bool operator< (const QString &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 QLatin1String &s) const
bool operator<= (const QString &s) const
QStringoperator= (const Null &)
QT_ASCII_CAST_WARN QStringoperator= (char c)
QT_ASCII_CAST_WARN QStringoperator= (const QByteArray &a)
QT_ASCII_CAST_WARN QStringoperator= (const char *ch)
QStringoperator= (const QLatin1String &)
QStringoperator= (const QString &)
QStringoperator= (QChar c)
QT_ASCII_CAST_WARN bool operator== (const QByteArray &s) const
QT_ASCII_CAST_WARN bool operator== (const char *s) const
bool operator== (const QLatin1String &s) const
bool operator== (const QString &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 QLatin1String &s) const
bool operator> (const QString &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 QLatin1String &s) const
bool operator>= (const QString &s) const
QCharRef operator[] (uint i)
const QChar operator[] (uint i) const
QCharRef operator[] (int i)
const QChar operator[] (int i) const
QT_ASCII_CAST_WARN QStringprepend (const QByteArray &s)
QT_ASCII_CAST_WARN QStringprepend (const char *s)
QStringprepend (const QLatin1String &s)
QStringprepend (const QString &s)
QStringprepend (QChar c)
void push_back (const QString &s)
void push_back (QChar c)
void push_front (const QString &s)
void push_front (QChar c)
 QString (const Null &)
QT_ASCII_CAST_WARN_CONSTRUCTOR QString (const QByteArray &a)
QT_ASCII_CAST_WARN_CONSTRUCTOR QString (const char *ch)
 QString (const QString &)
 QString (const QLatin1String &latin1)
 QString (int size, QChar c)
 QString (QChar c)
 QString (const QChar *unicode, int size)
 QString ()
QStringremove (const QRegExp &rx)
QStringremove (const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive)
QStringremove (QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive)
QStringremove (int i, int len)
QStringreplace (const QRegExp &rx, const QString &after)
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 before, QChar after, Qt::CaseSensitivity cs=Qt::CaseSensitive)
QStringreplace (int i, int len, const QString &after)
QStringreplace (int i, int len, const QChar *s, int slen)
QStringreplace (int i, int len, QChar after)
void reserve (int size)
void resize (int size)
QString right (int len) const Q_REQUIRED_RESULT
QString rightJustified (int width, QChar fill=QLatin1Char(' '), bool trunc=false) const Q_REQUIRED_RESULT
QString section (const QRegExp &reg, int start, int end=-1, SectionFlags flags=SectionDefault) const
QString section (const QString &in_sep, int start, int end=-1, SectionFlags flags=SectionDefault) const
QString section (QChar sep, int start, int end=-1, SectionFlags flags=SectionDefault) const
QStringsetNum (double, char f='g', int prec=6)
QStringsetNum (float, char f='g', int prec=6)
QStringsetNum (qulonglong, int base=10)
QStringsetNum (qlonglong, int base=10)
QStringsetNum (ulong, int base=10)
QStringsetNum (long, int base=10)
QStringsetNum (uint, int base=10)
QStringsetNum (int, int base=10)
QStringsetNum (ushort, int base=10)
QStringsetNum (short, int base=10)
QStringsetUnicode (const QChar *unicode, int size)
QStringsetUtf16 (const ushort *utf16, int size)
QString simplified () const Q_REQUIRED_RESULT
int size () const
QStringList split (const QRegExp &sep, SplitBehavior behavior=KeepEmptyParts) const Q_REQUIRED_RESULT
QStringList split (const QChar &sep, SplitBehavior behavior=KeepEmptyParts, Qt::CaseSensitivity cs=Qt::CaseSensitive) 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
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 QLatin1String &s1, const QString &s2, Qt::CaseSensitivity cs=Qt::CaseSensitive)
static int compare (const QString &s1, const QLatin1String &s2, Qt::CaseSensitivity cs=Qt::CaseSensitive)
static int compare (const QString &s1, const QString &s2, Qt::CaseSensitivity cs)
static int compare (const QString &s1, const QString &s2)
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 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 (ulong, int base=10)
static QString number (long, int base=10)
static QString number (uint, int base=10)
static QString number (int, int base=10)

Static Public Attributes

static const Null null = QString::Null()

Private Member Functions

void expand (int i)
QString multiArg (int numArgs, const QString **args) const
 QString (Data *dd, int)
void realloc (int alloc)
void realloc ()
void updateProperties () const

Static Private Member Functions

static void free (Data *)
static Data * fromAscii_helper (const char *str, int size=-1)
static Data * fromLatin1_helper (const char *str, int size=-1)
static int grow (int)

Private Attributes

Data * d

Static Private Attributes

static QTextCodeccodecForCStrings
static Data shared_empty = { Q_ATOMIC_INIT(1), 0, 0, shared_empty.array, 0, 0, 0, 0, 0, {0} }
static Data shared_null = { Q_ATOMIC_INIT(1), 0, 0, shared_null.array, 0, 0, 0, 0, 0, {0} }

Friends

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

Related Functions

(Note that these are not member functions.)

bool operator!= (const char *s1, const QString &s2)
const QString operator+ (char ch, const QString &s)
const QString operator+ (const QString &s, char ch)
const QString operator+ (const char *s1, const QString &s2)
const QString operator+ (const QString &s1, const char *s2)
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== (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)

Classes

struct  Data
struct  Null

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

Generated by  Doxygen 1.6.0   Back to index