Doc: Update/scrub QString documentation
Fixes: QTBUG-86554 Change-Id: I3d40295115207c430ec30bbac6fb241bf897e5fa Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
This commit is contained in:
parent
15f55e9be5
commit
bd3a1dd9c2
@ -85,9 +85,9 @@ public:
|
||||
void isNullFunction();
|
||||
void isEmptyFunction();
|
||||
void lastIndexOfFunction();
|
||||
void leftFunction();
|
||||
void firstFunction();
|
||||
void leftJustifiedFunction();
|
||||
void midFunction();
|
||||
void slicedFunction();
|
||||
void numberFunction();
|
||||
|
||||
void prependFunction();
|
||||
@ -95,7 +95,7 @@ public:
|
||||
void replaceFunction();
|
||||
void reserveFunction();
|
||||
void resizeFunction();
|
||||
void rightFunction();
|
||||
void lastFunction();
|
||||
void rightJustifiedFunction();
|
||||
void sectionFunction();
|
||||
void setNumFunction();
|
||||
@ -164,7 +164,7 @@ void Widget::atFunction()
|
||||
//! [3]
|
||||
QString str;
|
||||
|
||||
for (int i = 0; i < str.size(); ++i) {
|
||||
for (qsizetype i = 0; i < str.size(); ++i) {
|
||||
if (str.at(i) >= QChar('a') && str.at(i) <= QChar('f'))
|
||||
qDebug() << "Found character in range [a-f]";
|
||||
}
|
||||
@ -197,7 +197,7 @@ void Widget::index()
|
||||
{
|
||||
//! [6]
|
||||
QString str = "We must be <b>bold</b>, very <b>bold</b>";
|
||||
int j = 0;
|
||||
qsizetype j = 0;
|
||||
|
||||
while ((j = str.indexOf("<b>", j)) != -1) {
|
||||
qDebug() << "Found <b> tag at index position" << j;
|
||||
@ -478,11 +478,11 @@ void Widget::lastIndexOfFunction()
|
||||
//! [94]
|
||||
}
|
||||
|
||||
void Widget::leftFunction()
|
||||
void Widget::firstFunction()
|
||||
{
|
||||
//! [31]
|
||||
QString x = "Pineapple";
|
||||
QString y = x.left(4); // y == "Pine"
|
||||
QString y = x.first(4); // y == "Pine"
|
||||
//! [31]
|
||||
}
|
||||
|
||||
@ -499,12 +499,12 @@ void Widget::leftJustifiedFunction()
|
||||
//! [33]
|
||||
}
|
||||
|
||||
void Widget::midFunction()
|
||||
void Widget::slicedFunction()
|
||||
{
|
||||
//! [34]
|
||||
QString x = "Nine pineapples";
|
||||
QString y = x.mid(5, 4); // y == "pine"
|
||||
QString z = x.mid(5); // z == "pineapples"
|
||||
QString y = x.sliced(5, 4); // y == "pine"
|
||||
QString z = x.sliced(5); // z == "pineapples"
|
||||
//! [34]
|
||||
}
|
||||
|
||||
@ -623,11 +623,11 @@ void Widget::resizeFunction()
|
||||
//! [47]
|
||||
}
|
||||
|
||||
void Widget::rightFunction()
|
||||
void Widget::lastFunction()
|
||||
{
|
||||
//! [48]
|
||||
QString x = "Pineapple";
|
||||
QString y = x.right(5); // y == "apple"
|
||||
QString y = x.last(5); // y == "apple"
|
||||
//! [48]
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,7 @@
|
||||
QString foo;
|
||||
QString type = "long";
|
||||
|
||||
foo->setText(QLatin1String("vector<") + type + QLatin1String(">::iterator"));
|
||||
foo = QLatin1String("vector<") + type + QLatin1String(">::iterator");
|
||||
|
||||
if (foo.startsWith("(" + type + ") 0x"))
|
||||
...
|
||||
|
@ -1618,7 +1618,7 @@ inline char qToLower(char ch)
|
||||
|
||||
The at() function can be faster than \l operator[](), because it
|
||||
never causes a \l{deep copy} to occur. Alternatively, use the
|
||||
left(), right(), or mid() functions to extract several characters
|
||||
first(), last(), or sliced() functions to extract several characters
|
||||
at a time.
|
||||
|
||||
A QString can embed '\\0' characters (QChar::Null). The size()
|
||||
@ -1917,7 +1917,7 @@ inline char qToLower(char ch)
|
||||
Such considerations, the configuration of such behavior or any mitigation
|
||||
are outside the scope of the Qt API.
|
||||
|
||||
\sa fromRawData(), QChar, QLatin1String, QByteArray
|
||||
\sa fromRawData(), QChar, QStringView, QLatin1String, QByteArray
|
||||
*/
|
||||
|
||||
/*! \typedef QString::ConstIterator
|
||||
@ -4617,8 +4617,6 @@ QString QString::section(const QRegularExpression &re, qsizetype start, qsizetyp
|
||||
The entire string is returned if \a n is greater than or equal
|
||||
to size(), or less than zero.
|
||||
|
||||
\snippet qstring/main.cpp 31
|
||||
|
||||
\sa first(), last(), startsWith(), chopped(), chop(), truncate()
|
||||
*/
|
||||
QString QString::left(qsizetype n) const
|
||||
@ -4637,8 +4635,6 @@ QString QString::left(qsizetype n) const
|
||||
The entire string is returned if \a n is greater than or equal
|
||||
to size(), or less than zero.
|
||||
|
||||
\snippet qstring/main.cpp 48
|
||||
|
||||
\sa endsWith(), last(), first(), sliced(), chopped(), chop(), truncate()
|
||||
*/
|
||||
QString QString::right(qsizetype n) const
|
||||
@ -4660,9 +4656,6 @@ QString QString::right(qsizetype n) const
|
||||
\a n is -1 (default), the function returns all characters that
|
||||
are available from the specified \a position.
|
||||
|
||||
Example:
|
||||
|
||||
\snippet qstring/main.cpp 34
|
||||
|
||||
\sa first(), last(), sliced(), chopped(), chop(), truncate()
|
||||
*/
|
||||
@ -4695,6 +4688,8 @@ QString QString::mid(qsizetype position, qsizetype n) const
|
||||
|
||||
\note The behavior is undefined when \a n < 0 or \a n > size().
|
||||
|
||||
\snippet qstring/main.cpp 31
|
||||
|
||||
\sa last(), sliced(), startsWith(), chopped(), chop(), truncate()
|
||||
*/
|
||||
|
||||
@ -4706,6 +4701,8 @@ QString QString::mid(qsizetype position, qsizetype n) const
|
||||
|
||||
\note The behavior is undefined when \a n < 0 or \a n > size().
|
||||
|
||||
\snippet qstring/main.cpp 48
|
||||
|
||||
\sa first(), sliced(), endsWith(), chopped(), chop(), truncate()
|
||||
*/
|
||||
|
||||
@ -4719,6 +4716,8 @@ QString QString::mid(qsizetype position, qsizetype n) const
|
||||
\note The behavior is undefined when \a pos < 0, \a n < 0,
|
||||
or \a pos + \a n > size().
|
||||
|
||||
\snippet qstring/main.cpp 34
|
||||
|
||||
\sa first(), last(), chopped(), chop(), truncate()
|
||||
*/
|
||||
|
||||
@ -4744,7 +4743,7 @@ QString QString::mid(qsizetype position, qsizetype n) const
|
||||
|
||||
\note The behavior is undefined if \a len is negative or greater than size().
|
||||
|
||||
\sa endsWith(), left(), right(), mid(), chop(), truncate()
|
||||
\sa endsWith(), first(), last(), sliced(), chop(), truncate()
|
||||
*/
|
||||
|
||||
#if QT_STRINGVIEW_LEVEL < 2
|
||||
@ -5573,7 +5572,7 @@ QString QString::trimmed_helper(QString &str)
|
||||
|
||||
If \a position is negative, it is equivalent to passing zero.
|
||||
|
||||
\sa chop(), resize(), left(), QStringView::truncate()
|
||||
\sa chop(), resize(), first(), QStringView::truncate()
|
||||
*/
|
||||
|
||||
void QString::truncate(qsizetype pos)
|
||||
@ -9215,7 +9214,7 @@ QString &QString::setRawData(const QChar *unicode, qsizetype size)
|
||||
|
||||
\note The behavior is undefined when \a length < 0 or \a length > size().
|
||||
|
||||
\sa mid(), left(), right(), chop(), truncate()
|
||||
\sa sliced(), first(), last(), chop(), truncate()
|
||||
*/
|
||||
|
||||
/*!
|
||||
@ -9228,7 +9227,7 @@ QString &QString::setRawData(const QChar *unicode, qsizetype size)
|
||||
|
||||
\note The behavior is undefined when \a length < 0 or \a length > size().
|
||||
|
||||
\sa mid(), left(), right(), chopped(), chop()
|
||||
\sa sliced(), first(), last(), chopped(), chop()
|
||||
*/
|
||||
|
||||
/*!
|
||||
@ -9241,7 +9240,7 @@ QString &QString::setRawData(const QChar *unicode, qsizetype size)
|
||||
|
||||
\note The behavior is undefined when \a length < 0 or \a length > size().
|
||||
|
||||
\sa mid(), left(), right(), chopped(), truncate()
|
||||
\sa sliced(), first(), last(), chopped(), truncate()
|
||||
*/
|
||||
|
||||
/*!
|
||||
|
Loading…
x
Reference in New Issue
Block a user