PythonQt.QtCore.QByteArray · declarations 001
Back to PythonQt.QtCore.QByteArray
Base64Encoding
instance-attribute
Base64Encoding: Any
Base64Option
instance-attribute
Base64Option: type
int([x]) -> integer int(x, base=10) -> integer
Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.int(). For floating point numbers, this truncates towards zero.
If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by '+' or '-' and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer literal.
int('0b100', base=0) 4
Base64Options
instance-attribute
Base64Options: type
int([x]) -> integer int(x, base=10) -> integer
Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.int(). For floating point numbers, this truncates towards zero.
If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by '+' or '-' and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer literal.
int('0b100', base=0) 4
Base64UrlEncoding
instance-attribute
Base64UrlEncoding: Any
KeepTrailingEquals
instance-attribute
KeepTrailingEquals: Any
OmitTrailingEquals
instance-attribute
OmitTrailingEquals: Any
append
append(s: Any, len: Any) -> Any
X.append(s, len) -> PythonQt.QtCore.QByteArray
Supplemental documentation: Qt 5 reference:
QByteArray \&QByteArray::append(const QByteArray \&ba)
Appends the byte array ba onto the end of this byte array.
Example:
QByteArray x("free");
QByteArray y("dom");
x.append(y);
// x == "freedom"
This is the same as insert(size(), ba).
Note: QByteArray is an implicitly shared class. Consequently, if you append to an empty byte array, then the byte array will just share the data held in ba. In this case, no copying of data is done, taking constant time. If a shared instance is modified, it will be copied (copy-on-write), taking linear time.
If the byte array being appended to is not empty, a deep copy of the data is performed, taking linear time.
This operation typically does not suffer from allocation overhead, because QByteArray preallocates extra space at the end of the data so that it may grow without reallocating for each append operation.
See also operator+\=(), prepend(), and insert().
QByteArray \&QByteArray::append(char ch)
This is an overloaded function.
Appends the character ch to this byte array.
QByteArray \&QByteArray::append(int count, char ch)
This is an overloaded function.
Appends count copies of character ch to this byte array and returns a reference to this byte array.
If count is negative or zero nothing is appended to the byte array.
This function was introduced in Qt 5.7.
QByteArray \&QByteArray::append(const char *str)
This is an overloaded function.
Appends the string str to this byte array.
QByteArray \&QByteArray::append(const char *str, int len)
This function overloads append().
Appends the first len characters of the string str to this byte array and returns a reference to this byte array.
If len is negative, the length of the string will be determined automatically using qstrlen(). If len is zero or str is null, nothing is appended to the byte array. Ensure that len is not longer than str.
Upstream PySide2 reference signatures (binding differences may apply):
append(self, a: PySide2.QtCore.QByteArray) -> PySide2.QtCore.QByteArray
append(self, c: int) -> PySide2.QtCore.QByteArray
append(self, count: int, c: int) -> PySide2.QtCore.QByteArray
Source: https://doc.qt.io/archives/qt-5.15/qbytearray.html#append
at
at(i: int) -> int
X.at(i) -> int
Supplemental documentation: Qt 5 reference:
char QByteArray::at(int i) const
Returns the character at index position i in the byte array.
i must be a valid index position in the byte array (i.e., 0 \<\= i \< size()).
See also operator[]().
Upstream PySide2 reference signatures (binding differences may apply):
at(self, i: int) -> int
Source: https://doc.qt.io/archives/qt-5.15/qbytearray.html#at
capacity
capacity() -> int
X.capacity() -> int
Supplemental documentation: Qt 5 reference:
int QByteArray::capacity() const
Returns the maximum number of bytes that can be stored in the byte array without forcing a reallocation.
The sole purpose of this function is to provide a means of fine tuning QByteArray's memory usage. In general, you will rarely ever need to call this function. If you want to know how many bytes are in the byte array, call size().
See also reserve() and squeeze().
Upstream PySide2 reference signatures (binding differences may apply):
capacity(self) -> int
Source: https://doc.qt.io/archives/qt-5.15/qbytearray.html#capacity
cbegin
cbegin() -> str
X.cbegin() -> int
Supplemental documentation: Qt 5 reference:
QByteArray::const_iterator QByteArray::cbegin() const
Returns a const STL-style iterator pointing to the first character in the byte-array.
This function was introduced in Qt 5.0.
Upstream PySide2 reference signatures (binding differences may apply):
cbegin(self) -> str
Source: https://doc.qt.io/archives/qt-5.15/qbytearray.html#cbegin
cend
cend() -> str
X.cend() -> int
Supplemental documentation: Qt 5 reference:
QByteArray::const_iterator QByteArray::cend() const
Returns a const STL-style iterator pointing to the imaginary character after the last character in the list.
This function was introduced in Qt 5.0.
Upstream PySide2 reference signatures (binding differences may apply):
cend(self) -> str
Source: https://doc.qt.io/archives/qt-5.15/qbytearray.html#cend
chop
chop(n: int) -> None
X.chop(n)
Supplemental documentation: Qt 5 reference:
void QByteArray::chop(int n)
Removes n bytes from the end of the byte array.
If n is greater than size(), the result is an empty byte array.
Example:
QByteArray ba("STARTTLS\r\n");
ba.chop(2); // ba == "STARTTLS"
See also truncate(), resize(), and left().
Upstream PySide2 reference signatures (binding differences may apply):
chop(self, n: int) -> None
Source: https://doc.qt.io/archives/qt-5.15/qbytearray.html#chop
clear
clear() -> None
X.clear()
Supplemental documentation: Qt 5 reference:
void QByteArray::clear()
Clears the contents of the byte array and makes it null.
See also resize() and isNull().
Upstream PySide2 reference signatures (binding differences may apply):
clear(self) -> None
Source: https://doc.qt.io/archives/qt-5.15/qbytearray.html#clear
contains
contains(c: Any) -> bool
X.contains(c) -> bool
Supplemental documentation: Qt 5 reference:
bool QByteArray::contains(const QByteArray \&ba) const
Returns true if the byte array contains an occurrence of the byte array ba;
otherwise returns false.
See also indexOf() and count().
bool QByteArray::contains(char ch) const
This is an overloaded function.
Returns true if the byte array contains the character ch; otherwise returns false.
bool QByteArray::contains(const char *str) const
This is an overloaded function.
Returns true if the byte array contains the string str; otherwise returns false.
Upstream PySide2 reference signatures (binding differences may apply):
contains(self, a: PySide2.QtCore.QByteArray) -> bool
contains(self, c: int) -> bool
Source: https://doc.qt.io/archives/qt-5.15/qbytearray.html#contains
count
count(c: Any) -> int
X.count(c) -> int
Supplemental documentation: Qt 5 reference:
int QByteArray::count(const QByteArray \&ba) const
Returns the number of (potentially overlapping) occurrences of byte array ba in this byte array.
See also contains() and indexOf().
int QByteArray::count(char ch) const
This is an overloaded function.
Returns the number of occurrences of character ch in the byte array.
See also contains() and indexOf().
int QByteArray::count(const char *str) const
This is an overloaded function.
Returns the number of (potentially overlapping) occurrences of string str in the byte array.
int QByteArray::count() const
This is an overloaded function.
Same as size().
Upstream PySide2 reference signatures (binding differences may apply):
count(self) -> int
count(self, a: PySide2.QtCore.QByteArray) -> int
count(self, c: int) -> int
Source: https://doc.qt.io/archives/qt-5.15/qbytearray.html#count
data
data() -> str
X.data()
Supplemental documentation: Qt 5 reference:
char *QByteArray::data()
Returns a pointer to the data stored in the byte array. The pointer can be used to access and modify the bytes that compose the array. The data is '\0'-terminated, i.e. the number of bytes in the returned character string is size() + 1 for the '\0' terminator.
Example:
QByteArray ba("Hello world");
char *data = ba.data();
while (*data) {
cout << "[" << *data << "]" << Qt::endl;
++data;
}
The pointer remains valid as long as the byte array isn't reallocated or destroyed. For read-only access, constData() is faster because it never causes a deep copy to occur.
This function is mostly useful to pass a byte array to a function that accepts a const
char *.
The following example makes a copy of the char* returned by data(), but it will corrupt the heap and cause a crash because it does not allocate a byte for the '\0' at the end:
QString tmp = "test";
QByteArray text = tmp.toLocal8Bit();
char *data = new char[text.size()];
strcpy(data, text.data());
delete [] data;
This one allocates the correct amount of space:
QString tmp = "test";
QByteArray text = tmp.toLocal8Bit();
char *data = new char[text.size() + 1];
strcpy(data, text.data());
delete [] data;
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() and operator[]().
const char *QByteArray::data() const
This is an overloaded function.
Upstream PySide2 reference signatures (binding differences may apply):
data(self) -> str
Source: https://doc.qt.io/archives/qt-5.15/qbytearray.html#data
endsWith
endsWith(c: Any) -> bool
X.endsWith(c) -> bool
Supplemental documentation: Qt 5 reference:
bool QByteArray::endsWith(const QByteArray \&ba) const
Returns true if this byte array ends with byte array ba; otherwise returns false.
Example:
QByteArray url("http://qt-project.org/doc/qt-5.0/qtdoc/index.html");
if (url.endsWith(".html"))
...
See also startsWith() and right().
bool QByteArray::endsWith(char ch) const
This is an overloaded function.
Returns true if this byte array ends with character ch; otherwise returns false.
bool QByteArray::endsWith(const char *str) const
This is an overloaded function.
Returns true if this byte array ends with string str; otherwise returns false.
Upstream PySide2 reference signatures (binding differences may apply):
endsWith(self, a: PySide2.QtCore.QByteArray) -> bool
endsWith(self, c: int) -> bool
Source: https://doc.qt.io/archives/qt-5.15/qbytearray.html#endsWith
fill
fill(c: int, size: int) -> Any
X.fill(c, size) -> PythonQt.QtCore.QByteArray
Supplemental documentation: Qt 5 reference:
QByteArray \&QByteArray::fill(char ch, int size \= -1)
Sets every byte in the byte array to character ch. If size is different from -1 (the default), the byte array is resized to size size beforehand.
Example:
QByteArray ba("Istambul");
ba.fill('o');
// ba == "oooooooo"
ba.fill('X', 2);
// ba == "XX"
See also resize().
Upstream PySide2 reference signatures (binding differences may apply):
fill(self, c: int, size: int=...) -> PySide2.QtCore.QByteArray
Source: https://doc.qt.io/archives/qt-5.15/qbytearray.html#fill
fromBase64
fromBase64(base64: Any, options: Any) -> Any
X.fromBase64(base64, options) -> PythonQt.QtCore.QByteArray
Supplemental documentation: Qt 5 reference:
[static] QByteArray QByteArray::fromBase64(const QByteArray \&base64, QByteArray::Base64Options options)
This is an overloaded function.
Returns a decoded copy of the Base64 array base64, using the options defined by
options. If options contains IgnoreBase64DecodingErrors (the default), the input
is not checked for validity; invalid characters in the input are skipped, enabling the
decoding process to continue with subsequent characters. If options contains
AbortOnBase64DecodingErrors, then decoding will stop at the first invalid character.
For example:
QByteArray::fromBase64("PHA+SGVsbG8/PC9wPg==", QByteArray::Base64Encoding); // returns "<p>Hello?</p>"
QByteArray::fromBase64("PHA-SGVsbG8_PC9wPg==", QByteArray::Base64UrlEncoding); // returns "<p>Hello?</p>"
The algorithm used to decode Base64-encoded data is defined in RFC 4648.
Returns the decoded data, or, if the AbortOnBase64DecodingErrors option was passed and
the input data was invalid, an empty byte array.
Note: The fromBase64Encoding() function is recommended in new code.
This function was introduced in Qt 5.2.
See also toBase64() and fromBase64Encoding().
[static] QByteArray QByteArray::fromBase64(const QByteArray \&base64)
This is an overloaded function.
Returns a decoded copy of the Base64 array base64. Input is not checked for validity; invalid characters in the input are skipped, enabling the decoding process to continue with subsequent characters.
For example:
QByteArray text = QByteArray::fromBase64("UXQgaXMgZ3JlYXQh");
text.data(); // returns "Qt is great!"
The algorithm used to decode Base64-encoded data is defined in RFC 4648.
Note: The fromBase64Encoding() function is recommended in new code.
See also toBase64() and fromBase64Encoding().
Upstream PySide2 reference signatures (binding differences may apply):
fromBase64(base64: PySide2.QtCore.QByteArray) -> PySide2.QtCore.QByteArray
fromBase64(base64: PySide2.QtCore.QByteArray, options: PySide2.QtCore.QByteArray.Base64Options) -> PySide2.QtCore.QByteArray
Source: https://doc.qt.io/archives/qt-5.15/qbytearray.html#fromBase64
fromHex
fromHex(hexEncoded: Any) -> Any
X.fromHex(hexEncoded) -> PythonQt.QtCore.QByteArray
Supplemental documentation: Qt 5 reference:
[static] QByteArray QByteArray::fromHex(const QByteArray \&hexEncoded)
Returns a decoded copy of the hex encoded array hexEncoded. Input is not checked for validity; invalid characters in the input are skipped, enabling the decoding process to continue with subsequent characters.
For example:
QByteArray text = QByteArray::fromHex("517420697320677265617421");
text.data(); // returns "Qt is great!"
See also toHex().
Upstream PySide2 reference signatures (binding differences may apply):
fromHex(hexEncoded: PySide2.QtCore.QByteArray) -> PySide2.QtCore.QByteArray
Source: https://doc.qt.io/archives/qt-5.15/qbytearray.html#fromHex
fromPercentEncoding
fromPercentEncoding(pctEncoded: Any, percent: int) -> Any
X.fromPercentEncoding(pctEncoded, percent) -> PythonQt.QtCore.QByteArray
Supplemental documentation: Qt 5 reference:
[static] QByteArray QByteArray::fromPercentEncoding(const QByteArray \&input, char percent \= '%')
Returns a decoded copy of the URI/URL-style percent-encoded input. The percent parameter allows you to replace the '%' character for another (for instance, '_' or '\=').
For example:
QByteArray text = QByteArray::fromPercentEncoding("Qt%20is%20great%33");
text.data(); // returns "Qt is great!"
Note: Given invalid input (such as a string containing the sequence "%G5", which is not a valid hexadecimal number) the output will be invalid as well. As an example: the sequence "%G5" could be decoded to 'W'.
This function was introduced in Qt 4.4.
See also toPercentEncoding() and QUrl::fromPercentEncoding().
Upstream PySide2 reference signatures (binding differences may apply):
fromPercentEncoding(pctEncoded: PySide2.QtCore.QByteArray, percent: int=...) -> PySide2.QtCore.QByteArray
Source: https://doc.qt.io/archives/qt-5.15/qbytearray.html#fromPercentEncoding
indexOf
indexOf(*args: Any, **kwargs: Any) -> int
X.indexOf(c, from) -> int
Supplemental documentation: Qt 5 reference:
int QByteArray::indexOf(const QByteArray \&ba, int from \= 0) const
Returns the index position of the first occurrence of the byte array ba in this byte array, searching forward from index position from. Returns -1 if ba could not be found.
Example:
QByteArray x("sticky question");
QByteArray y("sti");
x.indexOf(y); // returns 0
x.indexOf(y, 1); // returns 10
x.indexOf(y, 10); // returns 10
x.indexOf(y, 11); // returns -1
See also lastIndexOf(), contains(), and count().
int QByteArray::indexOf(char ch, int from \= 0) const
This is an overloaded function.
Returns the index position of the first occurrence of the character ch in the byte array, searching forward from index position from. Returns -1 if ch could not be found.
Example:
QByteArray ba("ABCBA");
ba.indexOf("B"); // returns 1
ba.indexOf("B", 1); // returns 1
ba.indexOf("B", 2); // returns 3
ba.indexOf("X"); // returns -1
See also lastIndexOf() and contains().
int QByteArray::indexOf(const char *str, int from \= 0) const
This is an overloaded function.
Returns the index position of the first occurrence of the string str in the byte array, searching forward from index position from. Returns -1 if str could not be found.
Upstream PySide2 reference signatures (binding differences may apply):
indexOf(self, a: PySide2.QtCore.QByteArray, from_: int=...) -> int
Source: https://doc.qt.io/archives/qt-5.15/qbytearray.html#indexOf
insert
insert(i: int, s: Any, len: Any) -> Any
X.insert(i, s, len) -> PythonQt.QtCore.QByteArray
Supplemental documentation: Qt 5 reference:
QByteArray \&QByteArray::insert(int i, const QByteArray \&ba)
Inserts the byte array ba at index position i and returns a reference to this byte array.
Example:
QByteArray ba("Meal");
ba.insert(1, QByteArray("ontr"));
// ba == "Montreal"
See also append(), prepend(), replace(), and remove().
QByteArray \&QByteArray::insert(int i, char ch)
This is an overloaded function.
Inserts character ch at index position i in the byte array. If i is greater than size(), the array is first extended using resize().
QByteArray \&QByteArray::insert(int i, int count, char ch)
This is an overloaded function.
Inserts count copies of character ch at index position i in the byte array.
If i is greater than size(), the array is first extended using resize().
This function was introduced in Qt 5.7.
QByteArray \&QByteArray::insert(int i, const char *str)
This is an overloaded function.
Inserts the string str at position i in the byte array.
If i is greater than size(), the array is first extended using resize().
QByteArray \&QByteArray::insert(int i, const char *str, int len)
This is an overloaded function.
Inserts len bytes of the string str at position i in the byte array.
If i is greater than size(), the array is first extended using resize().
This function was introduced in Qt 4.6.
Upstream PySide2 reference signatures (binding differences may apply):
insert(self, i: int, a: PySide2.QtCore.QByteArray) -> PySide2.QtCore.QByteArray
insert(self, i: int, count: int, c: int) -> PySide2.QtCore.QByteArray
Source: https://doc.qt.io/archives/qt-5.15/qbytearray.html#insert
isEmpty
isEmpty() -> bool
X.isEmpty() -> bool
Supplemental documentation: Qt 5 reference:
bool QByteArray::isEmpty() const
Returns true if the byte array has size 0; otherwise returns false.
Example:
QByteArray().isEmpty(); // returns true
QByteArray("").isEmpty(); // returns true
QByteArray("abc").isEmpty(); // returns false
See also size().
Upstream PySide2 reference signatures (binding differences may apply):
isEmpty(self) -> bool
Source: https://doc.qt.io/archives/qt-5.15/qbytearray.html#isEmpty
isNull
isNull() -> bool
X.isNull() -> bool
Supplemental documentation: Qt 5 reference:
bool QByteArray::isNull() const
Returns true if this byte array is null; otherwise returns false.
Example:
QByteArray().isNull(); // returns true
QByteArray("").isNull(); // returns false
QByteArray("abc").isNull(); // returns false
Qt makes a distinction between null byte arrays and empty byte arrays for historical reasons. For most applications, what matters is whether or not a byte array contains any data, and this can be determined using isEmpty().
See also isEmpty().
Upstream PySide2 reference signatures (binding differences may apply):
isNull(self) -> bool
Source: https://doc.qt.io/archives/qt-5.15/qbytearray.html#isNull
isSharedWith
isSharedWith(other: Any) -> bool
X.isSharedWith(other) -> bool
Upstream PySide2 reference signatures (binding differences may apply):
isSharedWith(self, other: PySide2.QtCore.QByteArray) -> bool
Source: https://doc.qt.io/archives/qt-5.15/qbytearray.html#isSharedWith
lastIndexOf
lastIndexOf(*args: Any, **kwargs: Any) -> int
X.lastIndexOf(c, from) -> int
Supplemental documentation: Qt 5 reference:
int QByteArray::lastIndexOf(const QByteArray \&ba, int from \= -1) const
Returns the index position of the last occurrence of the byte array ba in this byte array, searching backward from index position from. If from is -1 (the default), the search starts at the last byte. Returns -1 if ba could not be found.
Example:
QByteArray x("crazy azimuths");
QByteArray y("az");
x.lastIndexOf(y); // returns 6
x.lastIndexOf(y, 6); // returns 6
x.lastIndexOf(y, 5); // returns 2
x.lastIndexOf(y, 1); // returns -1
See also indexOf(), contains(), and count().
int QByteArray::lastIndexOf(char ch, int from \= -1) const
This is an overloaded function.
Returns the index position of the last occurrence of character ch in the byte array, searching backward from index position from. If from is -1 (the default), the search starts at the last (size() - 1) byte. Returns -1 if ch could not be found.
Example:
QByteArray ba("ABCBA");
ba.lastIndexOf("B"); // returns 3
ba.lastIndexOf("B", 3); // returns 3
ba.lastIndexOf("B", 2); // returns 1
ba.lastIndexOf("X"); // returns -1
See also indexOf() and contains().
int QByteArray::lastIndexOf(const char *str, int from \= -1) const
This is an overloaded function.
Returns the index position of the last occurrence of the string str in the byte array, searching backward from index position from. If from is -1 (the default), the search starts at the last (size() - 1) byte. Returns -1 if str could not be found.
Upstream PySide2 reference signatures (binding differences may apply):
lastIndexOf(self, a: PySide2.QtCore.QByteArray, from_: int=...) -> int
Source: https://doc.qt.io/archives/qt-5.15/qbytearray.html#lastIndexOf
left
left(len: int) -> Any
X.left(len) -> PythonQt.QtCore.QByteArray
Supplemental documentation: Qt 5 reference:
QByteArray QByteArray::left(int len) const
Returns a byte array that contains the leftmost len bytes of this byte array.
The entire byte array is returned if len is greater than size().
Example:
QByteArray x("Pineapple");
QByteArray y = x.left(4);
// y == "Pine"
See also startsWith(), right(), mid(), chopped(), chop(), and truncate().
Upstream PySide2 reference signatures (binding differences may apply):
left(self, len: int) -> PySide2.QtCore.QByteArray
Source: https://doc.qt.io/archives/qt-5.15/qbytearray.html#left
leftJustified
leftJustified(width: int, fill: int, truncate: bool) -> Any
X.leftJustified(width, fill, truncate) -> PythonQt.QtCore.QByteArray
Supplemental documentation: Qt 5 reference:
QByteArray QByteArray::leftJustified(int width, char fill \= ' ', bool truncate \= false) const
Returns a byte array of size width that contains this byte array padded by the fill character.
If truncate is false and the size() of the byte array is more than width, then the returned byte array is a copy of this byte array.
If truncate is true and the size() of the byte array is more than width, then any bytes in a copy of the byte array after position width are removed, and the copy is returned.
Example:
QByteArray x("apple");
QByteArray y = x.leftJustified(8, '.'); // y == "apple..."
See also rightJustified().
Upstream PySide2 reference signatures (binding differences may apply):
leftJustified(self, width: int, fill: int=..., truncate: bool=...) -> PySide2.QtCore.QByteArray
Source: https://doc.qt.io/archives/qt-5.15/qbytearray.html#leftJustified
length
length() -> int
X.length() -> int
Supplemental documentation: Qt 5 reference:
int QByteArray::length() const
Same as size().
Upstream PySide2 reference signatures (binding differences may apply):
length(self) -> int
Source: https://doc.qt.io/archives/qt-5.15/qbytearray.html#length
mid
mid(index: int, len: int) -> Any
X.mid(index, len) -> PythonQt.QtCore.QByteArray
Supplemental documentation: Qt 5 reference:
QByteArray QByteArray::mid(int pos, int len \= -1) const
Returns a byte array containing len bytes from this byte array, starting at position pos.
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 left(), right(), chopped(), chop(), and truncate().
Upstream PySide2 reference signatures (binding differences may apply):
mid(self, index: int, len: int=...) -> PySide2.QtCore.QByteArray
Source: https://doc.qt.io/archives/qt-5.15/qbytearray.html#mid
number
number(arg__1: Any, f: Any, prec: Any) -> Any
X.number(arg__1, f, prec) -> PythonQt.QtCore.QByteArray
Supplemental documentation: Qt 5 reference:
[static] QByteArray QByteArray::number(int n, int base \= 10)
Returns a byte array containing the string equivalent of the number n to base base (10 by default). The base can be any value between 2 and 36.
Example:
int n = 63;
QByteArray::number(n); // returns "63"
QByteArray::number(n, 16); // returns "3f"
QByteArray::number(n, 16).toUpper(); // returns "3F"
Note: The format of the number is not localized; the default C locale is used irrespective of the user's locale.
See also setNum() and toInt().
[static] QByteArray QByteArray::number(uint n, int base \= 10)
This is an overloaded function.
See also toUInt().
[static] QByteArray QByteArray::number(qlonglong n, int base \= 10)
This is an overloaded function.
See also toLongLong().
[static] QByteArray QByteArray::number(qulonglong n, int base \= 10)
This is an overloaded function.
See also toULongLong().
[static] QByteArray QByteArray::number(double n, char f \= 'g', int prec \= 6)
This is an overloaded function.
Returns a byte array that contains the printed value of n, formatted in format f with precision prec.
Argument n is formatted according to the f format specified, which is g by
default, and can be any of the following:
| Format | Meaning |
|---|---|
e |
format as [-]9.9e[+|-]999 |
E |
format as [-]9.9E[+|-]999 |
f |
format as [-]9.9 |
g |
use e or f format, whichever is the most concise |
G |
use E or f format, whichever is the most concise |
With 'e', 'E', and 'f', prec is the number of digits after the decimal point. With 'g' and 'G', prec is the maximum number of significant digits (trailing zeroes are omitted).
QByteArray ba = QByteArray::number(12.3456, 'E', 3);
// ba == 1.235E+01
Note: The format of the number is not localized; the default C locale is used irrespective of the user's locale.
See also toDouble().
Upstream PySide2 reference signatures (binding differences may apply):
number(arg__1: float, f: int=..., prec: int=...) -> PySide2.QtCore.QByteArray
number(arg__1: int, base: int=...) -> PySide2.QtCore.QByteArray
number(arg__1: int, base: int=...) -> PySide2.QtCore.QByteArray
Source: https://doc.qt.io/archives/qt-5.15/qbytearray.html#number
operator_assign
operator_assign(arg__1: Any) -> Any
X.operator_assign(arg__1) -> PythonQt.QtCore.QByteArray
prepend
prepend(s: Any, len: Any) -> Any
X.prepend(s, len) -> PythonQt.QtCore.QByteArray
Supplemental documentation: Qt 5 reference:
QByteArray \&QByteArray::prepend(const QByteArray \&ba)
Prepends the byte array ba to this byte array and returns a reference to this byte array.
Example:
QByteArray x("ship");
QByteArray y("air");
x.prepend(y);
// x == "airship"
This is the same as insert(0, ba).
Note: QByteArray is an implicitly shared class. Consequently, if you prepend to an empty byte array, then the byte array will just share the data held in ba. In this case, no copying of data is done, taking constant time. If a shared instance is modified, it will be copied (copy-on-write), taking linear time.
If the byte array being prepended to is not empty, a deep copy of the data is performed, taking linear time.
See also append() and insert().
QByteArray \&QByteArray::prepend(char ch)
This is an overloaded function.
Prepends the character ch to this byte array.
QByteArray \&QByteArray::prepend(int count, char ch)
This is an overloaded function.
Prepends count copies of character ch to this byte array.
This function was introduced in Qt 5.7.
QByteArray \&QByteArray::prepend(const char *str)
This is an overloaded function.
Prepends the string str to this byte array.
QByteArray \&QByteArray::prepend(const char *str, int len)
This is an overloaded function.
Prepends len bytes of the string str to this byte array.
This function was introduced in Qt 4.6.
Upstream PySide2 reference signatures (binding differences may apply):
prepend(self, a: PySide2.QtCore.QByteArray) -> PySide2.QtCore.QByteArray
prepend(self, c: int) -> PySide2.QtCore.QByteArray
prepend(self, count: int, c: int) -> PySide2.QtCore.QByteArray
Source: https://doc.qt.io/archives/qt-5.15/qbytearray.html#prepend
push_back
push_back(a: Any) -> Any
X.push_back(a)
Supplemental documentation: Qt 5 reference:
void QByteArray::push_back(const QByteArray \&other)
This function is provided for STL compatibility. It is equivalent to append(other).
void QByteArray::push_back(char ch)
This is an overloaded function.
Same as append(ch).
void QByteArray::push_back(const char *str)
This is an overloaded function.
Same as append(str).
Source: https://doc.qt.io/archives/qt-5.15/qbytearray.html#push_back
push_front
push_front(a: Any) -> Any
X.push_front(a)
Supplemental documentation: Qt 5 reference:
void QByteArray::push_front(const QByteArray \&other)
This function is provided for STL compatibility. It is equivalent to prepend(other).
void QByteArray::push_front(char ch)
This is an overloaded function.
Same as prepend(ch).
void QByteArray::push_front(const char *str)
This is an overloaded function.
Same as prepend(str).
Source: https://doc.qt.io/archives/qt-5.15/qbytearray.html#push_front
remove
remove(index: int, len: int) -> Any
X.remove(index, len) -> PythonQt.QtCore.QByteArray
Supplemental documentation: Qt 5 reference:
QByteArray \&QByteArray::remove(int pos, int len)
Removes len bytes from the array, starting at index position pos, and returns a reference to the array.
If pos is out of range, nothing happens. If pos is valid, but pos + len is larger than the size of the array, the array is truncated at position pos.
Example:
QByteArray ba("Montreal");
ba.remove(1, 4);
// ba == "Meal"
See also insert() and replace().
Upstream PySide2 reference signatures (binding differences may apply):
remove(self, index: int, len: int) -> PySide2.QtCore.QByteArray
Source: https://doc.qt.io/archives/qt-5.15/qbytearray.html#remove
repeated
repeated(times: int) -> Any
X.repeated(times) -> PythonQt.QtCore.QByteArray
Supplemental documentation: Qt 5 reference:
QByteArray QByteArray::repeated(int times) const
Returns a copy of this byte array repeated the specified number of times.
If times is less than 1, an empty byte array is returned.
Example:
QByteArray ba("ab");
ba.repeated(4); // returns "abababab"
This function was introduced in Qt 4.5.
Upstream PySide2 reference signatures (binding differences may apply):
repeated(self, times: int) -> PySide2.QtCore.QByteArray
Source: https://doc.qt.io/archives/qt-5.15/qbytearray.html#repeated
replace
replace(before: Any, bsize: Any, after: Any, asize: Any) -> Any
X.replace(before, bsize, after, asize) -> PythonQt.QtCore.QByteArray
Supplemental documentation: Qt 5 reference:
QByteArray \&QByteArray::replace(int pos, int len, const QByteArray \&after)
Replaces len bytes from index position pos with the byte array after, and returns a reference to this byte array.
Example:
QByteArray x("Say yes!");
QByteArray y("no");
x.replace(4, 3, y);
// x == "Say no!"
See also insert() and remove().
QByteArray \&QByteArray::replace(int pos, int len, const char *after)
This is an overloaded function.
Replaces len bytes from index position pos with the '\0'-terminated string after.
Notice: this can change the length of the byte array.
QByteArray \&QByteArray::replace(int pos, int len, const char *after, int alen)
This is an overloaded function.
Replaces len bytes from index position pos with alen bytes from the string after. after is allowed to have '\0' characters.
This function was introduced in Qt 4.7.
QByteArray \&QByteArray::replace(char before, const char *after)
This is an overloaded function.
Replaces every occurrence of the character before with the string after.
QByteArray \&QByteArray::replace(char before, const QByteArray \&after)
This is an overloaded function.
Replaces every occurrence of the character before with the byte array after.
QByteArray \&QByteArray::replace(const char *before, const char *after)
This is an overloaded function.
Replaces every occurrence of the string before with the string after.
QByteArray \&QByteArray::replace(const char *before, int bsize, const char *after, int asize)
This is an overloaded function.
Replaces every occurrence of the string before with the string after. Since the sizes of the strings are given by bsize and asize, they may contain zero characters and do not need to be '\0'-terminated.
QByteArray \&QByteArray::replace(const QByteArray \&before, const QByteArray \&after)
This is an overloaded function.
Replaces every occurrence of the byte array before with the byte array after.
Example:
QByteArray ba("colour behaviour flavour neighbour");
ba.replace(QByteArray("ou"), QByteArray("o"));
// ba == "color behavior flavor neighbor"
QByteArray \&QByteArray::replace(const QByteArray \&before, const char *after)
This is an overloaded function.
Replaces every occurrence of the byte array before with the string after.
QByteArray \&QByteArray::replace(const char *before, const QByteArray \&after)
This is an overloaded function.
Replaces every occurrence of the string before with the byte array after.
QByteArray \&QByteArray::replace(char before, char after)
This is an overloaded function.
Replaces every occurrence of the character before with the character after.
Upstream PySide2 reference signatures (binding differences may apply):
replace(self, before: PySide2.QtCore.QByteArray, after: PySide2.QtCore.QByteArray) -> PySide2.QtCore.QByteArray
replace(self, before: str, after: PySide2.QtCore.QByteArray) -> PySide2.QtCore.QByteArray
replace(self, before: int, after: PySide2.QtCore.QByteArray) -> PySide2.QtCore.QByteArray
replace(self, before: int, after: int) -> PySide2.QtCore.QByteArray
replace(self, index: int, len: int, s: PySide2.QtCore.QByteArray) -> PySide2.QtCore.QByteArray
Source: https://doc.qt.io/archives/qt-5.15/qbytearray.html#replace
reserve
reserve(size: int) -> None
X.reserve(size)
Supplemental documentation: Qt 5 reference:
void QByteArray::reserve(int size)
Attempts to allocate memory for at least size bytes. If you know in advance how large the byte array will be, you can call this function, and if you call resize() often you are likely to get better performance. If size is an underestimate, the worst that will happen is that the QByteArray will be a bit slower.
The sole purpose of this function is to provide a means of fine tuning QByteArray's memory usage. In general, you will rarely ever need to call this function. If you want to change the size of the byte array, call resize().
See also squeeze() and capacity().
Upstream PySide2 reference signatures (binding differences may apply):
reserve(self, size: int) -> None
Source: https://doc.qt.io/archives/qt-5.15/qbytearray.html#reserve