From bd3a1dd9c287e0a1c35d013c57d83a55de52a470 Mon Sep 17 00:00:00 2001 From: Karsten Heimrich Date: Mon, 9 Nov 2020 14:04:57 +0100 Subject: Doc: Update/scrub QString documentation Fixes: QTBUG-86554 Change-Id: I3d40295115207c430ec30bbac6fb241bf897e5fa Reviewed-by: Andrei Golubev Reviewed-by: Alex Blasche --- src/corelib/doc/snippets/qstring/main.cpp | 24 +++++++++++----------- src/corelib/doc/snippets/qstring/stringbuilder.cpp | 2 +- 2 files changed, 13 insertions(+), 13 deletions(-) (limited to 'src/corelib/doc/snippets') diff --git a/src/corelib/doc/snippets/qstring/main.cpp b/src/corelib/doc/snippets/qstring/main.cpp index 419b98366d..8abe69ed42 100644 --- a/src/corelib/doc/snippets/qstring/main.cpp +++ b/src/corelib/doc/snippets/qstring/main.cpp @@ -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 bold, very bold"; - int j = 0; + qsizetype j = 0; while ((j = str.indexOf("", j)) != -1) { qDebug() << "Found 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] } diff --git a/src/corelib/doc/snippets/qstring/stringbuilder.cpp b/src/corelib/doc/snippets/qstring/stringbuilder.cpp index 74623aeb94..b81b40e10e 100644 --- a/src/corelib/doc/snippets/qstring/stringbuilder.cpp +++ b/src/corelib/doc/snippets/qstring/stringbuilder.cpp @@ -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")) ... -- cgit v1.2.3