I have to implement a DBus service in Qt that must return a reasonably complex piece of data that follows a given spec. The data is essentially a series of tested maps, arrays, structures, and other variants.
I can't find a handy way to pack all this into the reply from my method. It seems like I should be able to use the QDBusArgument
class for this. For example, to create an array of strings, I should be able to do this:
QDBusArgument arg;
arg.beginArray( qMetaTypeId<QString>());
arg << "Hello" << "World";
arg.endArray();
QVariant var = arg.asVariant();
But that doesn't work. It seems I need to painstakingly construct QList
s of variants manually. Surely there's a better way?
I assume something like this should help you