Qt World Summit: Submit your Presentation

[solved]Is it safe to store QMetaObject for later use ?

  • Hi,

    I wonder if it is safe to store a QMetaObject struct returned from staticMetaObjec from a Template type: QMetaObject metaObject=reinterpret_cast<T>(0)->staticMetaObject;
    I want to safe the QMetaObject for later use. It works but I am not sure if this is ok.

    Thanks Jochen

  • QMetaObject is a static member for each meta object, it is always there and isn't going anywhere. You can get a pointer to it or the static instance itself at any point, why would you even need to store it for later use?

  • hi,

    thanks for the answer. Iam making a Inversion of Control Container/Dependency Injection Container for QObjects. You can register classes using a template method and resolve it later to an object. I have to save the QMetaobject for the class type to call the Ctor for this class later.


Log in to reply