Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c++

qt

metaobject

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?

like image 614
Marc Avatar asked Apr 04 '13 11:04

Marc


2 Answers

Use the static meta object:

 MyClass::staticMetaObject.className()

Works!

like image 84
BeniBela Avatar answered Sep 20 '22 20:09

BeniBela


You should be able to use:

obj->metaObject()->className();
like image 25
Hans Avatar answered Sep 19 '22 20:09

Hans