Results 1 to 3 of 3

Thread: howto send a reply using QDBusMessage

  1. #1
    Join Date
    Jan 2010
    Posts
    12
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default howto send a reply using QDBusMessage

    Hello,

    I want to send a reply over DBUs before the end of my slot method. According to the QT document I have to use QDBusMessage QDBusMessage::createReply ( const QVariant & argument ) const.

    Suppose I have the follow slot
    Qt Code:
    1. int getValue(QString key);
    To copy to clipboard, switch view to plain text mode 

    How can I send a reply over the DBUS? I tried it like this

    Qt Code:
    1. Int getValue(QString key) {
    2. QVariant v(2);
    3. msg.createReply(v)
    4. bus.send(msg);
    5.  
    6. Return 0;
    7. }
    To copy to clipboard, switch view to plain text mode 

    Where
    Qt Code:
    1. bus= QDBusConnection::sessionBus();
    To copy to clipboard, switch view to plain text mode 

    But I get the follow DBUS error
    QDBusConnection: error: could not send invalid message to service “”

  2. #2
    Join Date
    Jan 2010
    Posts
    12
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: howto send a reply using QDBusMessage

    it seems that I have to implement the follow slot

    Qt Code:
    1. int getValue(QString key,const QDBusMessage&);
    To copy to clipboard, switch view to plain text mode 

    and the slot implemantation is

    Qt Code:
    1. int getValue(QString key,const QDBusMessage& msg) {
    2.  
    3. QVariant v(2);
    4. QDBusMessage reply= msg.createReply(v)
    5. QDBusConnection::sessionBus().send(reply);
    6.  
    7. Return 0;
    8. }
    To copy to clipboard, switch view to plain text mode 

    However I recevied 2 replys in that case .
    According to the QT document no reply should be send on return.

  3. #3
    Join Date
    Jan 2010
    Posts
    12
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: howto send a reply using QDBusMessage

    I have to set


    Qt Code:
    1. msg.setDelayedReply(true);
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. QDBusMessage problem
    By nrabara in forum Newbie
    Replies: 1
    Last Post: 10th November 2012, 09:17
  2. QDBusMessage returns NULL string
    By nrabara in forum Qt Programming
    Replies: 0
    Last Post: 27th November 2009, 06:09
  3. Qt widget causing "unexpected async reply"
    By gct in forum Qt Programming
    Replies: 3
    Last Post: 11th March 2008, 15:04

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.