📄 qstring.3qt
字号:
.BI "Q_ULLONG \fBtoULongLong\fR ( bool * ok = 0, int base = 10 ) const".br.ti -1c.BI "float \fBtoFloat\fR ( bool * ok = 0 ) const".br.ti -1c.BI "double \fBtoDouble\fR ( bool * ok = 0 ) const".br.ti -1c.BI "QString & \fBsetNum\fR ( short n, int base = 10 )".br.ti -1c.BI "QString & \fBsetNum\fR ( ushort n, int base = 10 )".br.ti -1c.BI "QString & \fBsetNum\fR ( int n, int base = 10 )".br.ti -1c.BI "QString & \fBsetNum\fR ( uint n, int base = 10 )".br.ti -1c.BI "QString & \fBsetNum\fR ( long n, int base = 10 )".br.ti -1c.BI "QString & \fBsetNum\fR ( ulong n, int base = 10 )".br.ti -1c.BI "QString & \fBsetNum\fR ( Q_LLONG n, int base = 10 )".br.ti -1c.BI "QString & \fBsetNum\fR ( Q_ULLONG n, int base = 10 )".br.ti -1c.BI "QString & \fBsetNum\fR ( float n, char f = 'g', int prec = 6 )".br.ti -1c.BI "QString & \fBsetNum\fR ( double n, char f = 'g', int prec = 6 )".br.ti -1c.BI "void setExpand ( uint index, QChar c ) \fI(obsolete)\fR".br.ti -1c.BI "QString & \fBoperator+=\fR ( const QString & str )".br.ti -1c.BI "QString & \fBoperator+=\fR ( const QByteArray & str )".br.ti -1c.BI "QString & \fBoperator+=\fR ( const char * str )".br.ti -1c.BI "QString & \fBoperator+=\fR ( const std::string & str )".br.ti -1c.BI "QString & \fBoperator+=\fR ( QChar c )".br.ti -1c.BI "QString & \fBoperator+=\fR ( char c )".br.ti -1c.BI "QChar \fBat\fR ( uint i ) const".br.ti -1c.BI "QChar \fBoperator[]\fR ( int i ) const".br.ti -1c.BI "QCharRef \fBat\fR ( uint i )".br.ti -1c.BI "QCharRef \fBoperator[]\fR ( int i )".br.ti -1c.BI "QChar \fBconstref\fR ( uint i ) const".br.ti -1c.BI "QChar & \fBref\fR ( uint i )".br.ti -1c.BI "const QChar * \fBunicode\fR () const".br.ti -1c.BI "const char * \fBascii\fR () const".br.ti -1c.BI "const char * \fBlatin1\fR () const".br.ti -1c.BI "QCString \fButf8\fR () const".br.ti -1c.BI "QCString \fBlocal8Bit\fR () const".br.ti -1c.BI "bool \fBoperator!\fR () const".br.ti -1c.BI "\fBoperator const char *\fR () const".br.ti -1c.BI "\fBoperator std::string\fR () const".br.ti -1c.BI "const unsigned short * \fBucs2\fR () const".br.ti -1c.BI "QString & \fBsetUnicode\fR ( const QChar * unicode, uint len )".br.ti -1c.BI "QString & \fBsetUnicodeCodes\fR ( const ushort * unicode_as_ushorts, uint len )".br.ti -1c.BI "QString & \fBsetAscii\fR ( const char * str, int len = -1 )".br.ti -1c.BI "QString & \fBsetLatin1\fR ( const char * str, int len = -1 )".br.ti -1c.BI "int \fBcompare\fR ( const QString & s ) const".br.ti -1c.BI "int \fBlocaleAwareCompare\fR ( const QString & s ) const".br.ti -1c.BI "void \fBcompose\fR ()".br.ti -1c.BI "const char * data () const \fI(obsolete)\fR".br.ti -1c.BI "bool \fBstartsWith\fR ( const QString & s, bool cs = TRUE ) const".br.ti -1c.BI "bool \fBendsWith\fR ( const QString & s, bool cs = TRUE ) const".br.ti -1c.BI "void \fBsetLength\fR ( uint newLen )".br.ti -1c.BI "uint \fBcapacity\fR () const".br.ti -1c.BI "void \fBreserve\fR ( uint minCapacity )".br.ti -1c.BI "void \fBsqueeze\fR ()".br.in -1c.SS "Static Public Members".in +1c.ti -1c.BI "QString \fBnumber\fR ( long n, int base = 10 )".br.ti -1c.BI "QString \fBnumber\fR ( ulong n, int base = 10 )".br.ti -1c.BI "QString \fBnumber\fR ( Q_LLONG n, int base = 10 )".br.ti -1c.BI "QString \fBnumber\fR ( Q_ULLONG n, int base = 10 )".br.ti -1c.BI "QString \fBnumber\fR ( int n, int base = 10 )".br.ti -1c.BI "QString \fBnumber\fR ( uint n, int base = 10 )".br.ti -1c.BI "QString \fBnumber\fR ( double n, char f = 'g', int prec = 6 )".br.ti -1c.BI "QString \fBfromAscii\fR ( const char * ascii, int len = -1 )".br.ti -1c.BI "QString \fBfromLatin1\fR ( const char * chars, int len = -1 )".br.ti -1c.BI "QString \fBfromUtf8\fR ( const char * utf8, int len = -1 )".br.ti -1c.BI "QString \fBfromLocal8Bit\fR ( const char * local8Bit, int len = -1 )".br.ti -1c.BI "QString \fBfromUcs2\fR ( const unsigned short * str )".br.ti -1c.BI "int \fBcompare\fR ( const QString & s1, const QString & s2 )".br.ti -1c.BI "int \fBlocaleAwareCompare\fR ( const QString & s1, const QString & s2 )".br.in -1c.SH RELATED FUNCTION DOCUMENTATION.in +1c.ti -1c.BI "bool \fBoperator==\fR ( const QString & s1, const QString & s2 )".br.ti -1c.BI "bool \fBoperator==\fR ( const QString & s1, const char * s2 )".br.ti -1c.BI "bool \fBoperator==\fR ( const char * s1, const QString & s2 )".br.ti -1c.BI "bool \fBoperator!=\fR ( const QString & s1, const QString & s2 )".br.ti -1c.BI "bool \fBoperator!=\fR ( const QString & s1, const char * s2 )".br.ti -1c.BI "bool \fBoperator!=\fR ( const char * s1, const QString & s2 )".br.ti -1c.BI "bool \fBoperator<\fR ( const QString & s1, const char * s2 )".br.ti -1c.BI "bool \fBoperator<\fR ( const char * s1, const QString & s2 )".br.ti -1c.BI "bool \fBoperator<=\fR ( const QString & s1, const char * s2 )".br.ti -1c.BI "bool \fBoperator<=\fR ( const char * s1, const QString & s2 )".br.ti -1c.BI "bool \fBoperator>\fR ( const QString & s1, const char * s2 )".br.ti -1c.BI "bool \fBoperator>\fR ( const char * s1, const QString & s2 )".br.ti -1c.BI "bool \fBoperator>=\fR ( const QString & s1, const char * s2 )".br.ti -1c.BI "bool \fBoperator>=\fR ( const char * s1, const QString & s2 )".br.ti -1c.BI "const QString \fBoperator+\fR ( const QString & s1, const QString & s2 )".br.ti -1c.BI "const QString \fBoperator+\fR ( const QString & s1, const char * s2 )".br.ti -1c.BI "const QString \fBoperator+\fR ( const char * s1, const QString & s2 )".br.ti -1c.BI "const QString \fBoperator+\fR ( const QString & s, char c )".br.ti -1c.BI "const QString \fBoperator+\fR ( char c, const QString & s )".br.ti -1c.BI "QDataStream & \fBoperator<<\fR ( QDataStream & s, const QString & str )".br.ti -1c.BI "QDataStream & \fBoperator>>\fR ( QDataStream & s, QString & str )".br.in -1c.SH DESCRIPTIONThe QString class provides an abstraction of Unicode text and the classic C '\0'-terminated char array..PPQString uses implicit sharing, which makes it very efficient and easy to use..PPIn all of the QString methods that take \fCconst char *\fR parameters, the \fCconst char *\fR is interpreted as a classic C-style '\0'-terminated ASCII string. It is legal for the \fCconst char *\fR parameter to be 0. If the \fCconst char *\fR is not '\0'-terminated, the results are undefined. Functions that copy classic C strings into a QString will not copy the terminating '\0' character. The QChar array of the QString (as returned by unicode()) is generally not terminated by a '\0'. If you need to pass a QString to a function that requires a C '\0'-terminated string use latin1()..PPA QString that has not been assigned to anything is \fInull\fR, i.e. both the length and data pointer is 0. A QString that references the empty string ("", a single '\0' char) is \fIempty\fR. Both null and empty QStrings are legal parameters to the methods. Assigning \fC(const char *) 0\fR to QString gives a null QString. For convenience, QString::null is a null QString. When sorting, empty strings come first, followed by non-empty strings, followed by null strings. We recommend using \fCif ( !str.isNull() )\fR to check for a non-null string rather than \fCif ( !str )\fR; see operator!() for an explanation..PPNote that if you find that you are mixing usage of QCString, QString, and QByteArray, this causes lots of unnecessary copying and might indicate that the true nature of the data you are dealing with is uncertain. If the data is '\0'-terminated 8-bit data, use QCString; if it is unterminated (i.e. contains '\0's) 8-bit data, use QByteArray; if it is text, use QString..PPLists of strings are handled by the QStringList class. You can split a string into a list of strings using QStringList::split(), and join a list of strings into a single string with an optional separator using QStringList::join(). You can obtain a list of strings from a string list that contain a particular substring or that match a particular regex using QStringList::grep()..PP\fBNote for C programmers\fR.PPDue to C++'s type system and the fact that QString is implicitly shared, QStrings can be treated like ints or other simple base types. For example:.PP.nf.br QString boolToString( bool b ).br {.br QString result;.br if ( b ).br result = "True";.br else.br result = "False";.br return result;.br }.br.fi.PPThe variable, result, is an auto variable allocated on the stack. When return is called, 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, see below.).PPThroughout Qt's source code you will encounter QString usages like this:.PP.nf.br QString func( const QString& input ).br {.br QString output = input;.br // process output.br return output;.br }.br.fi.PPThe 'copying' of input to output is almost as fast as copying a pointer because behind the scenes copying is achieved by incrementing a reference count. QString (like all Qt's implicitly shared classes) operates on a copy-on-write basis, only copying if an instance is actually changed..PPIf you wish to create a deep copy of a QString without losing any Unicode information then you should use QDeepCopy..PPSee also QChar, QCString, QByteArray, QConstString, Implicitly and Explicitly Shared Classes, Text Related Classes, and Non-GUI Classes..SS "Member Type Documentation".SH "QString::SectionFlags".TP\fCQString::SectionDefault\fR - Empty fields are counted, leading and trailing separators are not included, and the separator is compared case sensitively..TP\fCQString::SectionSkipEmpty\fR - Treat empty fields as if they don't exist, i.e. they are not considered as far as \fIstart\fR and \fIend\fR are concerned..TP\fCQString::SectionIncludeLeadingSep\fR - Include the leading separator (if any) in the result string..TP\fCQString::SectionIncludeTrailingSep\fR - Include the trailing separator (if any) in the result string..TP\fCQString::SectionCaseInsensitiveSeps\fR - Compare the separator case-insensitively..PPAny of the last four values can be OR-ed together to form a flag.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -