PDA

View Full Version : SOLVED: error using qobject_cast against instance of a plugin



QPlace
12th November 2009, 18:47
The problem was that Q_DECLARE_INTERFACE should be used in the same header where interface is declared.

I have a plugin that I can successfully load, i.e. instance() returned by pluginloader is not null and I can see that the plugin class instantiates successfully under debugger. However, I can't compile the casting of returned QObject* to my interface.

For this line:

tit::testdata::ITestData* fd = qobject_cast< tit::testdata::ITestData*> (loader.instance());

compiler returns the error:

error C2039: 'staticMetaObject' : is not a member of 'tit::testdata::ITestData'

According to the doc example interface classes do not have any reference to Qt. (like FilterInterface in <QT>/doc/html/plugins-howto.html#the-lower-level-api-extending-qt-applications ).

my interface declarations are:
header:

using namespace tit::testdata;
Q_DECLARE_INTERFACE(ITestData, "tit.testdata/1.0")

source:
Q_EXPORT_PLUGIN2("myplugin", CTestData)

CTestData implements ITestData

What am I doing wrong?