diff options
Diffstat (limited to 'src/corelib/doc/snippets/code/src_corelib_text_qbytearray.cpp')
-rw-r--r-- | src/corelib/doc/snippets/code/src_corelib_text_qbytearray.cpp | 14 |
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] |