I'm trying to connect to a D-Bus signal this way:
bool result = QDBusConnection::systemBus().connect(
"foo.bar", // service
"/foo/bar", // path
"foo.bar", // interface
"SignalSomething",
this,
SLOT(SignalSomethingSlot()));
if( !result )
{
// Why!?
}
QDBusConnection::connect() returns a boolean, how do I get extended error information? If a check QDBusConnection::lastError() it returns no useful information (as QDBusError::isValid() is false).
I had the same issue and it turned out that the slot I connected to had the wrong parameter types. They must match according to Qt's documentation and it looks like
connect()verifies that, despite not explicitly mentioned.I suggest d-feet to list signals and check their parameter types.
dbus-monitordoes list signals, paths and such too, but not always the exact type of parameters.One important observation though: I fixed the issue in my particular case by using different slot parameters than the actual signal has!
I wanted to connect to a
com.ubuntu.Upstart0_6signal mentioned here to detect when the screen in Ubuntu is locked/unlocked.dbusmonitorprints the following andd-feetshows parameters(String, Array of [String])Hence the signal should be of type
This however made
connect()returnfalse. The solution was to remove the array parameter from the slot:I am aware that the array parameter was always empty, but I cannot explain why it only worked when removing it.