CopperSpice API
1.9.2
|
Base class which provides a QSharedPointer for an existing object. More...
Public Methods | |
QSharedPointer< T > | sharedFromThis () |
QSharedPointer< const T > | sharedFromThis () const |
QEnableSharedFromThis is a base class which provides a mechanism for obtaining a QSharedPointer to the current object.
This class supports retrieving a valid QSharedPointer to this. In C++ "this" is a keyword which evaluates to a raw pointer whose value refers to the current object. If you construct a shared pointer by using the "this" raw pointer the shared pointer will assume responsibilitiy and ownership for the current object. In most cases this will lead to undefined behavior.
To use this class your class must inherit from QEnableSharedFromThis and pass the name of your class as a template parameter.
QSharedPointer< T > QEnableSharedFromThis< T >::sharedFromThis | ( | ) |
Returns a shared pointer which points to the current object, otherwise this method returns a null pointer.
QSharedPointer< const T > QEnableSharedFromThis< T >::sharedFromThis | ( | ) | const |
Equivalent to calling sharedFromThis(), used when the T is const.