Hi, I have problem with QDBus module. I want to receive signal from my other application, signal is emited (listed in dbus-monitor) however application slot is not triggered:

receiver.h
Qt Code:
  1. #ifndef RECEIVER_H
  2. #define RECEIVER_H
  3.  
  4. #include <iostream>
  5. #include <QObject>
  6.  
  7. class Receiver : public QObject {
  8. Q_OBJECT
  9. public:
  10. ~Receiver() { std::cout << "Receiver destoryed."; }
  11. public slots:
  12. void receive() {
  13. std::cout << "Received!";
  14. }
  15. };
  16.  
  17. #endif // RECEIVER_H
To copy to clipboard, switch view to plain text mode 

main.cpp
Qt Code:
  1. #include <QCoreApplication>
  2. #include <QDBusConnection>
  3. #include <QDBusInterface>
  4. #include <iostream>
  5. #include "receiver.h"
  6.  
  7. int main(int argc, char *argv[])
  8. {
  9. QCoreApplication a(argc, argv);
  10. auto bus = QDBusConnection::connectToBus(QDBusConnection::SessionBus,
  11. "ControllerBoard");
  12. if(bus.isConnected()) {
  13. std::cout << "Bus connected." << std::endl;
  14. } else {
  15. std::cout << QString("Bus not conected: %1").arg(bus.lastError().message()).toStdString()
  16. << std::endl;
  17. }
  18.  
  19. auto recv = new Receiver;
  20. auto interface = new QDBusInterface("com.ControllerBoard",
  21. "/",
  22. "com.ControllerBoard.Buttons",
  23. bus, &a);
  24.  
  25. if(interface->isValid()) {
  26. QObject::connect(interface, SIGNAL(PowerButtonPushed()), recv, SLOT(receive()));
  27. } else {
  28. std::cout << QString("Interface not valid: %1").arg(interface->lastError().message()).toStdString()
  29. << std::endl;
  30.  
  31. }
  32.  
  33. return a.exec();
  34. }
To copy to clipboard, switch view to plain text mode 

I ran application with QDBUS_DEBUG=1, here is output:
QDBusConnectionPrivate(0x7fe7780032f0) : connected successfully
Bus connected.
QDBusConnectionPrivate(0x7fe7780032f0) got message (signal): QDBusMessage(type=Signal, service="org.freedesktop.DBus", path="/org/freedesktop/DBus", interface="org.freedesktop.DBus", member="NameAcquired", signature="s", contents=(":1.104") )
QDBusConnectionPrivate(0x7fe7780032f0) sending message: QDBusMessage(type=MethodCall, service="org.freedesktop.DBus", path="/org/freedesktop/DBus", interface="org.freedesktop.DBus", member="GetNameOwner", signature="", contents=("com.ControllerBoard") )
QDBusConnectionPrivate(0x7fe7780032f0) got message reply: QDBusMessage(type=MethodReturn, service="org.freedesktop.DBus", signature="s", contents=(":1.98") )
QDBusConnectionPrivate(0x7fe7780032f0) sending message: QDBusMessage(type=MethodCall, service="com.ControllerBoard", path="/", interface="org.freedesktop.DBus.Introspectable", member="Introspect", signature="", contents=() )
QDBusConnectionPrivate(0x7fe7780032f0) got message reply: QDBusMessage(type=MethodReturn, service=":1.98", signature="s", contents=("<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node>
<interface name="com.ControllerBoard.Buttons">
<signal name="PowerButtonPushed"/>
<signal name="PowerButtonReleased"/>
<signal name="ScalesButtonPushed"/>
<signal name="ScalesButtonReleased"/>
<signal name="TimerButtonPushed"/>
<signal name="TimerButtonReleased"/>
</interface>
<interface name="org.freedesktop.DBus.Properties">
<method name="Get">
<arg name="interface_name" type="s" direction="in"/>
<arg name="property_name" type="s" direction="in"/>
<arg name="value" type="v" direction="out"/>
</method>
<method name="Set">
<arg name="interface_name" type="s" direction="in"/>
<arg name="property_name" type="s" direction="in"/>
<arg name="value" type="v" direction="in"/>
</method>
<method name="GetAll">
<arg name="interface_name" type="s" direction="in"/>
<arg name="values" type="a{sv}" direction="out"/>
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QVariantMap"/>
</method>
<signal name="PropertiesChanged">
<arg name="interface_name" type="s" direction="out"/>
<arg name="changed_properties" type="a{sv}" direction="out"/>
<annotation name="org.qtproject.QtDBus.QtTypeName.Out1" value="QVariantMap"/>
<arg name="invalidated_properties" type="as" direction="out"/>
</signal>
</interface>
<interface name="org.freedesktop.DBus.Introspectable">
<method name="Introspect">
<arg name="xml_data" type="s" direction="out"/>
</method>
</interface>
<interface name="org.freedesktop.DBus.Peer">
<method name="Ping"/>
<method name="GetMachineId">
<arg name="machine_uuid" type="s" direction="out"/>
</method>
</interface>
</node>
") )
QDBusConnectionPrivate(0x7fe7780032f0) Adding rule: "type='signal',sender='org.freedesktop.DBus',inter face='org.freedesktop.DBus',member='NameOwnerChang ed',arg0='com.ControllerBoard'"
QDBusConnectionPrivate(0x7fe7780032f0) Adding rule: "type='signal',sender='com.ControllerBoard',pa th='/',interface='com.ControllerBoard.Buttons',member=' PowerButtonPushed'"
QDBusConnectionPrivate(0x7fe7780032f0) sending message: QDBusMessage(type=MethodCall, service="org.freedesktop.DBus", path="/org/freedesktop/DBus", interface="org.freedesktop.DBus", member="GetNameOwner", signature="", contents=("com.ControllerBoard") )
QDBusConnectionPrivate(0x7fe7780032f0) got message reply: QDBusMessage(type=MethodReturn, service="org.freedesktop.DBus", signature="s", contents=(":1.98") )
QDBusConnectionPrivate(0x7fe7780032f0) Watching service "com.ControllerBoard" for owner changes (current owner: ":1.98" )
QDBusConnectionPrivate(0x7fe7780032f0) got message (signal): QDBusMessage(type=Signal, service=":1.98", path="/", interface="com.ControllerBoard.Buttons", member="PowerButtonPushed", signature="", contents=() )