21#ifndef QOBJECTUNIQUEPTR_H 
   22#define QOBJECTUNIQUEPTR_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->() ;
 
 
Keeps a pointer to an object owned by a QObject parent, and deletes it whenever this parent object is...
 
T * data() const
Returns the raw pointer to the managed QObject.
 
T * operator->() const
Returns a raw pointer to the managed child.
 
T & operator*() const
Dereferences the managed child.
 
QObjectParentUniquePtr< T > & operator=(T *child)
Assigns a new child to the pointer.
 
void setParentOwner(QObject *parent)
Sets the parent object.
 
void reset(T *p=nullptr)
Will reset the managed pointer to p.
 
QObjectParentUniquePtr()
Creates a new empty QObjectParentUniquePtr.
 
T * get() const
Returns the raw pointer to the managed child.
 
void clear()
Clears the pointer.
 
bool isNull() const
Checks if the managed pointer is nullptr.
 
T * release()
Clears the pointer and returns it.
 
~QObjectParentUniquePtr()
Will delete the contained object if the parent still exists.
 
QObjectParentUniquePtr(T *child, QObject *parent)
Takes a new QObjectParentUniquePtr and assign a child to it.
 
Keeps a pointer to a QObject and deletes it whenever this object is deleted.
 
QObjectUniquePtr< T > & operator=(T *p)
 
void reset(T *p=nullptr)
Will reset the managed pointer to p.
 
bool isNull() const
Checks if the managed pointer is nullptr.
 
T & operator*() const
Dereferences the managed QObject.
 
QObjectUniquePtr()
Creates a new empty QObjectUniquePtr.
 
~QObjectUniquePtr()
Will delete the contained QObject if it still exists.
 
QObjectUniquePtr(T *p)
Takes a new QObjectUniquePtr and assigned p to it.
 
T * release()
Clears the pointer and returns it.
 
T * get() const
Returns the raw pointer to the managed QObject.
 
void swap(QObjectUniquePtr &other)
Swaps the pointer managed by this instance with the pointer managed by other.
 
T * data() const
Returns the raw pointer to the managed QObject.
 
T * operator->() const
Returns a raw pointer to the managed QObject.
 
void clear()
Clears the pointer.
 
bool operator==(const T *o, const QObjectUniquePtr< T > &p)
 
Q_DECLARE_TYPEINFO_BODY(QObjectUniquePtr< T >, Q_MOVABLE_TYPE)
 
bool operator!=(const T *o, const QObjectUniquePtr< T > &p)
 
QObjectUniquePtr< T > QObjectUniquePtrFromVariant(const QVariant &variant)