Is it possible to use Qt plugins - loaded via QPluginLoader - from QtScript side? How?
I’m currently writing a Qt application for Windows which uses QPluginLoader to load different plugins (DLLs). These plugins have a generic interface (for plugin name, version etc.) and an extended interface for plugin specific funtions (i.e. one plugin to draw something, one to send something via network or play audio samples etc.). As you can see, these extended functions are completely different from plugin to plugin and can’t be combined in a single interface. I implemented this as described in http://doc.qt.nokia.com/4.6/tools-plugandpaint.html and it’s working without problems. By using for example
BrushInterface *iBrush = qobject_cast<BrushInterface *>(plugin);
I can access any extended plugin function from C++ side.
But now I want to call these extended functions (provided by the plugins) using the QtScriptEngine in my application. So I want to call for example
from within QtScript. The problem is, that iBrush is a pointer of type BrushInterface and doesn’t inherit QObject. If I try to call it, the QtScript environment throws an exception. I tried to derive these interfaces from QObject (so that it’s possible to introspect these plugin objects), but that throws a compiler error (in the Qt plugin example above all these interfaces are NOT derived from QObject as well).
So, my question is: How can I use all of the functions of the plugins (loaded via QPluginLoader) from the QtScript side? I don’t want to copy all the function pointers of the plugins to a QObject derived class. This would be possible, I think, but I don’t like the solution.
Is this implemented the correct way at all? Do I have to use the QScriptExtensionPlugin class for my aim (although it doesn’t look like, what I wanted to do)? Or do I have to register my interface via qScriptRegisterMetaType?
Can you please give me a hint to this issue!? I don’t need the complete solution for that, just a direction sign to know where I should look!
Thank you very much!
I am not too sure about the solution in Qt but having used Eclipse Plug in Development for some time what I feel is we need to have an ADAPTER that can adapt your QtScriptPlugin with QObject.
To get the Adapter we need to explore what you mention in registering mechanism. Do let know where did u find the fix.