Skip to content

BluetoothServiceInfo

Qt Base Class: QBluetoothServiceInfo

Signature: QBluetoothServiceInfo(self) -> None QBluetoothServiceInfo(self, other: PySide6.QtBluetooth.QBluetoothServiceInfo) -> None

Base classes

Name Children Inherits
QBluetoothServiceInfo
PySide6.QtBluetooth
QBluetoothServiceInfo(self) -> None
MutableMapping
collections.abc
A MutableMapping is a generic container for associating

⋔ Inheritance diagram

graph TD
  1473367553168["bluetooth.BluetoothServiceInfo"]
  1473367544384["QtBluetooth.QBluetoothServiceInfo"]
  1473291690208["Shiboken.Object"]
  140713234304496["builtins.object"]
  1473222543776["abc.MutableMapping"]
  1473222540848["abc.Mapping"]
  1473222211728["abc.Collection"]
  1473222226368["abc.Sized"]
  1473222223440["abc.Iterable"]
  1473222220512["abc.Container"]
  1473367544384 --> 1473367553168
  1473291690208 --> 1473367544384
  140713234304496 --> 1473291690208
  1473222543776 --> 1473367553168
  1473222540848 --> 1473222543776
  1473222211728 --> 1473222540848
  1473222226368 --> 1473222211728
  140713234304496 --> 1473222226368
  1473222223440 --> 1473222211728
  140713234304496 --> 1473222223440
  1473222220512 --> 1473222211728
  140713234304496 --> 1473222220512

🛈 DocStrings

Bases: QBluetoothServiceInfo, MutableMapping

Enables access to the attributes of a Bluetooth service.

Also implements MutableMapping interface, can be used as a dicionary.

Source code in prettyqt\bluetooth\bluetoothserviceinfo.py
class BluetoothServiceInfo(
    QtBluetooth.QBluetoothServiceInfo, MutableMapping, metaclass=datatypes.QABCMeta
):
    """Enables access to the attributes of a Bluetooth service.

    Also implements MutableMapping interface, can be used as a dicionary.
    """

    def __getitem__(self, value: str | int | AttributeId):
        match value:
            case int():
                flag = value
            case str():
                if value not in ATTRIBUTE_IDS:
                    raise KeyError(value)
                flag = ATTRIBUTE_IDS[value].value
            case AttributeId():
                flag = value.value
            case _:
                raise KeyError(value)
        return self.attribute(flag)

    def __delitem__(self, value: str | int | AttributeId):
        match value:
            case int():
                flag = value
            case str():
                flag = ATTRIBUTE_IDS[value].value
            case AttributeId():
                flag = value.value
        return self.removeAttribute(flag)

    def __setitem__(self, index: str | int | AttributeId, value):
        """Set attribute."""
        match index:
            case int():
                flag = index
            case str():
                flag = ATTRIBUTE_IDS[index].value
            case AttributeId():
                flag = index.value
        return self.setAttribute(flag, value)

    def __contains__(self, value: int) -> bool:
        attr = ATTRIBUTE_IDS.inverse[value]
        return self.contains(attr)

    def __iter__(self):
        """Iter the info attributes."""
        return iter(self.attributes())

    def __len__(self):
        return len(self.attributes())

__iter__()

Iter the info attributes.

Source code in prettyqt\bluetooth\bluetoothserviceinfo.py
def __iter__(self):
    """Iter the info attributes."""
    return iter(self.attributes())

__setitem__(index: str | int | AttributeId, value: str | int | AttributeId)

Set attribute.

Source code in prettyqt\bluetooth\bluetoothserviceinfo.py
def __setitem__(self, index: str | int | AttributeId, value):
    """Set attribute."""
    match index:
        case int():
            flag = index
        case str():
            flag = ATTRIBUTE_IDS[index].value
        case AttributeId():
            flag = index.value
    return self.setAttribute(flag, value)