[Qt-interest] QDBusConnection::ExposeChildObjects
Stefan Majewsky
stefan.majewsky at googlemail.com
Mon Sep 26 11:57:57 CEST 2011
Hi,
I'm trying to implement an application that exposes a standardized
DBus interface. The specification states that (using metasyntactic
variables) the application must expose the "/org/someinterface" object
path, which must implement the "org.someinterface.foo" and
"org.someinterface.bar" interfaces.
I have the XML files for these interfaces, and have qdbusxml2cpp
autogenerate adaptor classes for them. In the code, I want to keep the
classes Foo and Bar implementing the interfaces separate. Both are
constructed like this:
Foo::Foo(QObject* parent) : QObject(parent)
{
new FooAdaptor(this);
QDBusConnection::registerObject(OBJECT_PATH, this);
}
When I instantiate only Foo, it works fine (as in: shows up on the
DBus correctly and stuff). But when I instantiate Bar, it won't show
up. I think that's registerObject() not allowing two objects on the
same path (sounds reasonable). However, I really want Foo and Bar to
be separate classes, or it becomes a royal mess. So I tried to use the
ExportChildObjects flag of registerObject(). Like this:
void inside_main()
{
QObject master;
new Foo(&master);
new Bar(&master);
QDBusConnection::registerObject(OBJECT_PATH, &master,
QDBusConnection::ExportAdaptors |
QDBusConnection::ExportChildObjects);
}
(Of course the registerObject() call is gone from Foo's and Bar's
ctors now.) But now only an empty object shows up on the DBus (i.e.
qdbus only gives me the default Properties and Introspect interfaces).
What am I doing wrong?
Greetings
Stefan
More information about the Qt-interest-old
mailing list