Congratulations to our 2022 Qt Champions!

Give qdbusxml2cpp some options within QtCreator

  • Hi!

    I am using qdbusxml2cpp to generate the adaptor and the interface class for dbus.
    I saw there is option "-c" give the name of the class.
    How can I add this option to qdbusxml2cpp in QtCreator?

    Kind regards,

  • Lifetime Qt Champion

    Hi @MHermann:

    How do you call qdbusxml2cpp from Creator?

  • Hi @aha_1980,

    I am not explicitly calling qdbusxml2cpp.
    I think it is automatically used because of these two lines in the project file:

    DBUS_ADAPTORS += org.example.xml
    DBUS_INTERFACES += org.example.xml

    Now I am wondering if it is possible to give some options to this?
    I want to give the class names with the option "-c".

  • Lifetime Qt Champion

    Hi @MHermann,

    Looks like the comment section in QTBUG-45434 has some hints on this.


    There are two ways of passing flags to qdbusxml2cpp. One way is to set it for all interfaces and for all adaptors:


    In case you want to pass different flags for different source XML, you'll want the following instead:

    DBUS_ADAPTORS += chat
    chat.files =
    chat.header_flags = -lFoo
    chat.source_flags = -lFoo



  • Hi @aha_1980,

    that was exactly the soultion.

    I changed

    DBUS_ADAPTORS += org.example.xml


    DBUS_ADAPTORS += dbusAdaptor
    dbusAdaptor.files = org.example.xml
    dbusAdaptor.header_flags = -cdbus_adaptor
    dbusAdaptor.source_flags = -cdbus_adaptor

    in the project file.

    So the class name dbus_adaptor is used for the D-Bus adaptor.

Log in to reply