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

Martin Dobias wonder.sk at gmail.com
Tue Nov 14 06:48:36 EST 2006


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