📄 qstring.3qt
字号:
.SH "QString & QString::operator+= ( const char * str )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPAppends \fIstr\fR to the string and returns a reference to the string..SH "QString & QString::operator+= ( const std::string & str )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPAppends \fIstr\fR to the string and returns a reference to the string..SH "QString & QString::operator+= ( QChar c )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPAppends \fIc\fR to the string and returns a reference to the string..SH "QString & QString::operator+= ( char c )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPAppends \fIc\fR to the string and returns a reference to the string..SH "QString & QString::operator= ( QChar c )"Sets the string to contain just the single character \fIc\fR..SH "QString & QString::operator= ( const QString & s )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPAssigns a shallow copy of \fIs\fR to this string and returns a reference to this string. This is very fast because the string isn't actually copied..SH "QString & QString::operator= ( const char * str )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPAssigns a deep copy of \fIstr\fR, interpreted as a classic C string to this string and returns a reference to this string..PPIf \fIstr\fR is 0, then a null string is created..PPSee also isNull()..SH "QString & QString::operator= ( const std::string & s )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPMakes a deep copy of \fIs\fR and returns a reference to the deep copy..SH "QString & QString::operator= ( const QCString & cs )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPAssigns a deep copy of \fIcs\fR, interpreted as a classic C string, to this string and returns a reference to this string..SH "QString & QString::operator= ( char c )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPSets the string to contain just the single character \fIc\fR..SH "QChar QString::operator[] ( int i ) const"Returns the character at index \fIi\fR, or QChar::null if \fIi\fR is beyond the length of the string..PPIf the QString is not const (i.e., const QString) or const& (i.e., const QString&), then the non-const overload of operator[] will be used instead..SH "QCharRef QString::operator[] ( int i )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPThe function returns a reference to the character at index \fIi\fR. The resulting reference can then be assigned to, or used immediately, but it will become invalid once further modifications are made to the original string..PPIf \fIi\fR is beyond the length of the string then the string is expanded with QChar::nulls, so that the QCharRef references a valid (null) character in the string..PPThe QCharRef internal class can be used much like a constant QChar, but if you assign to it, you change the original string (which will detach itself because of QString's copy-on-write semantics). You will get compilation errors if you try to use the result as anything but a QChar..SH "QString & QString::prepend ( const QString & s )"Inserts \fIs\fR at the beginning of the string and returns a reference to the string..PPEquivalent to insert(0, \fIs\fR)..PP.nf.br QString string = "42";.br string.prepend( "The answer is " );.br // string == "The answer is 42".br.fi.PPSee also insert()..SH "QString & QString::prepend ( char ch )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPInserts \fIch\fR at the beginning of the string and returns a reference to the string..PPEquivalent to insert(0, \fIch\fR)..PPSee also insert()..SH "QString & QString::prepend ( QChar ch )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPInserts \fIch\fR at the beginning of the string and returns a reference to the string..PPEquivalent to insert(0, \fIch\fR)..PPSee also insert()..SH "QString & QString::prepend ( const QByteArray & s )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPInserts \fIs\fR at the beginning of the string and returns a reference to the string..PPEquivalent to insert(0, \fIs\fR)..PPSee also insert()..SH "QString & QString::prepend ( const char * s )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPInserts \fIs\fR at the beginning of the string and returns a reference to the string..PPEquivalent to insert(0, \fIs\fR)..PPSee also insert()..SH "QString & QString::prepend ( const std::string & s )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPInserts \fIs\fR at the beginning of the string and returns a reference to the string..PPEquivalent to insert(0, \fIs\fR)..PPSee also insert()..SH "QChar & QString::ref ( uint i )"Returns the QChar at index \fIi\fR by reference, expanding the string with QChar::null if necessary. The resulting reference can be assigned to, or otherwise used immediately, but becomes invalid once furher modifications are made to the string..PP.nf.br QString string("ABCDEF");.br QChar ch = string.ref( 3 ); // ch == 'D'.br.fi.PPSee also constref()..SH "QString & QString::remove ( uint index, uint len )"Removes \fIlen\fR characters from the string starting at position \fIindex\fR, and returns a reference to the string..PPIf \fIindex\fR is beyond the length of the string, nothing happens. If \fIindex\fR is within the string, but \fIindex\fR + \fIlen\fR is beyond the end of the string, the string is truncated at position \fIindex\fR..PP.nf.br QString string( "Montreal" );.br string.remove( 1, 4 ); // string == "Meal".br.fi.PPSee also insert() and replace()..SH "QString & QString::remove ( QChar c )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPRemoves every occurrence of the character \fIc\fR in the string. Returns a reference to the string..PPThis is the same as replace(\fIc\fR, "")..SH "QString & QString::remove ( char c )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPRemoves every occurrence of the character \fIc\fR in the string. Returns a reference to the string..PPThis is the same as replace(\fIc\fR, "")..SH "QString & QString::remove ( const QString & str )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPRemoves every occurrence of \fIstr\fR in the string. Returns a reference to the string..PPThis is the same as replace(\fIstr\fR, "")..SH "QString & QString::remove ( const QRegExp & rx )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPRemoves every occurrence of the regular expression \fIrx\fR in the string. Returns a reference to the string..PPThis is the same as replace(\fIrx\fR, "")..SH "QString & QString::remove ( const char * str )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPRemoves every occurrence of \fIstr\fR in the string. Returns a reference to the string..SH "QString & QString::replace ( uint index, uint len, const QString & s )"Replaces \fIlen\fR characters from the string with \fIs\fR, starting at position \fIindex\fR, and returns a reference to the string..PPIf \fIindex\fR is beyond the length of the string, nothing is deleted and \fIs\fR is appended at the end of the string. If \fIindex\fR is valid, but \fIindex\fR + \fIlen\fR is beyond the end of the string, the string is truncated at position \fIindex\fR, then \fIs\fR is appended at the end..PP.nf.br QString string( "Say yes!" );.br string = string.replace( 4, 3, "NO" );.br // string == "Say NO!".br.fi.PPSee also insert() and remove()..PPExamples:.)l listviews/listviews.cpp, network/networkprotocol/nntp.cpp, and qmag/qmag.cpp..SH "QString & QString::replace ( uint index, uint len, const QChar * s, uint slen )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPReplaces \fIlen\fR characters with \fIslen\fR characters of QChar data from \fIs\fR, starting at position \fIindex\fR, and returns a reference to the string..PPSee also insert() and remove()..SH "QString & QString::replace ( uint index, uint len, QChar c )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPThis is the same as replace(\fIindex\fR, \fIlen\fR, QString(\fIc\fR))..SH "QString & QString::replace ( uint index, uint len, char c )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPThis is the same as replace(\fIindex\fR, \fIlen\fR, QChar(\fIc\fR))..SH "QString & QString::replace ( QChar c, const QString & after )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPReplaces every occurrence of the character \fIc\fR in the string with \fIafter\fR. Returns a reference to the string..PPExample:.PP.nf.br QString s = "a,b,c";.br s.replace( QChar(','), " or " );.br // s == "a or b or c".br.fi.SH "QString & QString::replace ( char c, const QString & after )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPReplaces every occurrence of the character \fIc\fR in the string with \fIafter\fR. Returns a reference to the string..SH "QString & QString::replace ( const QString & before, const QString & after )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPReplaces every occurrence of the string \fIbefore\fR in the string with the string \fIafter\fR. Returns a reference to the string..PPExample:.PP.nf.br QString s = "Greek is Greek";.br s.replace( "Greek", "English" );.br // s == "English is English".br.fi.SH "QString & QString::replace ( const QRegExp & rx, const QString & str )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPReplaces every occurrence of the regexp \fIrx\fR in the string with \fIstr\fR. Returns a reference to the string. For example:.PP.nf.br QString s = "banana";.br s.replace( QRegExp("an"), "" );.br // s == "ba".br.fi.PPFor regexps containing capturing parentheses, occurrences of \fB\1\fR, \fB\2\fR, ..., in \fIstr\fR are replaced with \fIrx\fR.cap(1), cap(2), ....PP.nf.br QString t = "A <i>bon mot</i>.";.br t.replace( QRegExp("<i>([^<]*)</i>"), "\\\\emph{\\\\1}" );.br // t == "A \\\\emph{bon mot}.".br.fi.PPSee also find(), findRev(), and QRegExp::cap()..SH "QString & QString::replace ( QChar c1, QChar c2 )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPReplaces every occurrence of \fIc1\fR with the char \fIc2\fR. Returns a reference to the string..SH "QString QString::right ( uint len ) const"Returns a string that contains the \fIlen\fR rightmost characters of the string..PPIf \fIlen\fR is greater than the length of the string then the whole string is returned..PP.nf.br QString string( "Pineapple" );.br QString t = string.right( 5 ); // t == "apple".br.fi.PPSee also left(), mid(), and isEmpty()..PPExample: fileiconview/qfileiconview.cpp..SH "QString QString::rightJustify ( uint width, QChar fill = ' ', bool truncate = FALSE ) const"Returns a string of length \fIwidth\fR that contains the \fIfill\fR character followed by the string..PPIf \fItruncate\fR is FALSE and the length of the string is more than \fIwidth\fR, then the returned string is a copy of the string..PPIf \fItruncate\fR is TRUE and the length of the string is more than \fIwidth\fR, then the resulting string is truncated at position \fIwidth\fR..PP.nf.br QString string( "apple" );.br QString t = string.rightJustify( 8, '.' ); // t == "...apple".br.fi.PPSee also leftJustify()..SH "QString QString::section ( QChar sep, int start, int end = 0xffffffff, int flags = SectionDefault ) const"This function returns a section of the string..PPThis string is treated as a sequence of fields separated by the character, \fIsep\fR. The returned string consists of the fields from position \fIstart\fR to position \fIend\fR inclusive. If \fIend\fR is not specified, all fields from position \fIstart\fR 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..PPThe \fIflags\fR argument can be used to affect some aspects of the function's behaviour, e.g. whether to be case sensitive, whether to skip empty fields and how to deal with leading and trailing separators; see SectionFlags..PP.nf.br QString csv( "forename,middlename,surname,phone" );.br QString s = csv.section( ',', 2, 2 ); // s == "surname".br.br QString path( "/usr/local/bin/myapp" ); // First field is empty.br QString s = path.section( '/', 3, 4 ); // s == "bin/myapp".br QString s = path.section( '/', 3, 3, SectionSkipEmpty ); // s == "myapp".br.fi.PPIf \fIstart\fR or \fIend\fR 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..PP.nf.br QString csv( "forename,middlename,surname,phone" );.br QString s = csv.section( ',', -3, -2 ); // s == "middlename,surname".br.br QString path( "/usr/local/bin/myapp" ); // First field is empty.br QString s = path.section( '/', -1 ); // s == "myapp".br.fi.PPSee also QStringList::split()..PPExamples:.)l chart/element.cpp and network/ftpclient/ftpmainwindow.ui.h..SH "QString QString::section ( char sep, int start, int end = 0xffffffff, int flags = SectionDefault ) const"This is an overloa
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -