Details
-
Bug
-
Resolution: Fixed
-
P3: Somewhat important
-
None
-
6.5.1
-
None
-
Ubuntu Focal, Python 3.10, PySide 6.5.1
-
-
16b17fa01 (dev), 8854d73e8 (dev), 20a36aede (dev)
Description
According to the documentation here, properties of a QDBusInterface should be accessible through the normal QObject::property() and QObject::setProperty() methods. However, I'm not able to do so.
I've got a DBus object on the session bus with which I'd like to interact. I can see in D-Feet that the interface exposes the property (called "counts") that I expect. However, a small test script is failing to read it. Specifically, this Python script:
session_bus = QDBusConnection.sessionBus()
if not session_bus.isConnected():
print("Cannot connect to the D-Bus session bus.")
sys.exit(-1)
iface = QDBusInterface(SERVICE_NAME, '/', INTERFACE_NAME, session_bus)
if not iface.isValid():
print(session_bus.lastError().message())
sys.exit(-1)
{{counts_from_remote = iface.property('counts')}}
print(f'Counts from the dbus interface: {counts_from_remote}')
The iface.property('counts') method always returns None, even though the 'counts' property exists on that interface.
I can confirm that the property() method does work correctly for an object that directly inherits QObject:
from PySide6.QtCore import QObject, Property
class MyThing(QObject):
def _init_(self, parent = None):
super()._init_(parent)
self._my_prop = 16
@Property(int, constant=True)
def my_prop(self):
return self._my_prop
def main():
thing = MyThing()
p = thing.property('my_prop')
print(f'The property is {p}')
if _name_ == '_main_':
main()
It's possible that I'm doing something incorrect here, but it seems like there's at least the possibility that this is a bug.