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. [QDbus] Using more object in the same service
QtWS25 Last Chance

[QDbus] Using more object in the same service

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 3.0k Views
  • 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 Offline
    S Offline
    stukdev
    wrote on last edited by
    #1

    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
    0
    • S Offline
      S Offline
      stukdev
      wrote on last edited by
      #2

      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
      0

      • Login

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