[][src]Struct qt_qml::QPointerOfQObject

#[repr(C)]pub struct QPointerOfQObject { /* fields omitted */ }

The QPointer class is a template class that provides guarded pointers to QObject.

C++ class: QPointer<QObject>.

C++ documentation:

The QPointer class is a template class that provides guarded pointers to QObject.

A guarded pointer, QPointer<T>, behaves like a normal C++ pointer T *, except that it is automatically set to 0 when the referenced object is destroyed (unlike normal C++ pointers, which become "dangling pointers" in such cases). T must be a subclass of QObject.

Guarded pointers are useful whenever you need to store a pointer to a QObject that is owned by someone else, and therefore might be destroyed while you still hold a reference to it. You can safely test the pointer for validity.

Note that Qt 5 introduces a slight change in behavior when using QPointer.

  • When using QPointer on a QWidget (or a subclass of QWidget), previously the QPointer would be cleared by the QWidget destructor. Now, the QPointer is cleared by the QObject destructor (since this is when QWeakPointer objects are cleared). Any QPointers tracking a widget will NOT be cleared before the QWidget destructor destroys the children for the widget being tracked.

Qt also provides QSharedPointer, an implementation of a reference-counted shared pointer object, which can be used to maintain a collection of references to an individual pointer.

Example:

QPointer<QLabel> label = new QLabel; label->setText("&Status:"); ... if (label) label->show();

If the QLabel is deleted in the meantime, the label variable will hold 0 instead of an invalid address, and the last line will never be executed.

The functions and operators available with a QPointer are the same as those available with a normal unguarded pointer, except the pointer arithmetic operators (+, -, ++, and --), which are normally used only with arrays of objects.

Use QPointers like normal pointers and you will not need to read this class documentation.

For creating guarded pointers, you can construct or assign to them from a T* or from another guarded pointer of the same type. You can compare them with each other using operator==() and operator!=(), or test for 0 with isNull(). You can dereference them using either the *x or the x->member notation.

A guarded pointer will automatically cast to a T *, so you can freely mix guarded and unguarded pointers. This means that if you have a QPointer<QWidget>, you can pass it to a function that requires a QWidget *. For this reason, it is of little value to declare functions to take a QPointer as a parameter; just use normal pointers. Use a QPointer when you are storing a pointer over time.

Note that class T must inherit QObject, or a compilation or link error will result.

Methods

impl QPointerOfQObject[src]

pub unsafe fn clear(&self)[src]

Clears this QPointer object.

Calls C++ function: void QPointer<QObject>::clear().

C++ documentation:

Clears this QPointer object.

This function was introduced in Qt 5.0.

See also isNull().

pub unsafe fn copy_from_q_object(
    &self,
    p: impl CastInto<Ptr<QObject>>
) -> Ref<QPointerOfQObject>
[src]

Assignment operator. This guarded pointer will now point to the same object that p points to.

Calls C++ function: QPointer<QObject>& QPointer<QObject>::operator=(QObject* p).

C++ documentation:

Assignment operator. This guarded pointer will now point to the same object that p points to.

pub unsafe fn copy_from_q_pointer_of_q_object(
    &self,
    other: impl CastInto<Ref<QPointerOfQObject>>
) -> Ref<QPointerOfQObject>
[src]

The QPointer class is a template class that provides guarded pointers to QObject.

Calls C++ function: QPointer<QObject>& QPointer<QObject>::operator=(const QPointer<QObject>& other).

C++ documentation:

The QPointer class is a template class that provides guarded pointers to QObject.

A guarded pointer, QPointer<T>, behaves like a normal C++ pointer T *, except that it is automatically set to 0 when the referenced object is destroyed (unlike normal C++ pointers, which become "dangling pointers" in such cases). T must be a subclass of QObject.

Guarded pointers are useful whenever you need to store a pointer to a QObject that is owned by someone else, and therefore might be destroyed while you still hold a reference to it. You can safely test the pointer for validity.

Note that Qt 5 introduces a slight change in behavior when using QPointer.

  • When using QPointer on a QWidget (or a subclass of QWidget), previously the QPointer would be cleared by the QWidget destructor. Now, the QPointer is cleared by the QObject destructor (since this is when QWeakPointer objects are cleared). Any QPointers tracking a widget will NOT be cleared before the QWidget destructor destroys the children for the widget being tracked.

Qt also provides QSharedPointer, an implementation of a reference-counted shared pointer object, which can be used to maintain a collection of references to an individual pointer.

Example:

QPointer<QLabel> label = new QLabel; label->setText("&Status:"); ... if (label) label->show();

If the QLabel is deleted in the meantime, the label variable will hold 0 instead of an invalid address, and the last line will never be executed.

The functions and operators available with a QPointer are the same as those available with a normal unguarded pointer, except the pointer arithmetic operators (+, -, ++, and --), which are normally used only with arrays of objects.

Use QPointers like normal pointers and you will not need to read this class documentation.

For creating guarded pointers, you can construct or assign to them from a T* or from another guarded pointer of the same type. You can compare them with each other using operator==() and operator!=(), or test for 0 with isNull(). You can dereference them using either the *x or the x->member notation.

