January 30, 2012

adam.bogocz adam.bogocz
Lab Rat
19 posts

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

6 replies

January 31, 2012

p-himik p-himik
Lab Rat
263 posts

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.

January 31, 2012

adam.bogocz adam.bogocz
Lab Rat
19 posts

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?

January 31, 2012

p-himik p-himik
Lab Rat
263 posts

It seems that QPluginLoader uses staticMetaObject and Q_DECLARE_INTERFACE creates it for interface. But I’m not sure about it.

January 31, 2012

adam.bogocz adam.bogocz
Lab Rat
19 posts

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?

January 31, 2012

adam.bogocz adam.bogocz
Lab Rat
19 posts

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

February 1, 2012

adam.bogocz adam.bogocz
Lab Rat
19 posts

So adding Interface header into plugins project file as HEADER += solved the problem :)

 
  ‹‹ How to copy a symlink file on Mac?      qobject_cast and Q_DECLARE_INTERFACE ››

You must log in to post a reply. Not a member yet? Register here!