[Qt-interest] Re : Problem with dynamic_cast

BOUCARD Olivier boucard_olivier at yahoo.fr
Thu Sep 22 13:08:01 CEST 2011


I have made an error in my previous mail.
First when I talk about type, I am talking about pointer to type.
Second, objects of type AC* and AD* are stored in an object of type A*. So basically, I try to cast from A* to C* and A* to D*.



>________________________________
>De : BOUCARD Olivier <boucard_olivier at yahoo.fr>
>À : Qt-interest Nokia <qt-interest at qt.nokia.com>
>Envoyé le : Jeudi 22 Septembre 2011 12h46
>Objet : [Qt-interest] Problem with dynamic_cast
>
>
>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.
>
>_______________________________________________
>Qt-interest mailing list
>Qt-interest at qt.nokia.com
>http://lists.qt.nokia.com/mailman/listinfo/qt-interest
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110922/07eb7c52/attachment.html 


More information about the Qt-interest-old mailing list