DataStream
Base classes
| Name |
Children |
Inherits |
QDataStream PySide6.QtCore QDataStream(self, /) -> None |
|
|
â‹” Inheritance diagram
graph TD
2370742038["core.DataStream"]
136215403["QtCore.QDataStream"]
2183098470["QtCore.QIODeviceBase"]
37984305["Shiboken.Object"]
2751680898["builtins.object"]
136215403 --> 2370742038
2183098470 --> 136215403
37984305 --> 2183098470
2751680898 --> 37984305
🛈 DocStrings
Bases: QDataStream
Serialization of binary data to a QIODevice.
Source code in prettyqt/core/datastream.py
| class DataStream(QtCore.QDataStream):
"""Serialization of binary data to a QIODevice."""
def set_byte_order(self, order: ByteOrderStr | QtCore.QDataStream.ByteOrder):
"""Set byte order.
Args:
order: byte order to use
"""
self.setByteOrder(BYTE_ORDER.get_enum_value(order))
def get_byte_order(self) -> ByteOrderStr:
"""Return byte order.
Returns:
byte order
"""
return BYTE_ORDER.inverse[self.byteOrder()]
def set_status(self, status: StatusStr):
"""Set status.
Args:
status: status to use
"""
self.setStatus(STATUS.get_enum_value(status))
def get_status(self) -> StatusStr:
"""Return status.
Returns:
status
"""
return STATUS.inverse[self.status()]
def set_floating_point_precision(
self,
precision: FloatingPointPrecisionStr | QtCore.QDataStream.FloatingPointPrecision,
):
"""Set floating point precision.
Args:
precision: floating point precision
"""
self.setFloatingPointPrecision(FLOATING_POINT_PRECISION.get_enum_value(precision))
def get_floating_point_precision(self) -> FloatingPointPrecisionStr:
"""Return floating point precision.
Returns:
floating point precision
"""
return FLOATING_POINT_PRECISION.inverse[self.floatingPointPrecision()]
@classmethod
def create_bytearray(cls, data: datatypes.QtSerializableType) -> QtCore.QByteArray:
ba = QtCore.QByteArray()
stream = cls(ba, QtCore.QIODeviceBase.OpenModeFlag.WriteOnly)
stream << data
return ba
@classmethod
def write_bytearray(
cls, ba: datatypes.ByteArrayType, write_to: datatypes.QtSerializableType
):
ba = datatypes.to_bytearray(ba)
stream = cls(ba, QtCore.QIODeviceBase.OpenModeFlag.ReadOnly)
stream >> write_to
@classmethod
def copy_data(
cls, source: datatypes.QtSerializableType, dest: datatypes.QtSerializableType
):
ba = cls.create_bytearray(source)
cls.write_bytearray(ba, dest)
|
get_byte_order() -> ByteOrderStr
Return byte order.
Source code in prettyqt/core/datastream.py
| def get_byte_order(self) -> ByteOrderStr:
"""Return byte order.
Returns:
byte order
"""
return BYTE_ORDER.inverse[self.byteOrder()]
|
get_floating_point_precision() -> FloatingPointPrecisionStr
Return floating point precision.
Source code in prettyqt/core/datastream.py
| def get_floating_point_precision(self) -> FloatingPointPrecisionStr:
"""Return floating point precision.
Returns:
floating point precision
"""
return FLOATING_POINT_PRECISION.inverse[self.floatingPointPrecision()]
|
get_status() -> StatusStr
Return status.
Source code in prettyqt/core/datastream.py
| def get_status(self) -> StatusStr:
"""Return status.
Returns:
status
"""
return STATUS.inverse[self.status()]
|
set_byte_order(order: ByteOrderStr | QtCore.QDataStream.ByteOrder)
Set byte order.
Parameters:
| Name |
Type |
Description |
Default |
order
|
ByteOrderStr | ByteOrder
|
|
required
|
Source code in prettyqt/core/datastream.py
| def set_byte_order(self, order: ByteOrderStr | QtCore.QDataStream.ByteOrder):
"""Set byte order.
Args:
order: byte order to use
"""
self.setByteOrder(BYTE_ORDER.get_enum_value(order))
|
set_floating_point_precision(precision: FloatingPointPrecisionStr | QtCore.QDataStream.FloatingPointPrecision)
Set floating point precision.
Parameters:
| Name |
Type |
Description |
Default |
precision
|
FloatingPointPrecisionStr | FloatingPointPrecision
|
|
required
|
Source code in prettyqt/core/datastream.py
| def set_floating_point_precision(
self,
precision: FloatingPointPrecisionStr | QtCore.QDataStream.FloatingPointPrecision,
):
"""Set floating point precision.
Args:
precision: floating point precision
"""
self.setFloatingPointPrecision(FLOATING_POINT_PRECISION.get_enum_value(precision))
|
set_status(status: StatusStr)
Set status.
Parameters:
| Name |
Type |
Description |
Default |
status
|
StatusStr
|
|
required
|
Source code in prettyqt/core/datastream.py
| def set_status(self, status: StatusStr):
"""Set status.
Args:
status: status to use
"""
self.setStatus(STATUS.get_enum_value(status))
|
:fa-brands-github: Show source on GitHub