QObject factory in Qt Plugin(non-creator)
-
Hi All,
I have desribed my problem here http://stackoverflow.com/q/9070817/538239 .. I apreciate your help.. I am out of ideas...Thanks,
Adam -
Are you sure that you've red QPluginLoader documentation carefully? Maybe I did not understand you correctly but QPluginLoader::instance() returns QObject* so there is no need to create multiple interfaces. To avoid linking errors just declare signals and slots in your ProtocolInterface (which is not actually an interface since it inherits QObject) as pure virtual.
-
Thanks for reply. The problem is that after I remove Q_DECLARE_INTERFACE from ProtocolInterface class and Q_INTERFACES id deriving class I got "libdummyplugin.so: undefined symbol: _ZN17ProtocolInterface16staticMetaObjectE)" :( ... the error is printed during plugin loading. Any ideas?
-
It seems that QPluginLoader uses staticMetaObject and Q_DECLARE_INTERFACE creates it for interface. But I'm not sure about it.
-
IMHO it is caused by MOC, because DummyProtocolInterface is not directly inheriting QObject and the compiler is not MOCing that class because it expects metaObject in ProtocolInterface located in daemon project... I am not sure if it could even work like this, sice ProtocolInterface.h has not-defined virtual functions(and there is probably no compilation -> no MOC ) ?? What do you say?
-
My colleague has probably found the root cause... it should be in the project file of the plugin... header of ProtocolInterface should be included via HEADERS not via INCLUDEPATH :) .. it will check it when I came home
-
So adding Interface header into plugins project file as HEADER += solved the problem :)