⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qstring.3qt

📁 Linux下的基于X11的图形开发环境。
💻 3QT
📖 第 1 页 / 共 5 页
字号:
.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 ) const".br.ti -1c.BI "bool \fBendsWith\fR ( const QString & s ) const".br.ti -1c.BI "void \fBsetLength\fR ( uint newLen )".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 ( 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 '&#92;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 '&#92;0'-terminated ASCII string. It is legal for the \fCconst char *\fR parameter to be 0. If the \fCconst char *\fR is not '&#92;0'-terminated, the results are undefined. Functions that copy classic C strings into a QString will not copy the terminating '&#92;0' character. The QChar array of the QString (as returned by unicode()) is generally not terminated by a '&#92;0'. If you need to pass a QString to a function that requires a C '&#92;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 '&#92;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 '&#92;0'-terminated 8-bit data, use QCString; if it is unterminated (i.e. contains '&#92;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 may 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..PPSee also section()..SH MEMBER FUNCTION DOCUMENTATION.SH "QString::QString ()"Constructs a null string, i.e. both the length and data pointer are 0..PPSee also isNull()..SH "QString::QString ( QChar ch )"Constructs a string of length one, containing the character \fIch\fR..SH "QString::QString ( const QString & s )"Constructs an implicitly shared copy of \fIs\fR. This is very fast since it only involves incrementing a reference count..SH "QString::QString ( const QByteArray & ba )"Constructs a string that is a deep copy of \fIba\fR interpreted as a classic C string..SH "QString::QString ( const QChar * unicode, uint length )"Constructs a string that is a deep copy of the first \fIlength\fR characters in the QChar array..PPIf \fIunicode\fR and \fIlength\fR are 0, then a null string is created..PPIf only \fIunicode\fR is 0, the string is empty but has \fIlength\fR characters of space preallocated: QString expands automatically anyway, but this may speed up some cases a little. We recommend using the plain constructor and setLength() for this purpose since it will result in more readable code..PPSee also isNull() and setLength()..SH "QString::QString ( const char * str )"Constructs a string that is a deep copy of \fIstr\fR, interpreted as a classic C string..PPIf \fIstr\fR is 0, then a null string is created..PPThis is a cast constructor, but it is perfectly safe: converting a Latin1 const char* to QString preserves all the information. You can disable this constructor by defining \fCQT_NO_CAST_ASCII\fR when you compile your applications. You can also make QString objects by using setLatin1(), fromLatin1(), fromLocal8Bit(), and fromUtf8(). Or whatever encoding is appropriate for the 8-bit data you have..PPSee also isNull()..SH "QString::QString ( const std::string & str )"Constructs a string that is a deep copy of \fIstr\fR..PPThis is the same as fromAscii(\fIstr\fR)..SH "QString::~QString ()"Destroys the string and frees the string's data if this is the last reference to the string..SH "QString & QString::append ( const QString & str )"Appends \fIstr\fR to the string and returns a reference to the result..PP.nf.br        string = "Test";.br        string.append( "ing" );        // string == "Testing".br.fi.PPEquivalent to operator+=()..PPExample: dirview/dirview.cpp..SH "QString & QString::append ( char ch )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPAppends character \fIch\fR to the string and returns a reference to the result..PPEquivalent to operator+=()..SH "QString & QString::append ( QChar ch )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPAppends character \fIch\fR to the string and returns a reference to the result..PPEquivalent to operator+=()..SH "QString & QString::append ( const QByteArray & str )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PP

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -