Important: Please read the Qt Code of Conduct -

Qt+dbus: signals automatically connected and disconnected?

  • Hi there!

    I want to use the dbus system qt comes with. As far as I've tested it, it works fine. Now I have one question:

    I used the qdbusxml2cpp tool to generate my code and I managed to send signals from my server application to the client. What I had to do was to something like this:

    @QObject::connect(myInterfaceObject, SIGNAL(someSignal()), this, SLOT(someSlot()));@

    There are the methods connect and disconnect in the QDBusConnection class which connects and disconnects signals and slots from the respective dbus service to a slot in my process. What I want to know: Is this connection and disconnection to the dbus signals done automatically with the QObject::connect/disconnect calls in my Object which receives the signals?

    It's interesting because of performance issues. Can I assume that my process does not receive signals from the dbus if there is no slot connected to it? Or do I receive these signals and qts dbus module discards them if no slot is connected? And are these signals automatically disconnected when the Object which wanted to receive them gets deleted? From the "D-Bus Tutorial": :

    bq. The emitter (aka sender) of a signal has no knowledge of the signal recipients. Recipients register with the bus daemon to receive signals based on "match rules" - these rules would typically include the sender and the signal name. The bus daemon sends each signal only to recipients who have expressed interest in that signal.

    I just want to make sure that my process does not receive any signals from the server when there is no slot registered to it.

    Thanks in advance.

  • I think I found the answer: The interface will connect signal to the dbus dynamically. I found


    in the source of QDBusAbstractInterface which calls connection->connectRelay.

    If you investigate a little bit further you will find the calls to connection->connect(..) somewhere. Vice versa you can find the same stuff for the disconnectNotify.

    So in my opinion: Smart Qt :D

Log in to reply