On Wednesday, 29 de December de 2010 16:16:44 He, Yunlong wrote: > Hi, experts, > > In qt doc, qtdbus supports customized type âMyStructâ, so I write > code as below:
> class MyStruct
> {
> public:
> â¦
>
> int type;
> QByteArray data;
> };
>
> Q_DECLARE_METATYPE(MyStruct);
>
>
> QDBusArgument &operator<<(QDBusArgument &argument, const MyStruct &msg);
> const QDBusArgument &operator>>(const QDBusArgument &argument, MyStruct
> &msg);
Please direct your Qt questions to [email protected]. But anyway...
And somewhere you call:
qDBusRegisterMetaType<MyStruct>();
> but when I use it as below:
>
> void notify(MyStruct & msg) {
> â¦
> QDBusReply<int> reply = iface->call(âmessageArrivedâ, msg);
> â¦
> }
>
> It reports âno matching function for call to QDBusInterface::call(const
> char[21], MyStruct &)â
That's a C++ error, nothing to do with QtDBus.
The QDBusInterface::call function has a QString argument, followed by 8
defaulted QVariant arguments. Your "MyStruct" argument doesn't convert to
QVariant.
> How can I use it in this case? Or I must convert to QVariant?
Yes. There are two ways to do that:
1) add operator QVariant() const { return QVariant::fromValue(*this); }
to your MyStruct class
2) make the call as:
call("messageArrived", QVariant::fromValue(msg));
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Senior Product Manager - Nokia, Qt Development Frameworks
PGP/GPG: 0x6EF45358; fingerprint:
E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4 5358
pgpLFdvBoHQVs.pgp
Description: This is a digitally signed message part.
_______________________________________________ MeeGo-dev mailing list [email protected] http://lists.meego.com/listinfo/meego-dev
