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

📄 qstring.3qt

📁 Linux下的基于X11的图形开发环境。
💻 3QT
📖 第 1 页 / 共 5 页
字号:
Appends \fIstr\fR to the string and returns a reference to the result..PPEquivalent to operator+=()..SH "QString & QString::append ( 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 result..PPEquivalent to operator+=()..SH "QString & QString::append ( 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 result..PPEquivalent to operator+=()..SH "QString QString::arg ( const QString & a, int fieldwidth = 0 ) const"This function will return a string that replaces the lowest numbered occurrence of \fC%1\fR, \fC%2\fR, ..., \fC%9\fR with \fIa\fR..PPThe \fIfieldwidth\fR value specifies the minimum amount of space that \fIa\fR is padded to. A positive value will produce right-aligned text, whereas a negative value will produce left-aligned text..PP.nf.br        QString firstName( "Joe" );.br        QString lastName( "Bloggs" );.br        QString fullName;.br        fullName = QString( "First name is '%1', last name is '%2'" ).br                    .arg( firstName ).br                    .arg( lastName );.br.br        // fullName == First name is 'Joe', last name is 'Bloggs'.br.fi.PPNote that using arg() to construct sentences as we've done in the example above does not usually translate well into other languages because sentence structure and word order often differ between languages..PPIf there is no place marker (\fC%1\fR or \fC%2\fR, etc.), a warning message (qWarning()) is output and the text is appended at the end of the string. We recommend that the correct number of place markers is always used in production code..SH "QString QString::arg ( long a, int fieldwidth = 0, int base = 10 ) const"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPThe \fIfieldwidth\fR value specifies the minimum amount of space that \fIa\fR is padded to. A positive value will produce a right-aligned number, whereas a negative value will produce a left-aligned number..PP\fIa\fR is expressed in base \fIbase\fR, which is 10 by default and must be between 2 and 36..PP.nf.br        QString str;.br        str = QString( "Decimal 63 is %1 in hexadecimal" ).br                .arg( 63, 0, 16 );.br        // str == "Decimal 63 is 3f in hexadecimal".br.fi.SH "QString QString::arg ( ulong a, int fieldwidth = 0, int base = 10 ) const"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PP\fIa\fR is expressed in base \fIbase\fR, which is 10 by default and must be between 2 and 36..SH "QString QString::arg ( int a, int fieldwidth = 0, int base = 10 ) const"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PP\fIa\fR is expressed in base \fIbase\fR, which is 10 by default and must be between 2 and 36..SH "QString QString::arg ( uint a, int fieldwidth = 0, int base = 10 ) const"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PP\fIa\fR is expressed in base \fIbase\fR, which is 10 by default and must be between 2 and 36..SH "QString QString::arg ( short a, int fieldwidth = 0, int base = 10 ) const"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PP\fIa\fR is expressed in base \fIbase\fR, which is 10 by default and must be between 2 and 36..SH "QString QString::arg ( ushort a, int fieldwidth = 0, int base = 10 ) const"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PP\fIa\fR is expressed in base \fIbase\fR, which is 10 by default and must be between 2 and 36..SH "QString QString::arg ( char a, int fieldwidth = 0 ) const"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PP\fIa\fR is assumed to be in the Latin1 character set..SH "QString QString::arg ( QChar a, int fieldwidth = 0 ) const"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..SH "QString QString::arg ( double a, int fieldwidth = 0, char fmt = 'g', int prec = -1 ) const"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPArgument \fIa\fR is formatted according to the \fIfmt\fR format specified, which is 'g' by default and can be any of the following:.PP<center>.nf.TSl - l. Format Meaning format as [-]9.9e[+|-]999 format as [-]9.9E[+|-]999 format as [-]9.9 use use.TE.fi</center>.PPWith 'e', 'E', and 'f', \fIprec\fR is the number of digits after the decimal point. With 'g' and 'G', \fIprec\fR is the maximum number of significant digits (trailing zeroes are omitted)..PP.nf.br        double d = 12.34;.br        QString ds = QString( "'E' format, precision 3, gives %1" ).br                        .arg( d, 0, 'E', 3 );.br        // ds == "1.234E+001".br.fi.SH "const char * QString::ascii () const"Returns an 8-bit ASCII representation of the string..PPIf a codec has been set using QTextCodec::codecForCStrings(), it is used to convert Unicode to 8-bit char. Otherwise, this function does the same as latin1()..PPSee also fromAscii(), latin1(), utf8(), and local8Bit()..PPExample: network/networkprotocol/nntp.cpp..SH "QChar QString::at ( uint i ) const"Returns the character at index \fIi\fR, or 0 if \fIi\fR is beyond the length of the string..PP.nf.br        const QString string( "abcdefgh" );.br        QChar ch = string.at( 4 );.br        // ch == 'e'.br.fi.PPIf the QString is not const (i.e. const QString) or const& (i.e. const QString &), then the non-const overload of at() will be used instead..SH "QCharRef QString::at ( uint 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::null..SH "int QString::compare ( const QString & s1, const QString & s2 )\fC [static]\fR"Lexically compares \fIs1\fR with \fIs2\fR and returns an integer less than, equal to, or greater than zero if \fIs1\fR is less than, equal to, or greater than \fIs2\fR..PPThe comparison is based exclusively on the numeric Unicode values of the characters and is very fast, but is not what a human would expect. Consider sorting user-interface strings with QString::localeAwareCompare()..PP.nf.br        int a = QString::compare( "def", "abc" );   // a > 0.br        int b = QString::compare( "abc", "def" );   // b < 0.br        int c = QString::compare(" abc", "abc" );   // c == 0.br.fi.SH "int QString::compare ( const QString & s ) const"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPLexically compares this string with \fIs\fR and returns an integer less than, equal to, or greater than zero if it is less than, equal to, or greater than \fIs\fR..SH "void QString::compose ()"\fBWarning:\fR This function is not supported in Qt 3.x. It is provided for experimental and illustrative purposes only. It is mainly of interest to those experimenting with Arabic and other composition-rich texts..PPApplies possible ligatures to a QString. Useful when composition-rich text requires rendering with glyph-poor fonts, but it also makes compositions such as QChar(0x0041) ('A') and QChar(0x0308) (Unicode accent diaresis), giving QChar(0x00c4) (German A Umlaut)..SH "QChar QString::constref ( uint i ) const"Returns the QChar at index \fIi\fR by value..PPEquivalent to at(\fIi\fR)..PPSee also ref()..SH "int QString::contains ( QChar c, bool cs = TRUE ) const"Returns the number of times the character \fIc\fR occurs in the string..PPIf \fIcs\fR is TRUE, the search is case sensitive; otherwise the search is case insensitive..PP.nf.br    QString string( "Trolltech and Qt" );.br    int i = string.contains( 't', FALSE );  // i == 3.br.fi.PPExamples:.)l fileiconview/qfileiconview.cpp and mdi/application.cpp..SH "int QString::contains ( char c, bool cs = TRUE ) const"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..SH "int QString::contains ( const char * str, bool cs = TRUE ) const"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPReturns the number of times the string \fIstr\fR occurs in the string..PPIf \fIcs\fR is TRUE, the search is case sensitive; otherwise the search is case insensitive..SH "int QString::contains ( const QString & str, bool cs = TRUE ) const"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPReturns the number of times \fIstr\fR occurs in the string..PPIf \fIcs\fR is TRUE, the search is case sensitive; otherwise the search is case insensitive..PPThis function counts overlapping strings, so in the example below, there are two instances of "ana" in "bananas"..PP.nf.br    QString str( "bananas" );.br    int i = str.contains( "ana" );  // i == 2.br.fi.PPSee also findRev()..SH "int QString::contains ( const QRegExp & rx ) const"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPReturns the number of times the regexp, \fIrx\fR, matches in the string..PPThis function counts overlapping matches, so in the example below, there are four instances of "ana" or "ama"..PP.nf.br        QString str = "banana and panama";.br        QRegExp rxp = QRegExp( "a[nm]a", TRUE, FALSE );.br        int i = str.contains( rxp );    // i == 4.br.fi.PPSee also find() and findRev()..SH "QString QString::copy () const"\fBThis function is obsolete.\fR It is provided to keep old source working. We strongly advise against using it in new code..PPIn Qt 2.0 and later, all calls to this function are needless. Just remove them..SH "const char * QString::data () const"\fBThis function is obsolete.\fR It is provided to keep old source working. We strongly advise against using it in new code..PPReturns a pointer to a '&#92;0'-terminated classic C string..PPIn Qt 1.x, this returned a char* allowing direct manipulation of the string as a sequence of bytes. In Qt 2.x where QString is a Unicode string, char* conversion constructs a temporary string, and hence direct character operations are meaningless..SH "bool QString::endsWith ( const QString & s ) const"Returns TRUE if the string ends with \fIs\fR; otherwise returns FALSE..PPSee also startsWith()..PPExample: chart/main.cpp..SH "QString & QString::fill ( QChar c, int len = -1 )"Fills the string with \fIlen\fR characters of value \fIc\fR, and returns a reference to the string..PPIf \fIlen\fR is negative (the default), the current string length is used..PP.nf.br        QString str;.br        str.fill( 'g', 5 );      // string == "ggggg".br.fi.SH "int QString::find ( const QRegExp & rx, int index = 0 ) const"Finds the first match of the regular expression \fIrx\fR, starting from position \fIindex\fR. If \fIindex\fR is -1, the search starts at the last character; if -2, at the next to last character and so on. (See findRev() for searching backwards.).PPReturns the position of the first match of \fIrx\fR or -1 if no match was found..PP.nf.br        QString string( "bananas" );.br        int i = string.find( QRegExp("an"), 0 );    // i == 1.br.fi.PPSee also findRev(), replace(), and contains()..PPExample: network/mail/smtp.cpp..SH "int QString::find ( QChar c, int index = 0, bool cs = TRUE ) const"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPFinds the first occurrence of the character \fIc\fR, starting at position \fIindex\fR. If \fIindex\fR is -1, the search starts at the last character; if -2, at the next to last character and so on. (See findRev() for searching backwards.).PPIf \fIcs\fR is TRUE, the search is case sensitive; otherwise the search is case insensitive..PPReturns the position of \fIc\fR or -1 if \fIc\fR could not be found..SH "int QString::find ( char c, int index = 0, bool cs = TRUE ) const"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPFind character \fIc\fR starting from position \fIindex\fR..PPIf \fIcs\fR is TRUE, the search is case sensitive; otherwise the search is case insensitive..SH "int QString::find ( const QString & str, int index = 0, bool cs = TRUE ) const"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPFinds the first occurrence of the string \fIstr\fR, starting at position \fIindex\fR. If \fIindex\fR is -1, the search starts at the last character, if it is -2, at the next to last character and so on. (See findRev() for searching backwards.).PPIf \fIcs\fR is TRUE, the search is case sensitive; otherwise the search is case insensitive..PPReturns the position of \fIstr\fR or -1 if \fIstr\fR could not be found..SH "int QString::find ( const char * str, int index = 0 ) const"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPEquivalent to find(QString(\fIstr\fR), \fIindex\fR)..SH "int QString::findRev ( const char * str, int index = -1 ) const"Equivalent to findRev(QString(\fIstr\fR), \fIindex\fR)..SH "int QString::findRev ( QChar c, int index = -1, bool cs = TRUE ) const"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPFinds the first occurrence of the character \fIc\fR, starting at position \fIindex\fR and searching backwards. If the index is -1, the search starts at the last character, if it is -2, at the next to last character and so on..PPReturns the position of \fIc\fR or -1 if \fIc\fR could not be found..PPIf \fIcs\fR is TRUE, the search is case sensitive; otherwise the search is case insensitive..PP.nf.br        QString string( "bananas" );.br        int i = string.findRev( 'a' );      // i == 5.br.fi.SH "int QString::findRev ( char c, int index = -1, bool cs = TRUE ) const"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPFind character \fIc\fR starting from position \fIindex\fR and working backwards..PPIf \fIcs\fR is TRUE, the search is case sensitive; otherwise the search is case insensitive..SH "int QString::findRev ( const QString & str, int index = -1, bool cs = TRUE ) const"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPFinds the first occurrence of the string \fIstr\fR, starting at position \fIindex\fR and searching backwards. If the index is -1, the search starts at the last character, if it is -2, at the next to last character and so on..PPReturns the position of \fIstr\fR or -1 if \fIstr\fR could not be found..PPIf \fIcs\fR is TRUE, the search is case sensitive; otherwise the search is case insensitive..PP.nf.br    QString string("bananas");.br    int i = string.findRev( "ana" );      // i == 3.br.fi.SH "int QString::findRev ( const QRegExp & rx, int index = -1 ) const"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPFinds the first match of the regexp \fIrx\fR, starting at position \fIindex\fR and searching backwards. If the index is -1, the search starts at the last character, if it is -2, at the next to last character and so on. (See findRev() for searching backwards.).PPReturns the position of the match or -1 if no match was found..PP.nf

⌨️ 快捷键说明

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