1

How can I hook my QT slot to respond to a D-BUS signals generated by some 3rd party service?

Is the following right?

QDBusConnection bus = QDBusConnection::systemBus();
bus.connect("com.me.foo", "/", "com.me.foo.bar", "foo",
                this, SLOT(fooSignal()));
James Bennet
  • 603
  • 2
  • 10
  • 22

1 Answers1

2

First, you have to find out, on which bus is that service registered (system or session). For session bus you will have to change QDBusConnection::systemBus() to QDBusConnection::sessionBus()

To get proper argument values for connect(), you will have to get service name, object path, interface and signal name.

The easiest way to do both tasks is to use qdbusviewer application, which is a part of Qt dev tools (qt4-dev-tools or qttools5-dev-tools in Ubuntu). It allows to see services on both buses, traverse object trees and list Methods. Properties and Signals of D-Bus interfaces, implemented by each registered object.