[Qt-interest] QMetaObject::newInstance and plugins

Stephen D'Angelo SDAngelo at evertz.com
Wed Aug 4 19:32:28 CEST 2010


Hello all,

I have a plugin interface that returns a QMetaObject of a class that inherits from QObject (SomeClass).  With this QMetaObject, I call newInstance to create an instance of its QObject.  When I then call qobject_cast<SomeClass *> to cast this QObject to SomeClass, it always returns 0.

However, the following works fine from within the main program (i.e. not getting the QMetaObject from the plugin):
qobject_cast<SomeClass*>(SomeClass::staticMetaObject.newInstance());

Could it be an issue with the fact that SomeClass is compiled into both the main program and the plugin?  Should it be pulled out to a separate library?

Any ideas?

I will post the code if that would help, but I'm thinking that what I'm trying to do may not be possible.

Thanks,
 - Steve




More information about the Qt-interest-old mailing list