As written In the title, I am trying to add my custom type (calles TestType) to a d-bus based interfaces. However when compyling the code, I get an error message in the generated adaptor code
TestType has not been declared.
I have searched the internet and found some examples how it should work. So in the XML protocol file (Test.xml), I have added following method:
Qt Code:
  1. <method name="testMethod">
  2. <annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="TestType"/>
  3. <arg name="TestType" type="(i)" direction="in"/>
  4. </method>
To copy to clipboard, switch view to plain text mode 

In my header file I have following (TestType.hpp)

Qt Code:
  1. #ifndef TESTTYPE_HPP
  2. #define TESTTYPE_HPP
  3.  
  4. #include <QDBusArgument>
  5. #include <QDBusMetaType>
  6. #include <QObject>
  7.  
  8. enum class TestType
  9. {
  10. ...whatever
  11. };
  12.  
  13. QDBusArgument &operator<<(QDBusArgument &argument, const TestType &testType);
  14. const QDBusArgument &operator>>(const QDBusArgument &argument, const TestType &testType);
  15.  
  16. Q_DECLARE_METATYPE(TestType)
  17.  
  18. inline void registerType()
  19. {
  20. qRegisterMetaType<TestType>("TestType");
  21. qDBusRegisterMetaType<TestType>();
  22. }
  23.  
  24. #endif // TESTTYPE_HPP
To copy to clipboard, switch view to plain text mode 

The according .cpp file looks like this:

Qt Code:
  1. #include "TestType.hpp"
  2. #include <QDBusMetaType>
  3.  
  4. QDBusArgument &operator<<(QDBusArgument &argument, const TestType &testType)
  5. {
  6. argument.beginStructure();
  7. argument << testType;
  8. argument.endStructure();
  9.  
  10. return argument;
  11. }
  12.  
  13. const QDBusArgument &operator>>(const QDBusArgument &argument, const TestType &testType)
  14. {
  15. argument.beginStructure();
  16. argument >> testType;
  17. argument.endStructure();
  18.  
  19. return argument;
  20. }
  21.  
  22. int main(int argc, char *argv[])
  23. {
  24. registerType();
  25. }
To copy to clipboard, switch view to plain text mode 

I will try to copy only the relevant lines from my cmake file:

Qt Code:
  1. set(SOURCES TestType.cpp AnotherTestClass.cpp Test.xml)
  2.  
  3. qt5_add_dbus_adaptor(SOURCES Test.xml
  4. AnotherTestClass.hpp AnotherTestClass)
To copy to clipboard, switch view to plain text mode 

So when the generated source code of the adaptor classes is created, I get the mentioned error. In my understanding, I have to specify somehow that the generated source files include my header ? IF yes, I don't know how to do it, or am I missing something completely? I am using qt 5.12 on ubuntu.