Unsolved Extracting multiple possible custom types from QDBusVariant
-
I have a method on DBus returning a variant, where the return value is one of multiple custom types.
QDBusInterface server("org.customtest", "/", "org.customtest"); QDBusReply<QDBusVariant> reply = server.call("person"); if (reply.isValid()) { auto arg = reply.value().variant().value<QDBusArgument>(); Person p; arg >> p; qDebug() << p.name << p.age; }
Now this code obviously doesn't work, when the return type isn't
Person
, so is there any way to identify the type of this variant? -
Hi,
Out of curiosity, why would a call to the person endpoint return something else ?
-
@SGaist This is just an example showing what I do in my actual service.
-
You can use canConvert.
-
@SGaist The value in the returned QDBusVariant is QDBusArgument in this case, so I cannot cast to QVariant from it.