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

📄 qstring.3qt

📁 tmark1.11:用于生成QT/EMBEDDED应用工程的Markfile文件
💻 3QT
📖 第 1 页 / 共 3 页
字号:
  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 interpretted 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 "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 ( char ch )"Prepends \fIch\fR to the string and returns a reference to the result..PPSee also: insert()..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.br    QString s = "banana";.br    s.replace( QRegExp("^[bn]a"), " " );        // becomes " nana".br.br    QString s = "banana";.br    s.replace( QRegExp("^[bn]a"), "" );         // NOTE! becomes "".fi.SH "QString & QString::replace ( uint index, uint len, const QChar * s, uint slen )"Replaces \fIlen\fR characters starting at position \fIindex\fR by \fIslen\fR units ot QChar data from \fIs,\fR and returns a reference to the string..PPSee also: insert() and remove()..SH "QString & QString::replace ( uint index, uint len, const QString & s )"Replaces \fIlen\fR characters starting at position \fIindex\fR from the string with \fIs,\fR and returns a reference to the string..PPIf \fIindex\fR is too big, nothing is deleted and \fIs\fR is inserted at the end of the string. If \fIindex\fR is valid, but \fIlen\fR is too large, \fIstr\fR replaces the rest of the string..PP.nf.br    QString s = "Say yes!";.br    s.replace( 4, 3, "NO" );                    // s == "Say NO!".fi.PPSee also: insert() and remove()..PPExamples:.(lqmag/qmag.cpp.)l.SH "QString QString::right ( uint len ) const"Returns a substring that contains the \fIlen\fR rightmost 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.right( 5 );                   // t == "apple".fi.PPSee also: left(), mid() and isEmpty()..SH "QString QString::rightJustify ( uint width, QChar fill=' ', bool truncate=FALSE ) const"Returns a string of length \fIwidth\fR that contains pad characters followed by the string..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 right(\fIwidth).\fR.PPExample:.PP.nf.br    QString s("pie");.br    QString t = s.rightJustify(8, '.');         // t == ".....pie".fi.PPSee also: leftJustify()..SH "void QString::setExpand ( uint index, QChar c )"\fBThis function is obsolete.\fR It is provided to keep old programs working. We strongly advise against using it in new code..PPSets the character at position \fIindex\fR to \fIc\fR and expands the string if necessary, filling with spaces..PPThis method is redundant in Qt 2.x, because operator[] will expand the string as necessary, if you are assigning a value..SH "QString & QString::setNum ( double n, char f='g', int prec=6 )"Sets the string to the printed value of \fIn.\fR.PPArguments:.TP\fIf\fR is the format specifier: 'f', 'F', 'e', 'E', 'g', 'G' (same as sprintf())..TP\fIprec\fR is the precision. Returns a reference to the string..PPExamples:.(ltable/main.cpp.)l.SH "QString & QString::setNum ( float n, char f='g', int prec=6 )"Sets the string to the printed value of \fIn.\fR.PPArguments:.TP\fIf\fR is the format specifier: 'f', 'F', 'e', 'E', 'g', 'G' (same as sprintf())..TP\fIprec\fR is the precision. Returns a reference to the string..SH "QString & QString::setNum ( int n, int base=10 )"Sets the string to the printed value of \fIn\fR and returns a reference to the string..SH "QString & QString::setNum ( long n, int base=10 )"Sets the string to the printed value of \fIn\fR and returns a reference to the string..PPThe value is converted to \fIbase\fR notation (default is decimal). The base must be a value from 2 to 36..SH "QString & QString::setNum ( short n, int base=10 )"Sets the string to the printed value of \fIn\fR and returns a reference to the string..SH "QString & QString::setNum ( uint n, int base=10 )"Sets the string to the printed unsigned value of \fIn\fR and returns a reference to the string..SH "QString & QString::setNum ( ulong n, int base=10 )"Sets the string to the printed unsigned value of \fIn\fR and returns a reference to the string..PPThe value is converted to \fIbase\fR notation (default is decimal). The base must be a value from 2 to 36..SH "QString & QString::setNum ( ushort n, int base=10 )"Sets the string to the printed unsigned value of \fIn\fR and returns a reference to the string..SH "QString QString::simplifyWhiteSpace () const"Returns a new string that has white space removed from the start and the end, plus any sequence of internal white space replaced with a single space (ASCII 32)..PPWhite space means any character for which QChar::isSpace() returns TRUE. This includes ASCII characters 9 (TAB), 10 (LF), 11 (VT), 12 (FF), 13 (CR), and 32 (Space)..PP.nf.br    QString s = "  lots\\t of\\nwhite    space ";.br    QString t = s.simplifyWhiteSpace();         // t == "lots of white space".fi.PPSee also: stripWhiteSpace()..SH "QString & QString::sprintf ( const char * cformat, ... )"Safely builds a formatted string from a format string and an arbitrary list of arguments. The format string supports all the escape sequences of printf() in the standard C library..PPThe %s escape sequence expects a UTF-8 encoded string. For typesafe string building, with full Unicode support, you can use QTextOStream like this:.PP.nf.br    QString str;.br    QString s = ...;.br    int x = ...;.br    QTextOStream(&str) << s << " : " << x;.fi.PPFor translations, especially if the strings contains more than one escape sequence, you should consider using the arg() function instead. This allows the order of the replacements to be controlled by the translator, and has Unicode support..PPSee also: arg(const and QString&,int)..PPExamples:.(lxform/xform.cpp layout/layout.cpp drawdemo/drawdemo.cpp popup/popup.cpp progress/progress.cpp qmag/qmag.cpp forever/forever.cpp scrollview/scrollview.cpp movies/main.cpp picture/picture.cpp.)l.SH "QString QString::stripWhiteSpace () const"Returns a new string that has white space removed from the start and the end..PPWhite space means any character for which QChar::isSpace() returns TRUE. This includes ASCII characters 9 (TAB), 10 (LF), 11 (VT), 12 (FF), 13 (CR), and 32 (Space)..PPExample:.PP.nf.br    QString s = " space ";.br    QString t = s.stripWhiteSpace();            // t == "space".fi.PPSee also: simplifyWhiteSpace()..SH "double QString::toDouble ( bool * ok=0 ) const"Returns the string converted to a \fCdouble\fR value..PPIf \fIok\fR is non-null, \fI*ok\fR is set to TRUE if there are no conceivable errors, and FALSE if the string is not a number at all, or if it has trailing garbage..SH "float QString::toFloat ( bool * ok=0 ) const"Returns the string converted to a \fCfloat\fR value..PPIf \fIok\fR is non-null, \fI*ok\fR is set to TRUE if there are no conceivable errors, and FALSE if the string is not a number at all, or if it has trailing garbage..SH "int QString::toInt ( bool * ok=0, int base=10 ) const"Returns the string converted to a \fCint\fR value..PPIf \fIok\fR is non-null, \fI*ok\fR is set to TRUE if there are no conceivable errors, and FALSE if the string is not a number at all, or if it has trailing garbage..SH "long QString::toLong ( bool * ok=0, int base=10 ) const"Returns the string converted to a \fClong\fR value..PPIf \fIok\fR is non-null, \fI*ok\fR is set to TRUE if there are no conceivable errors, and FALSE if the string is not a number at all, or if it has trailing garbage..SH "short QString::toShort ( bool * ok=0, int base=10 ) const"Returns the string converted to a \fCshort\fR value..PPIf \fIok\fR is non-null, \fI*ok\fR is set to TRUE if there are no conceivable errors, and FALSE if the string is not a number at all, or if it has trailing garbage..SH "uint QString::toUInt ( bool * ok=0, int base=10 ) const"Returns the string converted to an \fCunsigned int\fR value..PPIf \fIok\fR is non-null, \fI*ok\fR is set to TRUE if there are no conceivable errors, and FALSE if the string is not a number at all, or if it has trailing garbage..SH "ulong QString::toULong ( bool * ok=0, int base=10 ) const"Returns the string converted to an \fCunsigned long\fR value..PPIf \fIok\fR is non-null, \fI*ok\fR is set to TRUE if there are no conceivable errors, and FALSE if the string is not a number at all, or if it has trailing garbage..SH "ushort QString::toUShort ( bool * ok=0, int base=10 ) const"Returns the string converted to an \fCunsigned short\fR value..PPIf \fIok\fR is non-null, \fI*ok\fR is set to TRUE if there are no conceivable errors, and FALSE if the string is not a number at all, or if it has trailing garbage..SH "void QString::truncate ( uint newLen )"Truncates the string at position \fInewLen.\fR If newLen is less than the current length, this is equivalent to setLength( newLen ). Otherwise, nothing happens..PPExample:.PP.nf.br    QString s = "truncate this string";.br    s.truncate( 5 );                            // s == "trunc".fi.PPIn Qt 1.x, it was possible to "truncate" a string to a longer length. This is no longer possible..PPSee also: setLength()..SH "const QChar* QString::unicode () const"Returns the Unicode representation of the string. The result remains valid until the string is modified..SH "QString QString::upper () const"Returns a new string that is the string converted to upper case..PPExample:.PP.nf.br    QString s("TeX");.br    QString t = s.upper();                      // t == "TEX".fi.PPSee also: lower()..SH "QCString QString::utf8 () const"Returns the string encoded in UTF8 format..PPSee QTextCodec for more diverse coding/decoding of Unicode strings..PPSee also: QString::fromUtf8() and local8Bit()..SH "QString QString::visual ( int index = 0, int len = -1 )"This function returns the QString ordered visually. Useful for painting the string or when transforming to a visually ordered encoding..SH RELATED FUNCTION DOCUMENTATION.SH "QDataStream & operator>> (QDataStream & s, QString & str)"Reads a string from the stream..SH "QString operator+ (const char * s1, const QString & s2)"Returns the concatenated string of s1 and s2..SH "bool operator<= (const char * s1, const QString & s2)"Returns TRUE if \fIs1\fR is alphabetically less than or equal to \fIs2,\fR otherwise FALSE..PPEquivalent to \fCstrcmp(s1,s2) <= 0\fR.SH "QString operator+ (const QString & s1, const char * s2)"Returns the concatenated string of s1 and s2..SH "QString operator+ (const QString & s1, const QString & s2)"Returns the concatenated string of s1 and s2..SH "QDataStream & operator<< (QDataStream & s, const QString & str)"Writes a string to the stream..PPOutput format: [length (Q_UINT32) data...]..SH "bool operator== (const QString & s1, const QString & s2)"Returns TRUE if the two strings are equal, or FALSE if they are different..PPEquivalent to \fCstrcmp(s1,s2) == 0\fR.SH "bool operator!= (const QString & s1, const QString & s2)"Returns TRUE if the two strings are different, or FALSE if they are equal..PPEquivalent to \fCstrcmp(s1,s2) != 0\fR.SH "bool operator!= (const QString & s1, const char * s2)"Returns TRUE if the two strings are different, or FALSE if they are equal..PPEquivalent to \fCstrcmp(s1,s2) != 0\fR.SH "bool operator< (const char * s1, const QString & s2)"Returns TRUE if \fIs1\fR is alphabetically less than \fIs2,\fR otherwise FALSE..PPEquivalent to \fCstrcmp(s1,s2) < 0\fR.SH "bool operator>= (const char * s1, const QString & s2)"Returns TRUE if \fIs1\fR is alphabetically greater than or equal to \fIs2,\fR otherwise FALSE..PPEquivalent to \fCstrcmp(s1,s2) >= 0\fR.SH "QString operator+ (char c, const QString & s)"Returns the concatenated string of c and s..SH "bool operator<= (const QString & s1, const char * s2)"Returns TRUE if \fIs1\fR is alphabetically less than or equal to \fIs2,\fR otherwise FALSE..PPEquivalent to \fCstrcmp(s1,s2) <= 0\fR.SH "QString operator+ (const QString & s, char c)"Returns the concatenated string of s and c..SH "bool operator> (const char * s1, const QString & s2)"Returns TRUE if \fIs1\fR is alphabetically greater than \fIs2,\fR otherwise FALSE..PPEquivalent to \fCstrcmp(s1,s2) > 0\fR.SH "bool operator< (const QString & s1, const char * s2)"Returns TRUE if \fIs1\fR is alphabetically less than \fIs2,\fR otherwise FALSE..PPEquivalent to \fCstrcmp(s1,s2) < 0\fR.SH "bool operator!= (const char * s1, const QString & s2)"Returns TRUE if the two strings are different, or FALSE if they are equal..PPEquivalent to \fCstrcmp(s1,s2) != 0\fR.SH "bool operator== (const QString & s1, const char * s2)"Returns TRUE if the two strings are equal, or FALSE if they are different..PPEquivalent to \fCstrcmp(s1,s2) == 0\fR.SH "bool operator== (const char * s1, const QString & s2)"Returns TRUE if the two strings are equal, or FALSE if they are different..PPEquivalent to \fCstrcmp(s1,s2) == 0\fR.SH "bool operator> (const QString & s1, const char * s2)"Returns TRUE if \fIs1\fR is alphabetically greater than \fIs2,\fR otherwise FALSE..PPEquivalent to \fCstrcmp(s1,s2) > 0\fR.SH "bool operator>= (const QString & s1, const char * s2)"Returns TRUE if \fIs1\fR is alphabetically greater than or equal to \fIs2,\fR otherwise FALSE..PPEquivalent to \fCstrcmp(s1,s2) >= 0\fR.SH "SEE ALSO".BR http://www.troll.no/qt/qstring.html.SH COPYRIGHTCopyright 1992-1999 Troll Tech AS.  See the license file included inthe distribution for a complete license statement..SH AUTHORGenerated automatically from the source code.

⌨️ 快捷键说明

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