Senior Software Engineer at KDAB, Volker has been developing with Qt for more than ten years now. He works in Berlin's KDAB office as a team lead, consultant and trainer. His experience with Qt spans desktop and embedded platforms, with a focus on software architecture and tooling. He has taught many 'Programming with Qt' trainings throughout Europe and is a long-term contributor to the KDE project. In 2010 Volker started the GammaRay project to address the need for QML debugging tools (which did not yet exist at this time), and has lead the project since then.
Moc's job is two-fold: it generates the qt_metacall() member function that dispatches incoming calls to slots and implements reading and writing of properties, and it generates the QMetaObject containing information about what signals, slots and properties are available, providing runtime introspection capabilities. All of this is fixed at compile time though, a limitation that might get into your way when using dynamic languages such as QML.
When exposing objects to a scripting language that are only known at runtime, or similarly when connecting to an IPC service, it is however possible to generate QMetaObjects dynamically, albeit using non-public Qt API. We will see how to do that, what to consider and how to use the resulting dynamic meta objects.
In order to also give these dynamically created objects sensible functionality, we will look at implementing qt_metacall() ourselves. This has applications beyond scripting in regular static C++ applications as well, for creating more powerful signal mappers for example, as it provides a way to intercept incoming signals including the ability to look at their arguments.
If you are integrating a dynamic language into your Qt application, designing a QML-based DSL, or implementing IPC code with Qt, or just want to look deep into some of the internals of QObject, this talk is for you.