Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    [QDbus] Using more object in the same service

    General and Desktop
    1
    2
    2842
    Loading More Posts
    • 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.
    • S
      stukdev last edited by

      Hi, i want register more object on the same service in qdbus. I create two class.
      The first create the service name and the object One:
      @
      //First Object Manager (One Class)

      QDBusConnection connection = QDBusConnection::sessionBus();
      connection.registerService("aa.bb.cc");
      qDebug() << "register" << connection.registerObject("/One", this);
      @

      The second create the object Second:
      @
      //Second Object Interface (Interface Class)
      QDBusConnection connection = = QDBusConnection::sessionBus();
      qDebug() << connection.isConnected();
      qDebug() << "register" << connection.registerObject("/Second", this);
      @

      The problem is the second class return true but i can't see the Second object on dbus i only see the First. For me the problem is how qt can know where is the service name where Second object is register. But how can i do this?

      PS: if i put on every class the code
      @
      QDBusConnection connection = QDBusConnection::sessionBus();
      connection.registerService("aa.bb.cc");
      @
      I know that is wrong becaus only the first class called can register the service name. But in this case the only object register is the first class i called. If i run First class at the begin...first object is create. If i run Second class at the begin second object is create.

      1 Reply Last reply Reply Quote 0
      • S
        stukdev last edited by

        You can't :)
        Every class have their connection. You can add more object on the same connection. But you can't add an object on another connection.
        The only solution is create a connection for every class in the example you can create

        @
        //First Object
        QDBusConnection connection = QDBusConnection::sessionBus();
        connection.registerService("aa.bb.cc.One");
        qDebug() << "register" << connection.registerObject("/One", this);
        @

        @
        //Second Object
        QDBusConnection connection = QDBusConnection::sessionBus();
        connection.registerService("aa.bb.cc.Second");
        qDebug() << "register" << connection.registerObject("/Second", this);
        @

        1 Reply Last reply Reply Quote 0
        • First post
          Last post