Is there a way to enumerate all QObject classes declared in an application or DLL? I am trying to create an application that loads DLLs and lists all QObject classes inside the DLLs.
Update: Actually I am trying to create a Unit Test GUI. It will load DLLs, instantiate the QObject inside, and call QTest::qExec against them.
If the program code is not stripped you can get some instrospection by reading the binary:
objdump -demangle=C++ -t SomeQtLibrary.so |grep qt_static_metacallit shows roughly the QObject derived classes. I think they all implement this symbol. Of couse since you are on Windows you would have to use Windows tools such asnm(correct me if I am wrong). Naturally processing the symbols in-code is also possible, but this is a separate topic.The command I mentioned returns this for example:
If you are interested in run-time introspection than you would have to play with the QMetaObject class on each object.
For objects that were registered as QMetaType (and only those!) you can do some additional magic to bring them to life. Not very easy, and not out of the box – but it is still hell of a lot from such a static language. Here is a snippet from Qt docs (changed
if(id == 0)toif(id)).