A guarded pointer will automatically cast to a T *, so you can freely mix guarded and unguarded pointers. This means that if you have a QPointer<QWidget>, you can pass it to a function that requires a QWidget *. For this reason, it is of little value to declare functions to take a QPointer as a parameter; just use normal pointers. Use a QPointer when you are storing a pointer over time.

Note that class T must inherit QObject, or a compilation or link error will result.

pub unsafe fn data(&self) -> QPtr<QObject>[src]

Returns the pointer to the object being guarded.

Calls C++ function: QObject* QPointer<QObject>::data() const.

C++ documentation:

Returns the pointer to the object being guarded.

This function was introduced in Qt 4.4.

pub unsafe fn eq(&self, o: impl CastInto<Ptr<QObject>>) -> bool[src]

Returns true if c1 and c2 are the same Unicode character; otherwise returns false.

Calls C++ function: bool operator==(const QPointer<QObject>& p, QObject* o).

Warning: no exact match found in C++ documentation. Below is the C++ documentation for bool operator==(QChar c1, QChar c2):

Returns true if c1 and c2 are the same Unicode character; otherwise returns false.

pub unsafe fn indirection(&self) -> Ref<QObject>[src]

Dereference operator; implements pointer semantics. Just use this operator as you would with a normal C++ pointer.

Calls C++ function: QObject& QPointer<QObject>::operator*() const.

C++ documentation:

Dereference operator; implements pointer semantics. Just use this operator as you would with a normal C++ pointer.

pub unsafe fn is_null(&self) -> bool[src]

Returns true if the referenced object has been destroyed or if there is no referenced object; otherwise returns false.

Calls C++ function: bool QPointer<QObject>::isNull() const.

C++ documentation:

Returns true if the referenced object has been destroyed or if there is no referenced object; otherwise returns false.

pub unsafe fn new_0a() -> CppBox<QPointerOfQObject>[src]

Constructs a 0 guarded pointer.

Calls C++ function: [constructor] void QPointer<QObject>::QPointer().

C++ documentation:

Constructs a 0 guarded pointer.

See also isNull().

pub unsafe fn new_1a(
    p: impl CastInto<Ptr<QObject>>
) -> CppBox<QPointerOfQObject>
[src]

Constructs a guarded pointer that points to the same object that p points to.

Calls C++ function: [constructor] void QPointer<QObject>::QPointer(QObject* p).

C++ documentation:

Constructs a guarded pointer that points to the same object that p points to.

pub unsafe fn new_copy(
    other: impl CastInto<Ref<QPointerOfQObject>>
) -> CppBox<QPointerOfQObject>
[src]

The QPointer class is a template class that provides guarded pointers to QObject.

Calls C++ function: [constructor] void QPointer<QObject>::QPointer(const QPointer<QObject>& other).

C++ documentation:

The QPointer class is a template class that provides guarded pointers to QObject.

A guarded pointer, QPointer<T>, behaves like a normal C++ pointer T *, except that it is automatically set to 0 when the referenced object is destroyed (unlike normal C++ pointers, which become "dangling pointers" in such cases). T must be a subclass of QObject.

Guarded pointers are useful whenever you need to store a pointer to a QObject that is owned by someone else, and therefore might be destroyed while you still hold a reference to it. You can safely test the pointer for validity.

Note that Qt 5 introduces a slight change in behavior when using QPointer.

  • When using QPointer on a QWidget (or a subclass of QWidget), previously the QPointer would be cleared by the QWidget destructor. Now, the QPointer is cleared by the QObject destructor (since this is when QWeakPointer objects are cleared). Any QPointers tracking a widget will NOT be cleared before the QWidget destructor destroys the children for the widget being tracked.

Qt also provides QSharedPointer, an implementation of a reference-counted shared pointer object, which can be used to maintain a collection of references to an individual pointer.

Example:

QPointer<QLabel> label = new QLabel; label->setText("&Status:"); ... if (label) label->show();

If the QLabel is deleted in the meantime, the label variable will hold 0 instead of an invalid address, and the last line will never be executed.

The functions and operators available with a QPointer are the same as those available with a normal unguarded pointer, except the pointer arithmetic operators (+, -, ++, and --), which are normally used only with arrays of objects.

Use QPointers like normal pointers and you will not need to read this class documentation.

For creating guarded pointers, you can construct or assign to them from a T* or from another guarded pointer of the same type. You can compare them with each other using operator==() and operator!=(), or test for 0 with isNull(). You can dereference them using either the *x or the x->member notation.

A guarded pointer will automatically cast to a T *, so you can freely mix guarded and unguarded pointers. This means that if you have a QPointer<QWidget>, you can pass it to a function that requires a QWidget *. For this reason, it is of little value to declare functions to take a QPointer as a parameter; just use normal pointers. Use a QPointer when you are storing a pointer over time.

Note that class T must inherit QObject, or a compilation or link error will result.

pub unsafe fn struct_deref(&self) -> QPtr<QObject>[src]

Overloaded arrow operator; implements pointer semantics. Just use this operator as you would with a normal C++ pointer.

