I would like to use Qt's reflection mechanism since C++ lacks of this feature. It seems to work, but calling all the macros and helper functions is very tedious. For example to register an enum as a proper meta type I had to go through all the following steps:
- Declare an enum inside of a wrapper class that contains the
Q_GADGET
macro. - Register the enum using the
Q_ENUM
macro just after that. - Register the class containing the enum:
Q_DECLARE_METATYPE(MyClass)
- Call
qRegisterMetaType<..>()
for the type of the wrapping class and for each declared enum.
Now I know that some of the steps can be omitted if part of the full functionality is not required. But that is not what I am looking for, I need to use enums within signals and I need to be able to get the the meta method of a signal and query it for it's parameters type.
But still I can't help thinking that there must be a better/simpler way to do this.