QDbus from Python: read DBus property



  • Hello, I wrote a couple of Python lines that work:

    def get_prop(bus, service, object_path, interface, name):
        obj = bus.get_object(service, object_path)
        iface = dbus.Interface(obj, 'org.freedesktop.DBus.Properties')
        property = iface.Get(interface, name)
        print(property)
    
    bus = dbus.SystemBus()
    get_prop(bus, 'org.bluez', '/org/bluez/hci0/dev_xx_xx_xx_xx_xx_xx/player0', "org.bluez.MediaPlayer1", "Status")
    

    This is a common way to read a DBus property.
    I'm in trouble to translate this to Qt5:

    QDBusInterface *iface = new QDBusInterface("org.bluez", "/org/bluez/hci0/dev_xx_xx_xx_xx_xx_xx/player0", "org.freedesktop.DBus.Properties", QDBusConnection::systemBus(), this);
    qDebug() <<  iface->call("Get",  "org.bluez.MediaPlayer1", "Status").arguments();
    

    but it returns:

    QVariant(QDBusVariant, )

    Where is my mistake?
    Is there a more convenient way to read DBus properties?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.