Den 18-06-2014 15:20, Etienne Sandré-Chardonnal skrev: > Hi, > > I would like to implement a plugin system in my app and I'm totally > ignorant of dynamic library mechanisms. So I'm trying with a QPlugin. > I'm using Qt 4.8.5, gcc 4.8.0 mingw64. > > The question is : can RTTI work between the plugin and the app? > > I will define and include these headers in both the app and the plugin: > > - A base class Base which will be pure virtual > - A few DerivedA, DerivedB classes which will be pure virtual, too. > > Then the plugin will derive from one of the DerivedX classes, and > provide a method in the interface which will list its implemented > derived class names as strings, and provide a factory for them returning > Base* objects. > > Then, the app will dynamic_cast these pointers to DerivedA, DerivedB, etc... > > Will the dynamic_cast work? Is there a special way to export/declare > things for that?
Hi Etienne, Yes, you can do this. If Base is a pure interface, you can just put it in a shared header file and do the case. But if there is more to it, you have to put it in a shared library and link both the plugin and the application to it. You can use a static library, but then stuff like singletons won't work reliably. Bo. -- Viking Software Qt and C++ developers for hire http://www.vikingsoft.eu _______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest