[Qt-interest] QDBusConnection::ExposeChildObjects

Stephen Kelly steveire at gmail.com
Wed Sep 28 10:51:12 CEST 2011


Stefan Majewsky wrote:

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

You might also be interested in this bug which is also about 
ExportChildObjects:

https://bugreports.qt.nokia.com/browse/QTBUG-18051

Steve.




More information about the Qt-interest-old mailing list