qmake and D-Bus
February 18, 2011 on 9:58 pm | In geeky | 3 CommentsSomething 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.
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 hello.cpp hello.h main.cpp qtdbus.pro
3 Comments »
RSS feed for comments on this post. TrackBack URI
thanks!
and it is *really* important to include "hello_adaptor.h" somewhere! even if you don't need it for testing in the first step! If you don't include it, it won't be generated by qmake. and then the hello_adaptor.cpp will not compile to object file...
Yes, it is. I ran into this too, but forgot to mention it. Thanks for reminding.
[...] итоге раскопок наткнулся на топик, где сказано, что нужно в .pro-файле просто прописать [...]