![]() |
Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
|
\inmodule QtCore More...
#include <qsharedpointer_impl.h>
Public Member Functions | |
QSharedPointer< T > | sharedFromThis () |
QSharedPointer< const T > | sharedFromThis () const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. |
Protected Member Functions | |
QEnableSharedFromThis ()=default | |
QEnableSharedFromThis (const QEnableSharedFromThis &) | |
QEnableSharedFromThis & | operator= (const QEnableSharedFromThis &) |
Friends | |
template<class X> | |
class | QSharedPointer |
\inmodule QtCore
A base class that 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 instance, from within the object itself. The key point is that the technique of just returning QSharedPointer<T>(this) cannot be used, because this winds up creating 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, to this:
It is also possible to get a shared pointer from an object outside of the class itself. This is especially useful in code that provides an interface to scripts, where it is currently not possible to use shared pointers. For example:
Definition at line 819 of file qsharedpointer_impl.h.
|
protecteddefault |
|
inlineprotected |
Definition at line 823 of file qsharedpointer_impl.h.
|
inlineprotected |
Definition at line 824 of file qsharedpointer_impl.h.
|
inline |
If this
(that is, the subclass instance invoking this method) is being managed by a QSharedPointer, returns a shared pointer instance pointing to this
; otherwise returns a null QSharedPointer.
Definition at line 827 of file qsharedpointer_impl.h.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Const overload of sharedFromThis().
Definition at line 828 of file qsharedpointer_impl.h.
Definition at line 831 of file qsharedpointer_impl.h.