Skip to content

DataStream

Qt Base Class: QDataStream

Signature: QDataStream(self) -> None QDataStream(self, arg__1: PySide6.QtCore.QIODevice) -> None QDataStream(self, arg__1: Union[PySide6.QtCore.QByteArray, bytes]) -> None QDataStream(self, arg__1: Union[PySide6.QtCore.QByteArray, bytes], flags: PySide6.QtCore.QIODeviceBase.OpenModeFlag) -> None

Base classes

Name Children Inherits
QDataStream
PySide6.QtCore
QDataStream(self) -> None

⋔ Inheritance diagram

graph TD
  1473299833568["core.DataStream"]
  1473288961312["QtCore.QDataStream"]
  1473243629040["QtCore.QIODeviceBase"]
  1473291690208["Shiboken.Object"]
  140713234304496["builtins.object"]
  1473288961312 --> 1473299833568
  1473243629040 --> 1473288961312
  1473291690208 --> 1473243629040
  140713234304496 --> 1473291690208

🛈 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

byte order to use

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

floating point precision

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

status to use

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))