21#ifndef QOBJECTUNIQUEPTR_H 
   22#define QOBJECTUNIQUEPTR_H 
   46    Q_STATIC_ASSERT_X( !std::is_pointer<T>::value, 
"QObjectUniquePtr's template type must not be a pointer type" );
 
   54    struct TypeSelector<const U>
 
   56      typedef const QObject Type;
 
   58    typedef typename TypeSelector<T>::Type QObjectType;
 
   59    QPointer<QObjectType> mPtr;
 
   89      mPtr.swap( other.mPtr );
 
 
   94      mPtr.assign( 
static_cast<QObjectType *
>( p ) );
 
 
  103      return static_cast<T *
>( mPtr.data() );
 
 
  111      return static_cast<T *
>( mPtr.data() );
 
 
  133    inline operator T *() 
const 
 
  143      return mPtr.isNull();
 
 
  151    explicit inline operator bool()
 const 
  153      return !mPtr.isNull();
 
 
  170      T *p = qobject_cast<T *>( mPtr.data() );
 
 
 
  191  return o == p.operator->();
 
 
  197  return p.operator->() == o;
 
 
  203  return o == p.operator->();
 
 
  209  return p.operator->() == o;
 
 
  215  return p1.operator->() == p2.operator->();
 
 
  221  return o != p.operator->();
 
 
  227  return p.operator->() != o;
 
 
  233  return o != p.operator->();
 
 
  239  return p.operator->() != o;
 
 
  245  return p1.operator->() != p2.operator->() ;
 
 
  252  return QObjectUniquePtr<T>( qobject_cast<T *>( QtSharedPointer::weakPointerFromVariant_internal( variant ).toStrongRef().data() ) );
 
 
  272    Q_STATIC_ASSERT_X( !std::is_pointer<T>::value, 
"QObjectParentUniquePtr's template object type must not be a pointer type" );
 
  276    QPointer<QObject> mParent;
 
  277    QMetaObject::Connection mParentDestroyedConnection;
 
  307        QObject::disconnect( mParentDestroyedConnection );
 
 
  325        QObject::disconnect( mParentDestroyedConnection );
 
  327      mParentDestroyedConnection = QObject::connect( parent, &QObject::destroyed, parent, [ = ]()
 
 
  343      if ( child && !mParent )
 
  345        qWarning() << 
"Assigning pointer to QObjectParentUniquePtr with nullptr parent.";
 
 
  357      return static_cast<T *
>( mChild );
 
 
  365      return static_cast<T *
>( mChild );
 
 
  389    inline operator T *() 
const 
 
  408    explicit inline operator bool()
 const 
  410      return static_cast< bool >( mChild );
 
 
  429      T *p = qobject_cast<T *>( mChild );
 
 
  446        qWarning() << 
"Assigning pointer to QObjectParentUniquePtr with nullptr parent.";
 
 
 
  456  return o == p.operator->();
 
 
  462  return p.operator->() == o;
 
 
  468  return o == p.operator->();
 
 
  474  return p.operator->() == o;
 
 
  480  return p1.operator->() == p2.operator->();
 
 
  486  return o != p.operator->();
 
 
  492  return p.operator->() != o;
 
 
  498  return o != p.operator->();
 
 
  504  return p.operator->() != o;
 
 
  510  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)