Reputation: 11808
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?
Upvotes: 2
Views: 1446
Reputation: 1156
I assume something like this should help you
QDBusMessage msg = QDBusMessage::createSignal( ... )
QStringList strlist;
strlist << "Hello" << "World";
msg << QVariant::fromValue( strlist);
QDBusConnection::systemBus().send( msg );
Note: If you are working with custom types, you should use the Q_DECLARE_METATYPE() macro to register your custom type.
Upvotes: 0