commit 69b7332e19cb6b9cbbea5632916d2cb40caa30e4
parent de763d333e46c4c546d4cd6c1ba24784a4fe7afe
Author: Santtu Lakkala <inz@inz.fi>
Date: Fri, 18 Feb 2011 18:58:37 +0000
qmake and D-Bus
Diffstat:
1 file changed, 18 insertions(+), 0 deletions(-)
diff --git a/posts/qmake-and-d-bus.md b/posts/qmake-and-d-bus.md
@@ -0,0 +1,18 @@
+# qmake and D-Bus
+
+ 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.
+
+ 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.
+
+ 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.
+
+ TEMPLATE = app
+ QT = core dbus
+ TARGET = qtdbus
+ DBUS_ADAPTORS = fi.inz.hello.xml
+ SOURCES = hello.cpp main.cpp
+ HEADERS = hello.h
+
+ With this simple .pro file qmake autogenerates the adaptor on build.
+
+ 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)