[][src]Struct qt_qml::q_qml_engine::ObjectOwnership

#[repr(transparent)]pub struct ObjectOwnership(_);

ObjectOwnership controls whether or not QML automatically destroys the QObject when the corresponding JavaScript object is garbage collected by the engine. The two ownership options are:

C++ enum: QQmlEngine::ObjectOwnership.

C++ documentation:

ObjectOwnership controls whether or not QML automatically destroys the QObject when the corresponding JavaScript object is garbage collected by the engine. The two ownership options are:

Generally an application doesn't need to set an object's ownership explicitly. QML uses a heuristic to set the default ownership. By default, an object that is created by QML has JavaScriptOwnership. The exception to this are the root objects created by calling QQmlComponent::create() or QQmlComponent::beginCreate(), which have CppOwnership by default. The ownership of these root-level objects is considered to have been transferred to the C++ caller.

Objects not-created by QML have CppOwnership by default. The exception to this are objects returned from C++ method calls; their ownership will be set to JavaScriptOwnership. This applies only to explicit invocations of Q_INVOKABLE methods or slots, but not to property getter invocations.

Calling setObjectOwnership() overrides the default ownership heuristic used by QML.

Methods

impl ObjectOwnership[src]

pub fn to_int(&self) -> c_int[src]

impl ObjectOwnership[src]

pub const CppOwnership: ObjectOwnership[src]

The object is owned by C++ code and QML will never delete it. The JavaScript destroy() method cannot be used on these objects. This option is similar to QScriptEngine::QtOwnership. (C++ enum variant: CppOwnership = 0)

pub const JavaScriptOwnership: ObjectOwnership[src]

The object is owned by JavaScript. When the object is returned to QML as the return value of a method call, QML will track it and delete it if there are no remaining JavaScript references to it and it has no QObject::parent(). An object tracked by one QQmlEngine will be deleted during that QQmlEngine's destructor. Thus, JavaScript references between objects with JavaScriptOwnership from two different engines will not be valid if one of these engines is deleted. This option is similar to QScriptEngine::ScriptOwnership. (C++ enum variant: JavaScriptOwnership = 1)

Trait Implementations

impl Clone for ObjectOwnership[src]

impl Copy for ObjectOwnership[src]

impl Debug for ObjectOwnership[src]

impl Eq for ObjectOwnership[src]

impl From<ObjectOwnership> for c_int[src]

impl From<i32> for ObjectOwnership[src]

impl PartialEq<ObjectOwnership> for ObjectOwnership[src]

impl StructuralEq for ObjectOwnership[src]

impl StructuralPartialEq for ObjectOwnership[src]

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> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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.