Skip to content

DIY moc – Dynamic Meta Objects Volker Krause

Abstract: 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.

Categories: Presentation videos / Qt

Tags:
Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

By continuing to use the site, you agree to the use of cookies. More information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close