qmake-and-d-bus.md (1244B)
1 # qmake and D-Bus 2 3 Something I did not find documented anywhere: a sensible way to generate QtDBus adaptor and interface classes from introspection data with qdbusxml2cpp. I only found hacks using system() and custom targets to accomplish the feat. 4 5 I though to myself that there must be a saner, better way, and while looking at the qmake generated Makefile, I noticed some interesting includes. After some investigation, I found "magic" variables DBUS_INTERFACES and DBUS_ADAPTORS. The introspect files should be named servicename.xml and listed in the variables, and qmake will do all the magic for you. 6 7 With these variables, it is really easy to generate the helper classes on-demand. Just remember to include the generated header in some code file, otherwise compilation will choke. 8 9 TEMPLATE = app 10 QT = core dbus 11 TARGET = qtdbus 12 DBUS_ADAPTORS = fi.inz.hello.xml 13 SOURCES = hello.cpp main.cpp 14 HEADERS = hello.h 15 16 With this simple .pro file qmake autogenerates the adaptor on build. 17 18 To see other files from the example, see [fi.inz.hello.xml](http://inz.fi/p/fi.inz.hello.xml) [hello.cpp](http://inz.fi/p/hello.cpp) [hello.h](http://inz.fi/p/hello.h) [main.cpp](http://inz.fi/p/main.cpp) [qtdbus.pro](http://inz.fi/p/qtdbus.pro)