In this post, we will see how to resolve cannot convert argument 1 from ‘std::shared_ptr<QtNodes::DataFlowGraphicsScene>’ to ‘QtNodes::BasicGraphicsScene *’
Question:
How do I pass my object pointer while also updating the reference counter.
Best Answer:
You don’t.You have two options to keep the object alive while the consumer is processing it:
The caller takes care that the object stays around long enough.
The consumer accepts a
std::shared_ptr
instead of a raw pointer.
In a case where the first option is not simple to achieve and there is already a
std::shared_ptr
, the second option is clearly preferred.If you have better answer, please add a comment about this, thank you!
Source: Stackoverflow.com
Leave a Review