Skip to content

NetworkDatagram

Qt Base Class: QNetworkDatagram

Signature: QNetworkDatagram(self) -> None QNetworkDatagram(self, data: Union[PySide6.QtCore.QByteArray, bytes], destinationAddress: Union[PySide6.QtNetwork.QHostAddress, PySide6.QtNetwork.QHostAddress.SpecialAddress] = Default(QHostAddress), port: int = 0) -> None QNetworkDatagram(self, other: Union[PySide6.QtNetwork.QNetworkDatagram, PySide6.QtCore.QByteArray]) -> None

Base classes

Name Children Inherits
QNetworkDatagram
PySide6.QtNetwork
QNetworkDatagram(self) -> None

⋔ Inheritance diagram

graph TD
  1473574008544["network.NetworkDatagram"]
  1473573842624["QtNetwork.QNetworkDatagram"]
  1473291690208["Shiboken.Object"]
  140713234304496["builtins.object"]
  1473573842624 --> 1473574008544
  1473291690208 --> 1473573842624
  140713234304496 --> 1473291690208

🛈 DocStrings

Bases: QNetworkDatagram

The data and metadata of a UDP datagram.

Source code in prettyqt\network\networkdatagram.py
class NetworkDatagram(network.QNetworkDatagram):
    """The data and metadata of a UDP datagram."""

    def get_destination_address(self) -> network.HostAddress:
        return network.HostAddress(self.destinationAddress())

    def get_sender_address(self) -> network.HostAddress:
        return network.HostAddress(self.senderAddress())

    def set_data(self, data: str):
        self.setData(QtCore.QByteArray(data.encode()))

    def get_data(self) -> str:
        return self.data().data().decode()