I currently have something like this:
QSharedPointer<t> Qsharedfoo;
Now I have a raw pointer to foo as well called rawfoo
. How can I make foo point own the raw pointer and start pointing to it. I know in boost with shared pointers we could use boost::make_shared
how do we do it with QSharedPointer
?
I want to do something like this:
Qsharedfoo = rawfoo
Straight from the Qt documentation, we have something like this:
QSharedPointer<MyObject> obj = QSharedPointer<MyObject>(new MyObject);
You can basically pass your pointer in the same fashion:
// Here I assume that T is the class you're using for Qsharedfoo.
QSharedPointer<T> Qsharedfoo = QSharedPointer<T>(rawfoo);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With