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 | 16 |
1 files changed, 11 insertions, 5 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 2a780f1c49..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] @@ -464,12 +464,18 @@ QByteArray decoded = encoded.percentDecoded(); // Set to "Qt is great!" //! [55] emscripten::val uint8array = emscripten::val::global("g_uint8array"); -QByteArray byteArray = QByteArray::fromUint8Array(uint8array); +QByteArray byteArray = QByteArray::fromEcmaUint8Array(uint8array); //! [55] //! [56] QByteArray byteArray = "test"; -emscripten::val uint8array = QByteArray::toUint8Array(byteArray); +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] + } |