Obsolete Members for QByteArray
The following members of class QByteArray are obsolete. They are provided to keep old source code working. We strongly advise against using them in new code.
Public Functions
(obsolete) QByteArray | left(qsizetype len) const |
(obsolete) QByteArray | mid(qsizetype pos, qsizetype len = -1) const |
(obsolete) QByteArray | right(qsizetype len) const |
Member Function Documentation
const char *QByteArray::operator const char *() const
const void *QByteArray::operator const void *() const
This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.
Use constData() instead.
Returns a pointer to the data stored in the byte array. The pointer can be used to access the bytes that compose the array. The data is '\0'-terminated.
The pointer remains valid as long as no detach happens and the QByteArray is not modified. This operator is mostly useful to pass a byte array to a function that accepts a const char *
.
You can disable this operator by defining QT_NO_CAST_FROM_BYTEARRAY
when you compile your applications.
Note: A QByteArray can store any byte values including '\0's, but most functions that take char *
arguments assume that the data ends at the first '\0' they encounter.
See also constData().
QByteArray QByteArray::left(qsizetype len) const
This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.
Returns a byte array that contains the first len bytes of this byte array.
Use first() instead in new code.
The entire byte array is returned if len is greater than size().
Returns an empty QByteArray if len is smaller than 0.
Example:
QByteArray x("Pineapple"); QByteArray y = x.left(4); // y == "Pine"
See also first(), last(), startsWith(), chopped(), chop(), and truncate().
QByteArray QByteArray::mid(qsizetype pos, qsizetype len = -1) const
This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.
Returns a byte array containing len bytes from this byte array, starting at position pos.
Use sliced() instead in new code.
If len is -1 (the default), or pos + len >= size(), returns a byte array containing all bytes starting at position pos until the end of the byte array.
Example:
QByteArray x("Five pineapples"); QByteArray y = x.mid(5, 4); // y == "pine" QByteArray z = x.mid(5); // z == "pineapples"
See also first(), last(), sliced(), chopped(), chop(), and truncate().
QByteArray QByteArray::right(qsizetype len) const
This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.
Returns a byte array that contains the last len bytes of this byte array.
Use last() instead in new code.
The entire byte array is returned if len is greater than size().
Returns an empty QByteArray if len is smaller than 0.
Example:
QByteArray x("Pineapple"); QByteArray y = x.right(5); // y == "apple"
See also endsWith(), last(), first(), sliced(), chopped(), chop(), and truncate().