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 isNullFunction();
|
||||||
void isEmptyFunction();
|
void isEmptyFunction();
|
||||||
void lastIndexOfFunction();
|
void lastIndexOfFunction();
|
||||||
void leftFunction();
|
void firstFunction();
|
||||||
void leftJustifiedFunction();
|
void leftJustifiedFunction();
|
||||||
void midFunction();
|
void slicedFunction();
|
||||||
void numberFunction();
|
void numberFunction();
|
||||||
|
|
||||||
void prependFunction();
|
void prependFunction();
|
||||||
@ -95,7 +95,7 @@ public:
|
|||||||
void replaceFunction();
|
void replaceFunction();
|
||||||
void reserveFunction();
|
void reserveFunction();
|
||||||
void resizeFunction();
|
void resizeFunction();
|
||||||
void rightFunction();
|
void lastFunction();
|
||||||
void rightJustifiedFunction();
|
void rightJustifiedFunction();
|
||||||
void sectionFunction();
|
void sectionFunction();
|
||||||
void setNumFunction();
|
void setNumFunction();
|
||||||
@ -164,7 +164,7 @@ void Widget::atFunction()
|
|||||||
//! [3]
|
//! [3]
|
||||||
QString str;
|
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'))
|
if (str.at(i) >= QChar('a') && str.at(i) <= QChar('f'))
|
||||||
qDebug() << "Found character in range [a-f]";
|
qDebug() << "Found character in range [a-f]";
|
||||||
}
|
}
|
||||||
@ -197,7 +197,7 @@ void Widget::index()
|
|||||||
{
|
{
|
||||||
//! [6]
|
//! [6]
|
||||||
QString str = "We must be <b>bold</b>, very <b>bold</b>";
|
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) {
|
while ((j = str.indexOf("<b>", j)) != -1) {
|
||||||
qDebug() << "Found <b> tag at index position" << j;
|
qDebug() << "Found <b> tag at index position" << j;
|
||||||
@ -478,11 +478,11 @@ void Widget::lastIndexOfFunction()
|
|||||||
//! [94]
|
//! [94]
|
||||||
}
|
}
|
||||||
|
|
||||||
void Widget::leftFunction()
|
void Widget::firstFunction()
|
||||||
{
|
{
|
||||||
//! [31]
|
//! [31]
|
||||||
QString x = "Pineapple";
|
QString x = "Pineapple";
|
||||||
QString y = x.left(4); // y == "Pine"
|
QString y = x.first(4); // y == "Pine"
|
||||||
//! [31]
|
//! [31]
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -499,12 +499,12 @@ void Widget::leftJustifiedFunction()
|
|||||||
//! [33]
|
//! [33]
|
||||||
}
|
}
|
||||||
|
|
||||||
void Widget::midFunction()
|
void Widget::slicedFunction()
|
||||||
{
|
{
|
||||||
//! [34]
|
//! [34]
|
||||||
QString x = "Nine pineapples";
|
QString x = "Nine pineapples";
|
||||||
QString y = x.mid(5, 4); // y == "pine"
|
QString y = x.sliced(5, 4); // y == "pine"
|
||||||
QString z = x.mid(5); // z == "pineapples"
|
QString z = x.sliced(5); // z == "pineapples"
|
||||||
//! [34]
|
//! [34]
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -623,11 +623,11 @@ void Widget::resizeFunction()
|
|||||||
//! [47]
|
//! [47]
|
||||||
}
|
}
|
||||||
|
|
||||||
void Widget::rightFunction()
|
void Widget::lastFunction()
|
||||||
{
|
{
|
||||||
//! [48]
|
//! [48]
|
||||||
QString x = "Pineapple";
|
QString x = "Pineapple";
|
||||||
QString y = x.right(5); // y == "apple"
|
QString y = x.last(5); // y == "apple"
|
||||||
//! [48]
|
//! [48]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@
|
|||||||
QString foo;
|
QString foo;
|
||||||
QString type = "long";
|
QString type = "long";
|
||||||
|
|
||||||
foo->setText(QLatin1String("vector<") + type + QLatin1String(">::iterator"));
|
foo = QLatin1String("vector<") + type + QLatin1String(">::iterator");
|
||||||
|
|
||||||
if (foo.startsWith("(" + type + ") 0x"))
|
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
|
The at() function can be faster than \l operator[](), because it
|
||||||
never causes a \l{deep copy} to occur. Alternatively, use the
|
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.
|
at a time.
|
||||||
|
|
||||||
A QString can embed '\\0' characters (QChar::Null). The size()
|
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
|
Such considerations, the configuration of such behavior or any mitigation
|
||||||
are outside the scope of the Qt API.
|
are outside the scope of the Qt API.
|
||||||
|
|
||||||
\sa fromRawData(), QChar, QLatin1String, QByteArray
|
\sa fromRawData(), QChar, QStringView, QLatin1String, QByteArray
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*! \typedef QString::ConstIterator
|
/*! \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
|
The entire string is returned if \a n is greater than or equal
|
||||||
to size(), or less than zero.
|
to size(), or less than zero.
|
||||||
|
|
||||||
\snippet qstring/main.cpp 31
|
|
||||||
|
|
||||||
\sa first(), last(), startsWith(), chopped(), chop(), truncate()
|
\sa first(), last(), startsWith(), chopped(), chop(), truncate()
|
||||||
*/
|
*/
|
||||||
QString QString::left(qsizetype n) const
|
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
|
The entire string is returned if \a n is greater than or equal
|
||||||
to size(), or less than zero.
|
to size(), or less than zero.
|
||||||
|
|
||||||
\snippet qstring/main.cpp 48
|
|
||||||
|
|
||||||
\sa endsWith(), last(), first(), sliced(), chopped(), chop(), truncate()
|
\sa endsWith(), last(), first(), sliced(), chopped(), chop(), truncate()
|
||||||
*/
|
*/
|
||||||
QString QString::right(qsizetype n) const
|
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
|
\a n is -1 (default), the function returns all characters that
|
||||||
are available from the specified \a position.
|
are available from the specified \a position.
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
\snippet qstring/main.cpp 34
|
|
||||||
|
|
||||||
\sa first(), last(), sliced(), chopped(), chop(), truncate()
|
\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().
|
\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()
|
\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().
|
\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()
|
\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,
|
\note The behavior is undefined when \a pos < 0, \a n < 0,
|
||||||
or \a pos + \a n > size().
|
or \a pos + \a n > size().
|
||||||
|
|
||||||
|
\snippet qstring/main.cpp 34
|
||||||
|
|
||||||
\sa first(), last(), chopped(), chop(), truncate()
|
\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().
|
\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
|
#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.
|
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)
|
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().
|
\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().
|
\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().
|
\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