QDBusConnection doesn't awake a slot



  • so I found the same problem here: http://qt-project.org/forums/viewthread/52203 but the solution didn't work for me. My qdbusconnection returns that it is connected, but doesn't awake a slot.

    here is the code:
    @void connectToDesktop()
    {
    if (QDBusConnection::sessionBus().isConnected())
    {
    bool res = QDBusConnection::sessionBus().connect("org.kde.Solid.PowerManagement",
    "/org/kde/Solid/PowerManagement/Actions/BrightnessControl",
    "org.kde.Solid.PowerManagement.Actions.BrightnessControl",
    "brightnessChanged",
    this,
    SLOT(myFn()));
    }
    if(res==true)
    {
    Log()<<"connectToDesktop: --- connected!\n";
    }

    if (res==false)
    {
    Log() << "connection to desktop failed.\n";
    return;
    }
    }

    void myFn()
    {
    Log()<<"myFn: --- in myFn\n";
    }
    @

    so, my program gets into the if(res==true) scope and prints that it is connected, but doesn't print log in myFn.

    This code is a part of a bigger one, so QApplication is included and used elsewhere. Can someone help me? Thanks...

    Edited:

    I understood what was wrong. My application runs from root that's why dbus doesn't awake a slot. When I run the same code in the different project, which runs as usual user, it works.

    But now I don't know how to make it work from root...


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    If I understood the doc correctly your slot signature doesn't match the brightnessChanged signature. That's why it doesn't work. myFn should be myFn(int)



  • Hello an thank you :)

    I did what you said, but it still doesn't work =(

    I also tried different services, but it does the same: returns true, but doesn't awake the slot.


  • Lifetime Qt Champion

    You should check that you currently have the service registered with

    @QDBusConnection::sessionBus().interface()->isServiceRegistered("org.kde.Solid.PowerManagement")@


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.