qt4qdbus

QDbusReply doesn't work calling a DBus function which returns a aa{sv} with Qt4?


I have a dbus interface which works in d-feet as expected but when I want to call it from within my QT4 Application the list has zero size :(

I guess, aa{sv} can be used from Qt4 via QVariantList, right?

QDBusReply< QVariantList > reply = dbusinterface.call("getUsers");
QVariantList value = reply.value();
qDebug() << "user size: " << value.size();

Can't someone please shed some light on this? Thanks!


Solution

  • Ok. I finally found a way to retrieve the correct list. No garanties that it is "the way" but at least, it does what it should :).

    QDBusMessage result = dbusinterface.call("getUsers");
    QDBusArgument v = result.arguments()[0].value<QDBusArgument>();
    QVariantMap m;
    QVariantList l;
    
    v.beginArray();
    while(!v.atEnd()) {
        v >> m;
        l.append(m);
    }
    
    qDebug() << "users count: " << l.size();