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

📄 qstring.3qt

📁 Qt/Embedded是一个多平台的C++图形用户界面应用程序框架
💻 3QT
📖 第 1 页 / 共 4 页
字号:
.SH "int QString::findRev ( QChar c, int index=-1, bool cs=TRUE ) const"Finds the first occurrence of the character \fIc,\fR starting at position \fIindex\fR and searching backwards. If \fIindex\fR is -1, the search starts at the last character; if -2, at the next to last character; etc..PPThe search is case sensitive if \fIcs\fR is TRUE, or case insensitive if \fIcs\fR is FALSE..PPReturns the position of \fIc,\fR or -1 if \fIc\fR could not be found..SH "int QString::findRev ( const QRegExp & rx, int index=-1 ) const"Finds the first occurrence of the regular expression \fIrx,\fR starting at position \fIindex\fR and searching backwards. If \fIindex\fR is -1, the search starts at the last character; if -2, at the next to last character; etc..PPReturns the position of the next match (backwards), or -1 if \fIrx\fR was not found..PPSee also find()..SH "int QString::findRev ( const QString & str, int index=-1, bool cs=TRUE ) const"Finds the first occurrence of the string \fIstr,\fR starting at position \fIindex\fR and searching backwards. If \fIindex\fR is -1, the search starts at the last character; -2, at the next to last character; etc..PPThe search is case sensitive if \fIcs\fR is TRUE, or case insensitive if \fIcs\fR is FALSE..PPReturns the position of \fIstr,\fR or -1 if \fIstr\fR could not be found..SH "int QString::findRev ( const char * str, int index=-1 ) const"Equivalent to findRev(QString(str), index)..SH "int QString::findRev ( char c, int index=-1, bool cs=TRUE ) const"This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts..SH "QString QString::fromLatin1 ( const char * chars, int len=-1 ) \fC[static]\fR"Creates a QString from Latin1 text. This is the same as the QString(const char*) constructor, but you can make that constructor invisible if you compile with the define QT_NO_CAST_ASCII, in which case you can explicitly create a QString from Latin-1 text using this function..SH "QString QString::fromLocal8Bit ( const char * local8Bit, int len=-1 ) \fC[static]\fR"Returns the unicode string decoded from the first \fIlen\fR bytes of \fIlocal8Bit.\fR If \fIlen\fR is -1 (the default), the length of \fIlocal8Bit\fR is used. If trailing partial characters are in \fIlocal8Bit,\fR they are ignored..PP\fIlocal8Bit\fR is assumed to be encoded in a locale-specific format..PPSee QTextCodec for more diverse coding/decoding of Unicode strings..SH "QString QString::fromUtf8 ( const char * utf8, int len=-1 ) \fC[static]\fR"Returns the unicode string decoded from the first \fIlen\fR bytes of \fIutf8.\fR If \fIlen\fR is -1 (the default), the length of \fIutf8\fR is used. If trailing partial characters are in \fIutf8,\fR they are ignored..PPSee QTextCodec for more diverse coding/decoding of Unicode strings..SH "QString & QString::insert ( uint index, QChar c )"Insert \fIc\fR into the string at (before) position \fIindex\fR and returns a reference to the string..PPIf \fIindex\fR is beyond the end of the string, the string is extended with spaces (ASCII 32) to length \fIindex\fR and \fIc\fR is then appended..PPExample:.PP.nf.br    QString s = "Ys";.br    s.insert( 1, 'e' );         // s == "Yes".br    s.insert( 3, '!');          // s == "Yes!".fi.PPSee also remove() and replace()..PPExamples:.(lxform/xform.cpp.)l.SH "QString & QString::insert ( uint index, const QChar * s, uint len )"Insert \fIlen\fR units of QChar data from \fIs\fR into the string before position \fIindex.\fR.SH "QString & QString::insert ( uint index, const QString & s )"Insert \fIs\fR into the string before position \fIindex.\fR.PPIf \fIindex\fR is beyond the end of the string, the string is extended with spaces (ASCII 32) to length \fIindex\fR and \fIs\fR is then appended..PP.nf.br    QString s = "I like fish";.br    s.insert( 2, "don't ");     // s == "I don't like fish".br    s = "x";.br    s.insert( 3, "yz" );        // s == "x  yz".fi.SH "QString& QString::insert ( uint index, char c )"This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts..SH "bool QString::isEmpty () const"Returns TRUE if the string is empty, i.e. if length() == 0. An empty string is not always a null string..PPSee example in isNull()..PPSee also isNull() and length()..PPExamples:.(lqmag/qmag.cpp hello/main.cpp.)l.SH "bool QString::isNull () const"Returns TRUE if the string is null. A null string is also an empty string..PPExample:.PP.nf.br    QString a;          // a.unicode() == 0,  a.length() == 0.br    QString b = "";     // b.unicode() == "", b.length() == 0.br    a.isNull();         // TRUE, because a.unicode() == 0.br    a.isEmpty();        // TRUE, because a.length() == 0.br    b.isNull();         // FALSE, because b.unicode() != 0.br    b.isEmpty();        // TRUE, because b.length() == 0.fi.PPSee also isEmpty() and length()..SH "const char* QString::latin1 () const"Returns a Latin-1 representation of the string. Note that the returned value is undefined if the string contains non-Latin-1 characters. If you want to convert strings into formats other than Unicode, see the QTextCodec classes..PPThis function is mainly useful for boot-strapping legacy code to use Unicode..PPThe result remains valid so long as one unmodified copy of the source string exists..PPSee also utf8() and local8Bit()..SH "QString QString::left ( uint len ) const"Returns a substring that contains the \fIlen\fR leftmost characters of the string..PPThe whole string is returned if \fIlen\fR exceeds the length of the string..PPExample:.PP.nf.br    QString s = "Pineapple";.br    QString t = s.left( 4 );    // t == "Pine".fi.PPSee also right(), mid() and isEmpty()..SH "QString QString::leftJustify ( uint width, QChar fill=' ', bool truncate=FALSE ) const"Returns a string of length \fIwidth\fR that contains this string and padded by the \fIfill\fR character..PPIf the length of the string exceeds \fIwidth\fR and \fItruncate\fR is FALSE, then the returned string is a copy of the string. If the length of the string exceeds \fIwidth\fR and \fItruncate\fR is TRUE, then the returned string is a left(\fIwidth).\fR.PPExample:.PP.nf.br    QString s("apple");.br    QString t = s.leftJustify(8, '.');          // t == "apple...".fi.PPSee also rightJustify()..SH "uint QString::length () const"Returns the length of the string..PPNull strings and empty strings have zero length..PPSee also isNull() and isEmpty()..SH "QCString QString::local8Bit () const"Returns the string encoded in a locale-specific format. On X11, this is the QTextCodec::codecForLocale(). On Windows, it is a system-defined encoding..PPSee QTextCodec for more diverse coding/decoding of Unicode strings..PPSee also QString::fromLocal8Bit(), latin1() and utf8()..SH "QString QString::lower () const"Returns a new string that is the string converted to lower case..PPExample:.PP.nf.br    QString s("TeX");.br    QString t = s.lower();      // t == "tex".fi.PPSee also upper()..SH "QString QString::mid ( uint index, uint len=0xffffffff ) const"Returns a substring that contains the \fIlen\fR characters of this string, starting at position \fIindex.\fR.PPReturns a null string if the string is empty or \fIindex\fR is out of range. Returns the whole string from \fIindex\fR if \fIindex+len\fR exceeds the length of the string..PPExample:.PP.nf.br    QString s = "Five pineapples";.br    QString t = s.mid( 5, 4 );                  // t == "pine".fi.PPSee also left() and right()..PPExamples:.(lqmag/qmag.cpp.)l.SH "QString QString::number ( double n, char f='g', int prec=6 ) \fC[static]\fR"This static function returns the printed value of \fIn,\fR formatted in the \\f format with \fIprec\fR precision..PP\fIf\fR can be 'f', 'F', 'e', 'E', 'g' or 'G', all of which have the same meaning as for sprintf()..PPSee also setNum()..SH "QString QString::number ( int n, int base=10 ) \fC[static]\fR"A convenience factory function that returns a string representation of the number \fIn.\fR.PPSee also setNum()..SH "QString QString::number ( long n, int base=10 ) \fC[static]\fR"A convenience factory function that returns a string representation of the number \fIn.\fR.PPSee also setNum()..SH "QString QString::number ( uint n, int base=10 ) \fC[static]\fR"A convenience factory function that returns a string representation of the number \fIn.\fR.PPSee also setNum()..SH "QString QString::number ( ulong n, int base=10 ) \fC[static]\fR"A convenience factory function that returns a string representation of the number \fIn.\fR.PPSee also setNum()..SH "bool QString::operator! () const"Returns TRUE if it is a null string, otherwise FALSE. Thus you can write:.PP.nf.br  QString name = getName();.br  if ( !name ).br    name = "Rodney";.fi.PPNote that if you say:.PP.nf.br  QString name = getName();.br  if ( name ).br    doSomethingWith(name);.fi.PPThen this will call \fCoperator const char*()\fR, which will do what you want, but rather inefficiently - you may wish to define the macro QT_NO_ASCII_CAST when writing code which you wish to strictly remain Unicode-clean..PPWhen you want the above semantics, use \fC!isNull()\fR or even \fC!!\fR:.PP.nf.br  QString name = getName();.br  if ( !!name ).br    doSomethingWith(name);.fi.SH "QString & QString::operator+= ( QChar c )"Appends \fIc\fR to the string and returns a reference to the string..SH "QString & QString::operator+= ( char c )"Appends \fIc\fR to the string and returns a reference to the string..SH "QString& QString::operator+= ( const QString & str )"Appends \fIstr\fR to the string and returns a reference to the string..SH "QString & QString::operator= ( const QCString & cs )"Assigns 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= ( const QString & s )"Assigns a shallow copy of \fIs\fR to this string and returns a reference to this string..SH "QString & QString::operator= ( const char * str )"Assigns 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 a null string is created..PPSee also isNull()..SH "QString& QString::operator= ( QChar c )"Sets the string to contain just the single character \fIc.\fR.SH "QString& QString::operator= ( char c )"Sets the string to contain just the single character \fIc.\fR.SH "QChar QString::operator[] ( int ) const"Returns the character at \fIi,\fR or QChar::null if \fIi\fR is beyond the length of the string..PPNote: If this QString is not const or const&, the non-const operator[] will be used instead, which will expand the string if \fIi\fR is beyond the length of the string..SH "QCharRef QString::operator[] ( int )"Returns an object that references the character at \fIi.\fR This reference can then be assigned to, or otherwise used immediately, but becomes invalid once further modifications are made to the string. The QCharRef internal class can be used much like a constant QChar, but if you assign to it, you change the original string (which enlarges and detaches itself). You will get compilation errors if you try to use the result as anything but a QChar..SH "QString & QString::prepend ( const QString & s )"Prepend \fIs\fR to the string. Equivalent to insert(0,s)..PPSee also insert()..SH "QString& QString::prepend ( QChar ch )"Prepends \fIch\fR to the string and returns a reference to the result..PPSee also insert()..SH "QString& QString::prepend ( char ch )"Prepends \fIch\fR to the string and returns a reference to the result..PPSee also insert()..SH "QChar& QString::ref ( uint i )"Returns the QChar at \fIi\fR by reference..PPSee also constref()..SH "QString & QString::remove ( uint index, uint len )"Removes \fIlen\fR characters starting at position \fIindex\fR from the string and returns a reference to the string..PPIf \fIindex\fR is too big, nothing happens. If \fIindex\fR is valid, but \fIlen\fR is too large, the rest of the string is removed..PP.nf.br    QString s = "Montreal";.br    s.remove( 1, 4 );.br    // s == "Meal".fi.PPSee also insert() and replace()..SH "QString & QString::replace ( const QRegExp & rx, const QString & str )"Replaces every occurrence of \fIrx\fR in the string with \fIstr.\fR Returns a reference to the string..PPExamples:.)l.PP.nf.br    QString s = "banana";.br    s.replace( QRegExp("a.*a"), "" );           // becomes "b".br

⌨️ 快捷键说明

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