PDA

View Full Version : How to send objectpath as an argument in dbus method?



Sage
6th August 2009, 15:00
Hi,

I'm trying to call dbus method where DBusObjectPath is the argument.

The method is defined as following:

...
<method name="Path">
<arg type="o" direction="in" name="path" />
</method>
...



...
QDBusObjectPath objectpath("/mypath");
((QDBusInterface*)iface)->call("Path",objectpath);
...

With the code above compiler returns following error:


error: ‘QString’ is an inaccessible base of ‘QDBusObjectPath’


However, if I use QDBusObjectPath :: path() as a argument.


...
QDBusObjectPath objectpath("/mypath");
((QDBusInterface*)iface)->call("Path",objectpath.path());
...

The code compiles, but dbus returns the following error, because the parameter is now string not objectpath.


"Method "Path" with signature "s" on interface "org.test" doesn't exist"


So the question is how to send objectpath as an argument in dbus method?

-Sage

yogeshgokul
6th August 2009, 15:10
Try this:


interface->call(QLatin1String("Path"), objectpath.path());

Sage
7th August 2009, 07:25
Try this:


interface->call(QLatin1String("Path"), objectpath.path());
Well, this does not help as the problem is not the method name, but the type of the argument (Tried it anyway to be sure).

nrabara
26th November 2009, 12:23
Hi,

I am also having the same problem.

Pls somebody help me?

Your suggestion would be a great help for me....

anders
5th January 2010, 07:41
I had the same problem and solved it with QVariant::fromValue()


QDBusObjectPath objectpath("/mypath");
((QDBusInterface*)iface)->call("Path", QVariant::fromValue(objectpath));

Sage
7th January 2010, 11:42
I had the same problem and solved it with QVariant::fromValue()


QDBusObjectPath objectpath("/mypath");
((QDBusInterface*)iface)->call("Path", QVariant::fromValue(objectpath));

Works like a charm, thanks.