summaryrefslogtreecommitdiffstats
path: root/src/corelib/doc/snippets
diff options
context:
space:
mode:
authorKarsten Heimrich <karsten.heimrich@qt.io>2020-10-27 14:20:06 +0100
committerKarsten Heimrich <karsten.heimrich@qt.io>2020-10-29 09:26:33 +0100
commit173615222a1c8b94aca3ee5e5d31308d77380db7 (patch)
tree85e594fcd4fae759598b9fce7aeaf3e3bc216e14 /src/corelib/doc/snippets
parentb961fb42e298673e2a6729df415ae19e85a82bd0 (diff)
Doc: Scrub QByteArray/QByteArrayView documentation
Fixes: QTBUG-86555 Change-Id: I3221e0de10e692ca767eeb69daa82da55b93e395 Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'src/corelib/doc/snippets')
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_text_qbytearray.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/corelib/doc/snippets/code/src_corelib_text_qbytearray.cpp b/src/corelib/doc/snippets/code/src_corelib_text_qbytearray.cpp
index 0159e624eb..625f34e151 100644
--- a/src/corelib/doc/snippets/code/src_corelib_text_qbytearray.cpp
+++ b/src/corelib/doc/snippets/code/src_corelib_text_qbytearray.cpp
@@ -69,7 +69,7 @@ ba[4] = 0xca;
//! [2]
-for (int i = 0; i < ba.size(); ++i) {
+for (qsizetype i = 0; i < ba.size(); ++i) {
if (ba.at(i) >= 'a' && ba.at(i) <= 'f')
cout << "Found character in range [a-f]" << Qt::endl;
}
@@ -86,7 +86,7 @@ x.replace(5, 3, "&"); // x == "rock & roll"
//! [4]
QByteArray ba("We must be <b>bold</b>, very <b>bold</b>");
-int j = 0;
+qsizetype j = 0;
while ((j = ba.indexOf("<b>", j)) != -1) {
cout << "Found <b> tag at index position " << j << Qt::endl;
++j;
@@ -108,7 +108,7 @@ QByteArray("abc").isEmpty(); // returns false
//! [6]
QByteArray ba("Hello");
-int n = ba.size(); // n == 5
+qsizetype n = ba.size(); // n == 5
ba.data()[0]; // returns 'H'
ba.data()[4]; // returns 'o'
ba.data()[5]; // returns '\0'
@@ -276,22 +276,22 @@ if (url.endsWith(".html"))
//! [27]
QByteArray x("Pineapple");
-QByteArray y = x.left(4);
+QByteArray y = x.first(4);
// y == "Pine"
//! [27]
//! [28]
QByteArray x("Pineapple");
-QByteArray y = x.right(5);
+QByteArray y = x.last(5);
// y == "apple"
//! [28]
//! [29]
QByteArray x("Five pineapples");
-QByteArray y = x.mid(5, 4); // y == "pine"
-QByteArray z = x.mid(5); // z == "pineapples"
+QByteArray y = x.sliced(5, 4); // y == "pine"
+QByteArray z = x.sliced(5); // z == "pineapples"
//! [29]