Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QDBusConnection doesn't awake a slot
Forum Updated to NodeBB v4.3 + New Features

QDBusConnection doesn't awake a slot

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 814 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    MT13
    wrote on last edited by
    #1

    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...

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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)

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • M Offline
        M Offline
        MT13
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          You should check that you currently have the service registered with

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

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved