[Qgis-developer] not able to downCast to Custom class

nitin quick quick.nitin at gmail.com
Tue Nov 14 07:57:52 EST 2006


thanks martin,
ya static_cast<> did provide some comfort. I will search more in this
field. Currently i am not bothered about optimization but later  i
will.
Also i am not creating a library. What made you feel i am creating
library or u were refring to library created for my plugin.
regards
quickNitin

On 11/14/06, Martin Dobias <wonder.sk at gmail.com> wrote:
> On 11/14/06, nitin quick <quick.nitin at gmail.com> wrote:
> > Since on collision i am getting a list of Q3CanvasItem objects, i need
> > to downCast it to my class MyMapCanvasItem, but it returns null. I am
> > using dynamic_cast for that. This cast is happening perfectly for
> > QgsMapCanvasItem. Is there any way, i can avoid downcast  in such
> > scenarion???Also, is this way of doing peration is correct, as it look
> > to me since i have no control over QgsMapCanvasItem.
>
> If rtti() of your canvas item is correct, it should be safe to use
> static_cast instead of dynamic_cast (which is also much slower).
> However I don't know what's the reason why dynamic_cast doesn't work,
> but it may be caused with the fact that you're creating a library...
>
> Martin
>



More information about the Qgis-developer mailing list