Results 1 to 6 of 6

Thread: How to send objectpath as an argument in dbus method?

  1. #1
    Join Date
    Aug 2009
    Posts
    3
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default How to send objectpath as an argument in dbus method?

    Hi,

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

    The method is defined as following:
    Qt Code:
    1. ...
    2. <method name="Path">
    3. <arg type="o" direction="in" name="path" />
    4. </method>
    5. ...
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. ...
    2. QDBusObjectPath objectpath("/mypath");
    3. ((QDBusInterface*)iface)->call("Path",objectpath);
    4. ...
    To copy to clipboard, switch view to plain text mode 
    With the code above compiler returns following error:
    Qt Code:
    1. error: ‘QString’ is an inaccessible base of ‘QDBusObjectPath’
    To copy to clipboard, switch view to plain text mode 

    However, if I use QDBusObjectPath :: path() as a argument.
    Qt Code:
    1. ...
    2. QDBusObjectPath objectpath("/mypath");
    3. ((QDBusInterface*)iface)->call("Path",objectpath.path());
    4. ...
    To copy to clipboard, switch view to plain text mode 
    The code compiles, but dbus returns the following error, because the parameter is now string not objectpath.
    Qt Code:
    1. "Method "Path" with signature "s" on interface "org.test" doesn't exist"
    To copy to clipboard, switch view to plain text mode 

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

    -Sage

  2. #2
    Join Date
    Dec 2007
    Posts
    628
    Thanks
    3
    Thanked 89 Times in 87 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to send objectpath as an argument in dbus method?

    Try this:
    Qt Code:
    1. interface->call(QLatin1String("Path"), objectpath.path());
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Aug 2009
    Posts
    3
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to send objectpath as an argument in dbus method?

    Quote Originally Posted by yogeshgokul View Post
    Try this:
    Qt Code:
    1. interface->call(QLatin1String("Path"), objectpath.path());
    To copy to clipboard, switch view to plain text mode 
    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).

  4. #4
    Join Date
    Sep 2008
    Posts
    58
    Thanks
    11
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default Re: How to send objectpath as an argument in dbus method?

    Hi,

    I am also having the same problem.

    Pls somebody help me?

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

  5. #5
    Join Date
    Dec 2009
    Posts
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to send objectpath as an argument in dbus method?

    I had the same problem and solved it with QVariant::fromValue()

    Qt Code:
    1. QDBusObjectPath objectpath("/mypath");
    2. ((QDBusInterface*)iface)->call("Path", QVariant::fromValue(objectpath));
    To copy to clipboard, switch view to plain text mode 

  6. The following user says thank you to anders for this useful post:

    Sage (7th January 2010)

  7. #6
    Join Date
    Aug 2009
    Posts
    3
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to send objectpath as an argument in dbus method?

    Quote Originally Posted by anders View Post
    I had the same problem and solved it with QVariant::fromValue()

    Qt Code:
    1. QDBusObjectPath objectpath("/mypath");
    2. ((QDBusInterface*)iface)->call("Path", QVariant::fromValue(objectpath));
    To copy to clipboard, switch view to plain text mode 
    Works like a charm, thanks.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.