Results 1 to 4 of 4

Thread: How could you pass a nested container as an argument to an exposed DBus routine?

  1. #1
    Join Date
    Jul 2010
    Posts
    3
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default How could you pass a nested container as an argument to an exposed DBus routine?

    Hi everyone,
    I would like to pass a QVariantList as an argument to a remotely called procedure using DBus. One of the items stored in the container is a QVariantMap which when I attempt to convert it from QVariant to QVariantMap the conversion fails. For instance:

    Qt Code:
    1. void Ping::sendPing()
    2. {
    3. QVariantMap mPingMap;
    4. mPingMap.insert("key1", "map: Ping says hello");
    5. mPingMap.insert("key2", 456);
    6.  
    7. QVariantList lPingData;
    8.  
    9. lPingData << "list: Ping says hello" << 123 << mPingMap;
    10.  
    11. interfaceCallToPong->test(lPingData);
    12. }
    To copy to clipboard, switch view to plain text mode 
    // The remote method:
    Qt Code:
    1. void Pong::test( QvariantList lRemoteData )
    2. {
    3. qDebug() << lRemoteData.at(0).toString();
    4. qDebug() << lRemoreData.at(1).toInt();
    5.  
    6.  
    7. QVariant qvMap = lRemoteData.at(3); // Get the variant that contains the QVariantMap
    8.  
    9. qvMap.canConvert< QVariantMap > (); // returns false. Why?
    10.  
    11. // As a result I got no valid data for the following.
    12. QVariantMap mRemoteMap = lRemoteData.at(3).toMap();
    13.  
    14. qDebug() << mRemoteMap.value("key1").toString ();
    15. qDebug() << mRemoteMat.value("key2").toInt();
    16. }
    To copy to clipboard, switch view to plain text mode 
    the output is:
    list: Ping says hello
    123
    0
    0

    Apparently I am doing something wrong, unless we cannot pass nested containers as an argument to a remotely called procedure using DBus. Could you please help me out?

  2. #2
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: How could you pass a nested container as an argument to an exposed DBus routine?

    Qt Code:
    1. lPingData << "list: Ping says hello" << 123 << mPingMap;
    2. ///
    3. qDebug() << lRemoteData.at(0).toString();
    4. qDebug() << lRemoreData.at(1).toInt();
    5. QVariant qvMap = lRemoteData.at(3); // are you sure not at(2) ?
    To copy to clipboard, switch view to plain text mode 
    For me it looks like the map argument is at index number 2, not 3

  3. #3
    Join Date
    Jul 2010
    Posts
    3
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How could you pass a nested container as an argument to an exposed DBus routine?

    Yes you are right, it's a typo though. I have also tried to send a QVariantMap which one of its items is a QVariantList but the latter is empty at remote end as well. Although all data can be retrieved at source end before doing the remote procedure call.

  4. #4
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: How could you pass a nested container as an argument to an exposed DBus routine?

    I've just read the QtDbus docs:
    All of the QtDBus types (primitives and user-defined alike) can be used to send and receive messages of all types over the bus.
    Warning: You may not use any type that is not on the list above, including typedefs to the types listed. This also includes QList<QVariant> and QMap<QString,QVariant>.
    Looks like you can't use those types. I have 0 experience with DBus programming, but maybe you can try with QDBusVariant.

Similar Threads

  1. DBus adaptor and 'const QDBusMessege &messege' argument.
    By MarekR22 in forum Qt Programming
    Replies: 2
    Last Post: 11th February 2011, 08:15
  2. Replies: 5
    Last Post: 20th September 2010, 10:30
  3. Replies: 3
    Last Post: 28th February 2010, 08:10
  4. how can i pass objects using DBus?
    By mismael85 in forum Qt Programming
    Replies: 14
    Last Post: 17th January 2010, 08:13
  5. Replies: 5
    Last Post: 7th January 2010, 10:42

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.