简体   繁体   中英

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?

Use the static meta object :

 MyClass::staticMetaObject.className()

Works!

您应该能够使用:

obj->metaObject()->className();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM