How do I do a dynamic_cast on a QSharedDataPointer?
Unsolved
General and Desktop
-
Based on the suggestions on my last post, I have started using QSharedDataPointers instead of QList<Class*>, but this has brought up a new problem while trying to dynamic_cast data to this type.
I have a
QList<QGraphicsItem*>::iterator itr
Layer* l = dynamic_cast<Layer*>(*itr);
I am trying to do something like:
Layer::LayerPointer l = dynamic_cast<Layer::LayerPointer>(*itr);
LayerPointer
has been defined here:typedef QSharedDataPointer<Layer> LayerPointer;
For obvious reasons I am getting a "Cannot dynamic_cast... target is not pointer or reference"
-
Hi
you can use
http://doc.qt.io/qt-5/qshareddatapointer.html#data
http://doc.qt.io/qt-5/qshareddatapointer.html#constData
to get type T ( the actual pointer )
( there might be better way)
Im wondering however if dynamic_cast is right to use and not
qgraphicsitem_cast ?