![]() |
CopperSpice API
1.8.1
|
This is abase class which provide a QSharedPointer for an existing object. More...
Public Methods | |
QSharedPointer< T > | sharedFromThis () |
QSharedPointer< const T > | sharedFromThis () const |
Friends | |
template<class X > | |
class | QSharedPointer |
A base class which allows obtaining a QSharedPointer for an object already managed by a shared pointer. You can inherit this class when you need to create a QSharedPointer from any instance of a class. For example, from within the object itself.
Returning QSharedPointer<T>(this) will not work because this creates multiple distinct QSharedPointer objects with separate reference counts. For this reason you must never create more than one QSharedPointer from the same raw pointer. QEnableSharedFromThis defines two member functions called sharedFromThis() that return a QSharedPointer<T> and QSharedPointer<const T>, depending on constness.
It is also possible to get a shared pointer from an object outside of the class itself. This is especially useful in code which provides an interface to scripts, where it is currently not possible to use shared pointers.
|
inline |
If this is being managed by a QSharedPointer, returns a shared pointer instance pointing to this otherwise returns a QSharedPointer holding a null pointer.
|
inline |
The const version of sharedFromThis().