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

StackOverflow https://stackoverflow.com/questions/15810220

  •  01-04-2022
  •  | 
  •  

Вопрос

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!

Другие советы

You should be able to use:

obj->metaObject()->className();
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top