C++ Reflection and Qt MOC
4 days ago
- #Qt
- #Reflection
- #C++
- C++26 reflection may not fully replace Qt's moc (meta-object compiler) due to missing features like token injection and string-based lookup.
- Current moc extracts metadata like class names, parent classes, properties, invokables, and more, which may not be fully replicable with C++26 reflection.
- Key challenges include handling Q_PROPERTY, Q_ENUM, Q_CLASSINFO, and Q_INTERFACES without string-based reflection.
- Potential solutions include structured property declarations or waiting for C++29 features like token sequence injection.
- Signals implementation requires definition injection, which is not possible with P2996 reflection, posing a significant hurdle.
- Buildsystem integration and triggering reflection in .cpp files may require new macros or manual annotations.
- JSON output for metaobject information is currently out of scope for reflection-based solutions.