QGIS API Documentation  3.22.4-Białowieża (ce8e65e95e)
Classes | Public Member Functions | List of all members
QObjectUniquePtr< T > Class Template Reference

Keeps a pointer to a QObject and deletes it whenever this object is deleted. More...

#include <qobjectuniqueptr.h>

Public Member Functions

 QObjectUniquePtr ()
 Creates a new empty QObjectUniquePtr. More...
 
 QObjectUniquePtr (T *p)
 Takes a new QObjectUniquePtr and assigned p to it. More...
 
 ~QObjectUniquePtr ()
 Will delete the contained QObject if it still exists. More...
 
void clear ()
 Clears the pointer. More...
 
T * data () const
 Returns the raw pointer to the managed QObject. More...
 
T * get () const
 Returns the raw pointer to the managed QObject. More...
 
bool isNull () const
 Checks if the managed pointer is nullptr. More...
 
 operator bool () const
 Checks if the pointer managed by this object is nullptr. More...
 
 operator T* () const
 Const getter for the managed raw pointer. More...
 
T & operator* () const
 Dereferences the managed QObject. More...
 
T * operator-> () const
 Returns a raw pointer to the managed QObject. More...
 
QObjectUniquePtr< T > & operator= (T *p)
 
T * release ()
 Clears the pointer and returns it. More...
 
void reset (T *p=nullptr)
 Will reset the managed pointer to p. More...
 
void swap (QObjectUniquePtr &other)
 Swaps the pointer managed by this instance with the pointer managed by other. More...
 

Detailed Description

template<class T>
class QObjectUniquePtr< T >

Keeps a pointer to a QObject and deletes it whenever this object is deleted.

It keeps a weak pointer to the QObject internally and will be set to nullptr whenever the QObject is deleted.

Since
QGIS 3.8

Definition at line 40 of file qobjectuniqueptr.h.

Constructor & Destructor Documentation

◆ QObjectUniquePtr() [1/2]

template<class T >
QObjectUniquePtr< T >::QObjectUniquePtr ( )
inline

Creates a new empty QObjectUniquePtr.

Definition at line 61 of file qobjectuniqueptr.h.

◆ QObjectUniquePtr() [2/2]

template<class T >
QObjectUniquePtr< T >::QObjectUniquePtr ( T *  p)
inline

Takes a new QObjectUniquePtr and assigned p to it.

Definition at line 67 of file qobjectuniqueptr.h.

◆ ~QObjectUniquePtr()

template<class T >
QObjectUniquePtr< T >::~QObjectUniquePtr ( )
inline

Will delete the contained QObject if it still exists.

Definition at line 74 of file qobjectuniqueptr.h.

Member Function Documentation

◆ clear()

template<class T >
void QObjectUniquePtr< T >::clear ( )
inline

Clears the pointer.

The managed object is set to nullptr and will not be deleted.

Definition at line 155 of file qobjectuniqueptr.h.

◆ data()

template<class T >
T* QObjectUniquePtr< T >::data ( ) const
inline

Returns the raw pointer to the managed QObject.

Definition at line 97 of file qobjectuniqueptr.h.

◆ get()

template<class T >
T* QObjectUniquePtr< T >::get ( ) const
inline

Returns the raw pointer to the managed QObject.

Definition at line 105 of file qobjectuniqueptr.h.

◆ isNull()

template<class T >
bool QObjectUniquePtr< T >::isNull ( ) const
inline

Checks if the managed pointer is nullptr.

Definition at line 137 of file qobjectuniqueptr.h.

◆ operator bool()

template<class T >
QObjectUniquePtr< T >::operator bool ( ) const
inline

Checks if the pointer managed by this object is nullptr.

If it is not nullptr true will be returned, if it is nullptr false will be returned.

Definition at line 147 of file qobjectuniqueptr.h.

◆ operator T*()

template<class T >
QObjectUniquePtr< T >::operator T* ( ) const
inline

Const getter for the managed raw pointer.

Definition at line 129 of file qobjectuniqueptr.h.

◆ operator*()

template<class T >
T& QObjectUniquePtr< T >::operator* ( ) const
inline

Dereferences the managed QObject.

Definition at line 121 of file qobjectuniqueptr.h.

◆ operator->()

template<class T >
T* QObjectUniquePtr< T >::operator-> ( ) const
inline

Returns a raw pointer to the managed QObject.

Definition at line 113 of file qobjectuniqueptr.h.

◆ operator=()

template<class T >
QObjectUniquePtr<T>& QObjectUniquePtr< T >::operator= ( T *  p)
inline

Definition at line 88 of file qobjectuniqueptr.h.

◆ release()

template<class T >
T* QObjectUniquePtr< T >::release ( )
inline

Clears the pointer and returns it.

The managed object will not be deleted and it is the callers responsibility to guarantee that no memory is leaked.

Definition at line 164 of file qobjectuniqueptr.h.

◆ reset()

template<class T >
void QObjectUniquePtr< T >::reset ( T *  p = nullptr)
inline

Will reset the managed pointer to p.

If there is already a QObject managed currently it will be deleted. If p is not specified the managed QObject will be deleted and this object reset to nullptr.

Definition at line 176 of file qobjectuniqueptr.h.

◆ swap()

template<class T >
void QObjectUniquePtr< T >::swap ( QObjectUniquePtr< T > &  other)
inline

Swaps the pointer managed by this instance with the pointer managed by other.

Definition at line 83 of file qobjectuniqueptr.h.


The documentation for this class was generated from the following file: