I'm trying to use QMetaObject::invokeMethod() in a dynamic library if I do this:


if (QMetaObject::invokeMethod(qApp, "callMe", Qt:irectConnection,
Q_ARG(QString, "Test")))

I could successfully call the method callMe of the QApplication, but if I create a class that extends QApplication addiing another method I cannot call it, as qApp continue to point to the class the does run() I suppose..

One possible soluction would be to use dynamic cast, but I cannot as the library shouldn't know the classes of the main application... there's a way to find the pointer to this class? I've tried to give a name, but I cannot find a method to find an object by name (I can find its children, but he is the "Grand Dad" of all), I've tried to loop on parent, but the recursion stopped... and effectively the QMainWindow has not as parent qApp... I've tried to use setParent() but the compiler doesn't liked it (it said something as QObject is not a QWidget???)...

So how find this object?

I've tried to create a slot and a signal and call emit in my callback... but it says that it doesn't know what is (it wants the header, but this defeat the purpose!).

Ideas? I've no more...

Thanks