PythonQt.QtCore.QByteArray · declarations 002
Back to PythonQt.QtCore.QByteArray
resize
resize(size: int) -> None
X.resize(size)
Supplemental documentation: Qt 5 reference:
void QByteArray::resize(int size)
Sets the size of the byte array to size bytes.
If size is greater than the current size, the byte array is extended to make it size bytes with the extra bytes added to the end. The new bytes are uninitialized.
If size is less than the current size, bytes are removed from the end.
See also size() and truncate().
Upstream PySide2 reference signatures (binding differences may apply):
resize(self, size: int) -> None
Source: https://doc.qt.io/archives/qt-5.15/qbytearray.html#resize
right
right(len: int) -> Any
X.right(len) -> PythonQt.QtCore.QByteArray
Supplemental documentation: Qt 5 reference:
QByteArray QByteArray::right(int len) const
Returns a byte array that contains the rightmost 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.right(5);
// y == "apple"
See also endsWith(), left(), mid(), chopped(), chop(), and truncate().
Upstream PySide2 reference signatures (binding differences may apply):
right(self, len: int) -> PySide2.QtCore.QByteArray
Source: https://doc.qt.io/archives/qt-5.15/qbytearray.html#right
rightJustified
rightJustified(width: int, fill: int, truncate: bool) -> Any
X.rightJustified(width, fill, truncate) -> PythonQt.QtCore.QByteArray
Supplemental documentation: Qt 5 reference:
QByteArray QByteArray::rightJustified(int width, char fill \= ' ', bool truncate \= false) const
Returns a byte array of size width that contains the fill character followed by this byte array.
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 the resulting byte array is truncated at position width.
Example:
QByteArray x("apple");
QByteArray y = x.rightJustified(8, '.'); // y == "...apple"
See also leftJustified().
Upstream PySide2 reference signatures (binding differences may apply):
rightJustified(self, width: int, fill: int=..., truncate: bool=...) -> PySide2.QtCore.QByteArray
Source: https://doc.qt.io/archives/qt-5.15/qbytearray.html#rightJustified
setNum
setNum(arg__1: Any, f: Any, prec: Any) -> Any
X.setNum(arg__1, f, prec) -> PythonQt.QtCore.QByteArray
Supplemental documentation: Qt 5 reference:
QByteArray \&QByteArray::setNum(int n, int base \= 10)
Sets the byte array to the printed value of n in base base (10 by default) and returns a reference to the byte array. The base can be any value between 2 and 36. For bases other than 10, n is treated as an unsigned integer.
Example:
QByteArray ba;
int n = 63;
ba.setNum(n); // ba == "63"
ba.setNum(n, 16); // ba == "3f"
Note: The format of the number is not localized; the default C locale is used irrespective of the user's locale.
See also number() and toInt().
QByteArray \&QByteArray::setNum(short n, int base \= 10)
This is an overloaded function.
See also toShort().
QByteArray \&QByteArray::setNum(ushort n, int base \= 10)
This is an overloaded function.
See also toUShort().
QByteArray \&QByteArray::setNum(uint n, int base \= 10)
This is an overloaded function.
See also toUInt().
QByteArray \&QByteArray::setNum(qlonglong n, int base \= 10)
This is an overloaded function.
See also toLongLong().
QByteArray \&QByteArray::setNum(qulonglong n, int base \= 10)
This is an overloaded function.
See also toULongLong().
QByteArray \&QByteArray::setNum(float n, char f \= 'g', int prec \= 6)
This is an overloaded function.
Sets the byte array to the printed value of n, formatted in format f with precision prec, and returns a reference to the byte array.
Note: The format of the number is not localized; the default C locale is used irrespective of the user's locale.
See also toFloat().
QByteArray \&QByteArray::setNum(double n, char f \= 'g', int prec \= 6)
This is an overloaded function.
Sets the byte array to the printed value of n, formatted in format f with precision prec, and returns a reference to the byte array.
The format f 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).
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):
setNum(self, arg__1: float, f: int=..., prec: int=...) -> PySide2.QtCore.QByteArray
setNum(self, arg__1: int, base: int=...) -> PySide2.QtCore.QByteArray
setNum(self, arg__1: int, base: int=...) -> PySide2.QtCore.QByteArray
Source: https://doc.qt.io/archives/qt-5.15/qbytearray.html#setNum
setRawData
setRawData(a: str, n: int) -> Any
X.setRawData(a, n) -> PythonQt.QtCore.QByteArray
Supplemental documentation: Qt 5 reference:
QByteArray \&QByteArray::setRawData(const char *data, uint size)
Resets the QByteArray to use the first size bytes of the data array. The bytes are not copied. The QByteArray will contain the data pointer. The caller guarantees that data will not be deleted or modified as long as this QByteArray and any copies of it exist that have not been modified.
This function can be used instead of fromRawData() to re-use existing QByteArray objects to save memory re-allocations.
This function was introduced in Qt 4.7.
See also fromRawData(), data(), and constData().
Upstream PySide2 reference signatures (binding differences may apply):
setRawData(self, a: str, n: int) -> PySide2.QtCore.QByteArray
Source: https://doc.qt.io/archives/qt-5.15/qbytearray.html#setRawData
simplified
simplified() -> Any
X.simplified() -> PythonQt.QtCore.QByteArray
Supplemental documentation: Qt 5 reference:
QByteArray QByteArray::simplified() const
Returns a byte array that has whitespace removed from the start and the end, and which has each sequence of internal whitespace replaced with a single space.
Whitespace means any character for which the standard C++ isspace() function returns
true in the C locale. This includes the ASCII isspace() function returns true in the
C locale. This includes the ASCII characters '\t', '\n', '\v', '\f', '\r', and ' '.
Example:
QByteArray ba(" lots\t of\nwhitespace\r\n ");
ba = ba.simplified();
// ba == "lots of whitespace";
See also trimmed().
Upstream PySide2 reference signatures (binding differences may apply):
simplified(self) -> PySide2.QtCore.QByteArray
Source: https://doc.qt.io/archives/qt-5.15/qbytearray.html#simplified
size
size() -> int
X.size() -> int
Supplemental documentation: Qt 5 reference:
int QByteArray::size() const
Returns the number of bytes in this byte array.
The last byte in the byte array is at position size() - 1. In addition, QByteArray ensures that the byte at position size() is always '\0', so that you can use the return value of data() and constData() as arguments to functions that expect '\0'-terminated strings. If the QByteArray object was created from a raw data that didn't include the trailing null-termination character then QByteArray doesn't add it automatically unless the deep copy is created.
Example:
QByteArray ba("Hello");
int n = ba.size(); // n == 5
ba.data()[0]; // returns 'H'
ba.data()[4]; // returns 'o'
ba.data()[5]; // returns '\0'
See also isEmpty() and resize().
Upstream PySide2 reference signatures (binding differences may apply):
size(self) -> int
Source: https://doc.qt.io/archives/qt-5.15/qbytearray.html#size
split
split(sep: int) -> Any
X.split(sep)
Supplemental documentation: Qt 5 reference:
QList\<QByteArray> QByteArray::split(char sep) const
Splits the byte array into subarrays wherever sep occurs, and returns the list of those arrays. If sep does not match anywhere in the byte array, split() returns a single-element list containing this byte array.
Upstream PySide2 reference signatures (binding differences may apply):
split(self, sep: int) -> typing.List[PySide2.QtCore.QByteArray]
Source: https://doc.qt.io/archives/qt-5.15/qbytearray.html#split
squeeze
squeeze() -> None
X.squeeze()
Supplemental documentation: Qt 5 reference:
void QByteArray::squeeze()
Releases any memory not required to store the array's data.
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.
See also reserve() and capacity().
Upstream PySide2 reference signatures (binding differences may apply):
squeeze(self) -> None
Source: https://doc.qt.io/archives/qt-5.15/qbytearray.html#squeeze
startsWith
startsWith(c: Any) -> bool
X.startsWith(c) -> bool
Supplemental documentation: Qt 5 reference:
bool QByteArray::startsWith(const QByteArray \&ba) const
Returns true if this byte array starts with byte array ba; otherwise returns
false.
Example:
QByteArray url("ftp://ftp.qt-project.org/");
if (url.startsWith("ftp:"))
...
See also endsWith() and left().
bool QByteArray::startsWith(char ch) const
This is an overloaded function.
Returns true if this byte array starts with character ch; otherwise returns false.
bool QByteArray::startsWith(const char *str) const
This is an overloaded function.
Returns true if this byte array starts with string str; otherwise returns false.
Upstream PySide2 reference signatures (binding differences may apply):
startsWith(self, a: PySide2.QtCore.QByteArray) -> bool
startsWith(self, c: int) -> bool
Source: https://doc.qt.io/archives/qt-5.15/qbytearray.html#startsWith
swap
swap(other: Any) -> None
X.swap(other)
Supplemental documentation: Qt 5 reference:
void QByteArray::swap(QByteArray \&other)
Swaps byte array other with this byte array. This operation is very fast and never fails.
This function was introduced in Qt 4.8.
Upstream PySide2 reference signatures (binding differences may apply):
swap(self, other: PySide2.QtCore.QByteArray) -> None
Source: https://doc.qt.io/archives/qt-5.15/qbytearray.html#swap
toBase64
toBase64(options: Any) -> Any
X.toBase64(options) -> PythonQt.QtCore.QByteArray
Supplemental documentation: Qt 5 reference:
QByteArray QByteArray::toBase64() const
Returns a copy of the byte array, encoded as Base64.
QByteArray text("Qt is great!");
text.toBase64(); // returns "UXQgaXMgZ3JlYXQh"
The algorithm used to encode Base64-encoded data is defined in RFC 4648.
See also fromBase64().
QByteArray QByteArray::toBase64(QByteArray::Base64Options options) const
This is an overloaded function.
Returns a copy of the byte array, encoded using the options options.
QByteArray text("<p>Hello?</p>");
text.toBase64(QByteArray::Base64Encoding | QByteArray::OmitTrailingEquals); // returns "PHA+SGVsbG8/PC9wPg"
text.toBase64(QByteArray::Base64Encoding); // returns "PHA+SGVsbG8/PC9wPg=="
text.toBase64(QByteArray::Base64UrlEncoding); // returns "PHA-SGVsbG8_PC9wPg=="
text.toBase64(QByteArray::Base64UrlEncoding | QByteArray::OmitTrailingEquals); // returns "PHA-SGVsbG8_PC9wPg"
The algorithm used to encode Base64-encoded data is defined in RFC 4648.
This function was introduced in Qt 5.2.
See also fromBase64().
Upstream PySide2 reference signatures (binding differences may apply):
toBase64(self) -> PySide2.QtCore.QByteArray
toBase64(self, options: PySide2.QtCore.QByteArray.Base64Options) -> PySide2.QtCore.QByteArray
Source: https://doc.qt.io/archives/qt-5.15/qbytearray.html#toBase64
toDouble
toDouble(ok: Any) -> float
X.toDouble(ok) -> float
Supplemental documentation: Qt 5 reference:
double QByteArray::toDouble(bool *ok \= nullptr) const
Returns the byte array converted to a double value.
Returns an infinity if the conversion overflows or 0.0 if the conversion fails for other reasons (e.g. underflow).
If ok is not nullptr, failure is reported by setting *ok to false, and success
by setting *ok to true.
QByteArray string("1234.56");
bool ok;
double a = string.toDouble(&ok); // a == 1234.56, ok == true
string = "1234.56 Volt";
a = str.toDouble(&ok); // a == 0, ok == false
Warning: The QByteArray content may only contain valid numerical characters which includes the plus/minus sign, the character e used in scientific notation, and the decimal point. Including the unit or additional characters leads to a conversion error.
Note: The conversion of the number is performed in the default C locale, irrespective of the user's locale.
This function ignores leading and trailing whitespace.
See also number().
Upstream PySide2 reference signatures (binding differences may apply):
toDouble(self) -> typing.Tuple[float, bool]
Source: https://doc.qt.io/archives/qt-5.15/qbytearray.html#toDouble
toFloat
toFloat(ok: Any) -> float
X.toFloat(ok) -> float
Supplemental documentation: Qt 5 reference:
float QByteArray::toFloat(bool *ok \= nullptr) const
Returns the byte array converted to a float value.
Returns an infinity if the conversion overflows or 0.0 if the conversion fails for other reasons (e.g. underflow).
If ok is not nullptr, failure is reported by setting *ok to false, and success
by setting *ok to true.
QByteArray string("1234.56");
bool ok;
float a = string.toFloat(&ok); // a == 1234.56, ok == true
string = "1234.56 Volt";
a = str.toFloat(&ok); // a == 0, ok == false
Warning: The QByteArray content may only contain valid numerical characters which includes the plus/minus sign, the character e used in scientific notation, and the decimal point. Including the unit or additional characters leads to a conversion error.
Note: The conversion of the number is performed in the default C locale, irrespective of the user's locale.
This function ignores leading and trailing whitespace.
See also number().
Upstream PySide2 reference signatures (binding differences may apply):
toFloat(self) -> typing.Tuple[float, bool]
Source: https://doc.qt.io/archives/qt-5.15/qbytearray.html#toFloat
toHex
toHex() -> Any
X.toHex() -> PythonQt.QtCore.QByteArray
Supplemental documentation: Qt 5 reference:
QByteArray QByteArray::toHex() const
Returns a hex encoded copy of the byte array. The hex encoding uses the numbers 0-9 and the letters a-f.
See also fromHex().
QByteArray QByteArray::toHex(char separator) const
This is an overloaded function.
Returns a hex encoded copy of the byte array. The hex encoding uses the numbers 0-9 and the letters a-f.
If separator is not '\0', the separator character is inserted between the hex bytes.
Example:
QByteArray macAddress = QByteArray::fromHex("123456abcdef");
macAddress.toHex(':'); // returns "12:34:56:ab:cd:ef"
macAddress.toHex(0); // returns "123456abcdef"
This function was introduced in Qt 5.9.
See also fromHex().
Upstream PySide2 reference signatures (binding differences may apply):
toHex(self) -> PySide2.QtCore.QByteArray
toHex(self, separator: int) -> PySide2.QtCore.QByteArray
Source: https://doc.qt.io/archives/qt-5.15/qbytearray.html#toHex
toInt
toInt(ok: Any, base: int) -> int
X.toInt(ok, base) -> int
Supplemental documentation: Qt 5 reference:
int QByteArray::toInt(bool *ok \= nullptr, int base \= 10) const
Returns the byte array converted to an int using base base, which is 10 by default
and must be between 2 and 36, or 0.
If base is 0, the base is determined automatically using the following rules: If the byte array begins with "0x", it is assumed to be hexadecimal; if it begins with "0", it is assumed to be octal; otherwise it is assumed to be decimal.
Returns 0 if the conversion fails.
If ok is not nullptr, failure is reported by setting *ok to false, and success
by setting *ok to true.
QByteArray str("FF");
bool ok;
int hex = str.toInt(&ok, 16); // hex == 255, ok == true
int dec = str.toInt(&ok, 10); // dec == 0, ok == false
Note: The conversion of the number is performed in the default C locale, irrespective of the user's locale.
See also number().
Upstream PySide2 reference signatures (binding differences may apply):
toInt(self, base: int=...) -> typing.Tuple[int, bool]
Source: https://doc.qt.io/archives/qt-5.15/qbytearray.html#toInt
toLower
toLower() -> Any
X.toLower() -> PythonQt.QtCore.QByteArray
Supplemental documentation: Qt 5 reference:
QByteArray QByteArray::toLower() const
Returns a lowercase copy of the byte array. The bytearray is interpreted as a Latin-1 encoded string.
Example:
QByteArray x("Qt by THE QT COMPANY");
QByteArray y = x.toLower();
// y == "qt by the qt company"
See also isLower(), toUpper(), and 8-bit Character Comparisons.
Upstream PySide2 reference signatures (binding differences may apply):
toLower(self) -> PySide2.QtCore.QByteArray
Source: https://doc.qt.io/archives/qt-5.15/qbytearray.html#toLower
toPercentEncoding
toPercentEncoding(exclude: Any, include: Any, percent: int) -> Any
X.toPercentEncoding(exclude, include, percent) -> PythonQt.QtCore.QByteArray
Supplemental documentation: Qt 5 reference:
QByteArray QByteArray::toPercentEncoding(const QByteArray \&exclude \= QByteArray(), const QByteArray \&include \= QByteArray(), char percent \= '%') const
Returns a URI/URL-style percent-encoded copy of this byte array. The percent parameter allows you to override the default '%' character for another.
By default, this function will encode all characters that are not one of the following:
ALPHA ("a" to "z" and "A" to "Z") / DIGIT (0 to 9) / "-" / "." / "_" / "\~"
To prevent characters from being encoded pass them to exclude. To force characters to be encoded pass them to include. The percent character is always encoded.
Example:
QByteArray text = "{a fishy string?}";
QByteArray ba = text.toPercentEncoding("{}", "s");
qDebug(ba.constData());
// prints "{a fi%73hy %73tring%3F}"
The hex encoding uses the numbers 0-9 and the uppercase letters A-F.
This function was introduced in Qt 4.4.
See also fromPercentEncoding() and QUrl::toPercentEncoding().
Upstream PySide2 reference signatures (binding differences may apply):
toPercentEncoding(self, exclude: PySide2.QtCore.QByteArray=..., include: PySide2.QtCore.QByteArray=..., percent: int=...) -> PySide2.QtCore.QByteArray
Source: https://doc.qt.io/archives/qt-5.15/qbytearray.html#toPercentEncoding
toUShort
toUShort(ok: Any, base: int) -> int
X.toUShort(ok, base) -> int
Supplemental documentation: Qt 5 reference:
ushort QByteArray::toUShort(bool *ok \= nullptr, int base \= 10) const
Returns the byte array converted to an unsigned short using base base, which is 10
by default and must be between 2 and 36, or 0.
If base is 0, the base is determined automatically using the following rules: If the byte array begins with "0x", it is assumed to be hexadecimal; if it begins with "0", it is assumed to be octal; otherwise it is assumed to be decimal.
Returns 0 if the conversion fails.
If ok is not nullptr, failure is reported by setting *ok to false, and success
by setting *ok to true.
Note: The conversion of the number is performed in the default C locale, irrespective of the user's locale.
See also number().
Upstream PySide2 reference signatures (binding differences may apply):
toUShort(self, base: int=...) -> typing.Tuple[int, bool]
Source: https://doc.qt.io/archives/qt-5.15/qbytearray.html#toUShort
toUpper
toUpper() -> Any
X.toUpper() -> PythonQt.QtCore.QByteArray
Supplemental documentation: Qt 5 reference:
QByteArray QByteArray::toUpper() const
Returns an uppercase copy of the byte array. The bytearray is interpreted as a Latin-1 encoded string.
Example:
QByteArray x("Qt by THE QT COMPANY");
QByteArray y = x.toUpper();
// y == "QT BY THE QT COMPANY"
See also isUpper(), toLower(), and 8-bit Character Comparisons.
Upstream PySide2 reference signatures (binding differences may apply):
toUpper(self) -> PySide2.QtCore.QByteArray
Source: https://doc.qt.io/archives/qt-5.15/qbytearray.html#toUpper
trimmed
trimmed() -> Any
X.trimmed() -> PythonQt.QtCore.QByteArray
Supplemental documentation: Qt 5 reference:
QByteArray QByteArray::trimmed() const
Returns a byte array that has whitespace removed from the start and the end.
Whitespace means any character for which the standard C++ isspace() function returns
true in the C locale. This includes the ASCII characters '\t', '\n', '\v', '\f',
'\r', and ' '.
Example:
QByteArray ba(" lots\t of\nwhitespace\r\n ");
ba = ba.trimmed();
// ba == "lots\t of\nwhitespace";
Unlike simplified(), trimmed() leaves internal whitespace alone.
See also simplified().
Upstream PySide2 reference signatures (binding differences may apply):
trimmed(self) -> PySide2.QtCore.QByteArray
Source: https://doc.qt.io/archives/qt-5.15/qbytearray.html#trimmed
truncate
truncate(pos: int) -> None
X.truncate(pos)
Supplemental documentation: Qt 5 reference:
void QByteArray::truncate(int pos)
Truncates the byte array at index position pos.
If pos is beyond the end of the array, nothing happens.
Example:
QByteArray ba("Stockholm");
ba.truncate(5); // ba == "Stock"
See also chop(), resize(), and left().
Upstream PySide2 reference signatures (binding differences may apply):
truncate(self, pos: int) -> None
Source: https://doc.qt.io/archives/qt-5.15/qbytearray.html#truncate