21 #ifndef QOBJECTUNIQUEPTR_H 
   22 #define QOBJECTUNIQUEPTR_H 
   27 #include <qtypeinfo.h> 
   42     Q_STATIC_ASSERT_X( !std::is_pointer<T>::value, 
"QObjectUniquePtr's template type must not be a pointer type" );
 
   50     struct TypeSelector<const U>
 
   52       typedef const QObject Type;
 
   54     typedef typename TypeSelector<T>::Type QObjectType;
 
   55     QPointer<QObjectType> mPtr;
 
   85       mPtr.swap( other.mPtr );
 
   90       mPtr.assign( 
static_cast<QObjectType *
>( p ) );
 
   99       return static_cast<T *
>( mPtr.data() );
 
  107       return static_cast<T *
>( mPtr.data() );
 
  129     inline operator T *() 
const 
  139       return mPtr.isNull();
 
  147     inline operator bool()
 const 
  149       return !mPtr.isNull();
 
  166       T *p = qobject_cast<T *>( mPtr.data() );
 
  187   return o == p.operator->();
 
  193   return p.operator->() == o;
 
  199   return o == p.operator->();
 
  205   return p.operator->() == o;
 
  211   return p1.operator->() == p2.operator->();
 
  217   return o != p.operator->();
 
  223   return p.operator->() != o;
 
  229   return o != p.operator->();
 
  235   return p.operator->() != o;
 
  241   return p1.operator->() != p2.operator->() ;
 
  248   return QObjectUniquePtr<T>( qobject_cast<T *>( QtSharedPointer::weakPointerFromVariant_internal( variant ).toStrongRef().data() ) );
 
Keeps a pointer to a QObject and deletes it whenever this object is deleted.
T * release()
Clears the pointer and returns it.
void reset(T *p=nullptr)
Will reset the managed pointer to p.
bool isNull() const
Checks if the managed pointer is nullptr.
T * data() const
Returns the raw pointer to the managed QObject.
QObjectUniquePtr()
Creates a new empty QObjectUniquePtr.
~QObjectUniquePtr()
Will delete the contained QObject if it still exists.
QObjectUniquePtr< T > & operator=(T *p)
T * get() const
Returns the raw pointer to the managed QObject.
T & operator*() const
Dereferences the managed QObject.
QObjectUniquePtr(T *p)
Takes a new QObjectUniquePtr and assigned p to it.
T * operator->() const
Returns a raw pointer to the managed QObject.
void swap(QObjectUniquePtr &other)
Swaps the pointer managed by this instance with the pointer managed by other.
void clear()
Clears the pointer.
QObjectUniquePtr< T > QObjectUniquePtrFromVariant(const QVariant &variant)
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)