| 
    QGIS API Documentation
    3.26.3-Buenos Aires (65e4edfdad)
    
   | 
 
 
 
 
Go to the documentation of this file.
   21 #ifndef QOBJECTUNIQUEPTR_H 
   22 #define QOBJECTUNIQUEPTR_H 
   27 #include <qtypeinfo.h> 
   45     Q_STATIC_ASSERT_X( !std::is_pointer<T>::value, 
"QObjectUniquePtr's template type must not be a pointer type" );
 
   53     struct TypeSelector<const U>
 
   55       typedef const QObject Type;
 
   57     typedef typename TypeSelector<T>::Type QObjectType;
 
   58     QPointer<QObjectType> mPtr;
 
   88       mPtr.swap( other.mPtr );
 
   93       mPtr.assign( 
static_cast<QObjectType *
>( p ) );
 
  102       return static_cast<T *
>( mPtr.data() );
 
  110       return static_cast<T *
>( mPtr.data() );
 
  132     inline operator T *() 
const 
  142       return mPtr.isNull();
 
  150     inline operator bool()
 const 
  152       return !mPtr.isNull();
 
  169       T *p = qobject_cast<T *>( mPtr.data() );
 
  190   return o == p.operator->();
 
  196   return p.operator->() == o;
 
  202   return o == p.operator->();
 
  208   return p.operator->() == o;
 
  214   return p1.operator->() == p2.operator->();
 
  220   return o != p.operator->();
 
  226   return p.operator->() != o;
 
  232   return o != p.operator->();
 
  238   return p.operator->() != o;
 
  244   return p1.operator->() != p2.operator->() ;
 
  251   return QObjectUniquePtr<T>( qobject_cast<T *>( QtSharedPointer::weakPointerFromVariant_internal( variant ).toStrongRef().data() ) );
 
  271     Q_STATIC_ASSERT_X( !std::is_pointer<T>::value, 
"QObjectParentUniquePtr's template object type must not be a pointer type" );
 
  275     QPointer<QObject> mParent;
 
  276     QMetaObject::Connection mParentDestroyedConnection;
 
  306         QObject::disconnect( mParentDestroyedConnection );
 
  324         QObject::disconnect( mParentDestroyedConnection );
 
  326       mParentDestroyedConnection = QObject::connect( parent, &QObject::destroyed, parent, [ = ]()
 
  342       if ( child && !mParent )
 
  344         qWarning() << 
"Assigning pointer to QObjectParentUniquePtr with nullptr parent.";
 
  356       return static_cast<T *
>( mChild );
 
  364       return static_cast<T *
>( mChild );
 
  388     inline operator T *() 
const 
  407     inline operator bool()
 const 
  409       return static_cast< bool >( mChild );
 
  428       T *p = qobject_cast<T *>( mChild );
 
  445         qWarning() << 
"Assigning pointer to QObjectParentUniquePtr with nullptr parent.";
 
  455   return o == p.operator->();
 
  461   return p.operator->() == o;
 
  467   return o == p.operator->();
 
  473   return p.operator->() == o;
 
  479   return p1.operator->() == p2.operator->();
 
  485   return o != p.operator->();
 
  491   return p.operator->() != o;
 
  497   return o != p.operator->();
 
  503   return p.operator->() != o;
 
  509   return p1.operator->() != p2.operator->() ;
 
  513 #endif // QOBJECTUNIQUEPTR_H 
  
T & operator*() const
Dereferences the managed child.
 
void reset(T *p=nullptr)
Will reset the managed pointer to p.
 
void swap(QObjectUniquePtr &other)
Swaps the pointer managed by this instance with the pointer managed by other.
 
void reset(T *p=nullptr)
Will reset the managed pointer to p.
 
void clear()
Clears the pointer.
 
bool operator!=(const T *o, const QObjectUniquePtr< T > &p)
 
void clear()
Clears the pointer.
 
bool operator==(const T *o, const QObjectUniquePtr< T > &p)
 
T * operator->() const
Returns a raw pointer to the managed QObject.
 
QObjectUniquePtr(T *p)
Takes a new QObjectUniquePtr and assigned p to it.
 
T * release()
Clears the pointer and returns it.
 
Keeps a pointer to an object owned by a QObject parent, and deletes it whenever this parent object is...
 
void setParentOwner(QObject *parent)
Sets the parent object.
 
QObjectUniquePtr< T > & operator=(T *p)
 
T * get() const
Returns the raw pointer to the managed child.
 
Keeps a pointer to a QObject and deletes it whenever this object is deleted.
 
~QObjectParentUniquePtr()
Will delete the contained object if the parent still exists.
 
T * operator->() const
Returns a raw pointer to the managed child.
 
T * data() const
Returns the raw pointer to the managed QObject.
 
T * release()
Clears the pointer and returns it.
 
~QObjectUniquePtr()
Will delete the contained QObject if it still exists.
 
T * data() const
Returns the raw pointer to the managed QObject.
 
QObjectUniquePtr< T > QObjectUniquePtrFromVariant(const QVariant &variant)
 
QObjectParentUniquePtr()
Creates a new empty QObjectParentUniquePtr.
 
bool isNull() const
Checks if the managed pointer is nullptr.
 
QObjectParentUniquePtr(T *child, QObject *parent)
Takes a new QObjectParentUniquePtr and assign a child to it.
 
Q_DECLARE_TYPEINFO_BODY(QObjectUniquePtr< T >, Q_MOVABLE_TYPE)
 
T * get() const
Returns the raw pointer to the managed QObject.
 
QObjectUniquePtr()
Creates a new empty QObjectUniquePtr.
 
T & operator*() const
Dereferences the managed QObject.
 
bool isNull() const
Checks if the managed pointer is nullptr.
 
QObjectParentUniquePtr< T > & operator=(T *child)
Assigns a new child to the pointer.