[Qt-interest] Problem with dynamic_cast

BOUCARD Olivier boucard_olivier at yahoo.fr
Thu Sep 22 12:46:20 CEST 2011


Hi all,

Well, it is not a Qt problem, I think, it is more a C++ problem, so I hope someone can help.
I am in  a quite complicate case, I will try to explain as simpler as I could.
First, there is 3 binaries:
	* A classic shared library with a particular abstract class A based on QObject, an interface B for the Qt plugin architecture, and some basic C++ classes C and D.

	* A plugin library based on interface B which allow to instanciate implementation of class A:
	* Class AC which inherit from A and C
	* Class AD which inherit from A and D
	* An executable, based on QCoreApplication, which load the plugin and instanciate an object of type AC and an object of type AD.Ok, now comes the trouble. I try to dynamic_cast object AC and AD to an object of, respectively, type C and D (Note: I can't use qobject_cast because C and D are basic classes, so no QObject).
The problem is in one case it works, let say for C, but in the other case the dynamic_cast return NULL.

I don't see my error. Basically C and D are quite the same. Except C have a pure virtual method and not D. But I try to add a pure virtual method to D and it has changed nothing.

Any clue? Need more information?

Thank you for your answers.

Olivier.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110922/6bdee870/attachment.html 


More information about the Qt-interest-old mailing list