Calls C++ function: QObject* QPointer<QObject>::operator->() const.

C++ documentation:

Overloaded arrow operator; implements pointer semantics. Just use this operator as you would with a normal C++ pointer.

pub unsafe fn swap(&self, other: impl CastInto<Ref<QPointerOfQObject>>)[src]

Swaps the contents of this QPointer with the contents of other. This operation is very fast and never fails.

Calls C++ function: void QPointer<QObject>::swap(QPointer<QObject>& other).

C++ documentation:

Swaps the contents of this QPointer with the contents of other. This operation is very fast and never fails.

This function was introduced in Qt 5.6.

pub unsafe fn to_q_ptr_q_object(&self) -> QPtr<QObject>[src]

Calls C++ function: QObject* QPointer<QObject>::operator QObject*() const.

Trait Implementations

impl CppDeletable for QPointerOfQObject[src]

unsafe fn delete(&self)[src]

The QPointer class is a template class that provides guarded pointers to QObject.

Calls C++ function: [destructor] void QPointer<QObject>::~QPointer().

C++ documentation:

The QPointer class is a template class that provides guarded pointers to QObject.

A guarded pointer, QPointer<T>, behaves like a normal C++ pointer T *, except that it is automatically set to 0 when the referenced object is destroyed (unlike normal C++ pointers, which become "dangling pointers" in such cases). T must be a subclass of QObject.

Guarded pointers are useful whenever you need to store a pointer to a QObject that is owned by someone else, and therefore might be destroyed while you still hold a reference to it. You can safely test the pointer for validity.

Note that Qt 5 introduces a slight change in behavior when using QPointer.

  • When using QPointer on a QWidget (or a subclass of QWidget), previously the QPointer would be cleared by the QWidget destructor. Now, the QPointer is cleared by the QObject destructor (since this is when QWeakPointer objects are cleared). Any QPointers tracking a widget will NOT be cleared before the QWidget destructor destroys the children for the widget being tracked.

Qt also provides QSharedPointer, an implementation of a reference-counted shared pointer object, which can be used to maintain a collection of references to an individual pointer.

Example:

QPointer<QLabel> label = new QLabel; label->setText("&Status:"); ... if (label) label->show();

If the QLabel is deleted in the meantime, the label variable will hold 0 instead of an invalid address, and the last line will never be executed.

The functions and operators available with a QPointer are the same as those available with a normal unguarded pointer, except the pointer arithmetic operators (+, -, ++, and --), which are normally used only with arrays of objects.

Use QPointers like normal pointers and you will not need to read this class documentation.

For creating guarded pointers, you can construct or assign to them from a T* or from another guarded pointer of the same type. You can compare them with each other using operator==() and operator!=(), or test for 0 with isNull(). You can dereference them using either the *x or the x->member notation.

A guarded pointer will automatically cast to a T *, so you can freely mix guarded and unguarded pointers. This means that if you have a QPointer<QWidget>, you can pass it to a function that requires a QWidget *. For this reason, it is of little value to declare functions to take a QPointer as a parameter; just use normal pointers. Use a QPointer when you are storing a pointer over time.

Note that class T must inherit QObject, or a compilation or link error will result.

impl Data for QPointerOfQObject[src]

type Output = QPtr<QObject>

Return type of data() function.

unsafe fn data(&self) -> QPtr<QObject>[src]

Returns the pointer to the object being guarded.

Calls C++ function: QObject* QPointer<QObject>::data() const.

C++ documentation:

Returns the pointer to the object being guarded.

This function was introduced in Qt 4.4.

impl Indirection for QPointerOfQObject[src]

type Output = Ref<QObject>

Output type.

unsafe fn indirection(&self) -> Ref<QObject>[src]

Dereference operator; implements pointer semantics. Just use this operator as you would with a normal C++ pointer.

Calls C++ function: QObject& QPointer<QObject>::operator*() const.

C++ documentation:

Dereference operator; implements pointer semantics. Just use this operator as you would with a normal C++ pointer.

impl PartialEq<Ptr<QObject>> for QPointerOfQObject[src]

fn eq(&self, o: &Ptr<QObject>) -> bool[src]

Returns true if c1 and c2 are the same Unicode character; otherwise returns false.

Calls C++ function: bool operator==(const QPointer<QObject>& p, const QObject* o).

Warning: no exact match found in C++ documentation. Below is the C++ documentation for bool operator==(QChar c1, QChar c2):

Returns true if c1 and c2 are the same Unicode character; otherwise returns false.

impl PartialEq<Ref<QPointerOfQObject>> for QPointerOfQObject[src]

fn eq(&self, p2: &Ref<QPointerOfQObject>) -> bool[src]

Returns true if c1 and c2 are the same Unicode character; otherwise returns false.

Calls C++ function: bool operator==(const QPointer<QObject>& p1, const QPointer<QObject>& p2).

Warning: no exact match found in C++ documentation. Below is the C++ documentation for bool operator==(QChar c1, QChar c2):

Returns true if c1 and c2 are the same Unicode character; otherwise returns false.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T, U> CastInto<U> for T where
    U: CastFrom<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> StaticUpcast<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.