Uploaded image for project: 'Qt for Python'
  1. Qt for Python
  2. PYSIDE-2535

Cannot get properties of a DBusInterface

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P3: Somewhat important
    • None
    • 6.5.1
    • PySide
    • None
    • Ubuntu Focal, Python 3.10, PySide 6.5.1
    • Linux/X11
    • 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.

      Attachments

        1. client-pyside-2535.py
          0.7 kB
        2. pyside2535_log.txt
          1 kB
        3. pyside2535.zip
          5 kB
        4. server-pyside-2535.py
          2 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            kleint Friedemann Kleint
            malocascio Mark Locascio
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes