On Wed, Jul 1, 2009 at 1:35 AM, trc<[email protected]> wrote:
> You cannot use dynamic_cast to convert the void pointer pls->dev to a
> QtPLWidget pointer.
>
> The purpose of dynamic_cast is to do a safe (runtime checked) cast
> from a base class to a derived class or vice-versa. As QtPLWidget is
> not derived from void the cast fails.
There is a C-style cast to a QWidget * first. Its result is then
passed to dynamic_cast, which should work in such case (but does not
for some reason; multiple inheritance problems?).
> For your code you have to use C++ reinterpret_cast or a C style cast.
Agreed. I don't see why dynamic_cast should be necessary here. In
any case, 'widget' variable is of type QtPLDriver * and all concrete
types (QtRasterDevice, QtSVGDevice, QtEPSDevice, QtPLWidget) are not
used after the cast. There's also a cryptic comment that I don't
understand "We have to dynamic_cast to make sure the good virtual
functions are called". Everything dynamic_cast can do here is to cut
off all derived types except the specified ones (they would be cast to
NULL, but I don't see why that should be needed).
Am I missing anything about that code?
Dmitri
--
main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
(j){printf("%d\n",i);}}} /*Dmitri Gribenko <[email protected]>*/
------------------------------------------------------------------------------
_______________________________________________
Plplot-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/plplot-devel