c++qtmetaobject

Is there a way of getting the classname of a QObject derived class without creating an instantiation of that class?


I'm looking for something like this:

MyClass::metaObject()->className()

which doesn't work because at the point where this code is executed, there exists no instantiation of MyClass.

If this is somehow possible, is there a way of getting all names of the classes that have been derived from MyClass?


Solution

  • Use the static meta object:

     MyClass::staticMetaObject.className()
    

    Works!