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 | 12 |
1 files changed, 9 insertions, 3 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 308fe0a5ac..a4fecc41f9 100644 --- a/src/corelib/doc/snippets/code/src_corelib_text_qbytearray.cpp +++ b/src/corelib/doc/snippets/code/src_corelib_text_qbytearray.cpp @@ -24,7 +24,7 @@ ba[4] = 0xca; //! [2] 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; + cout << "Found character in range [a-f]" << endl; } //! [2] @@ -41,7 +41,7 @@ x.replace(5, 3, "&"); // x == "rock & roll" QByteArray ba("We must be <b>bold</b>, very <b>bold</b>"); qsizetype j = 0; while ((j = ba.indexOf("<b>", j)) != -1) { - cout << "Found <b> tag at index position " << j << Qt::endl; + cout << "Found <b> tag at index position " << j << endl; ++j; } //! [4] @@ -79,7 +79,7 @@ QByteArray("abc").isEmpty(); // returns false QByteArray ba("Hello world"); char *data = ba.data(); while (*data) { - cout << "[" << *data << "]" << Qt::endl; + cout << "[" << *data << "]" << endl; ++data; } //! [8] @@ -472,4 +472,10 @@ QByteArray byteArray = "test"; emscripten::val uint8array = QByteArray::toEcmaUint8Array(byteArray); //! [56] +//! [57] +QByteArray x = "Five pineapples"_ba; +x.slice(5); // x == "pineapples" +x.slice(4, 3); // x == "app" +//! [57] + } |