[−][src]Struct qt_qml::q_qml_engine::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
.
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]
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]
fn clone(&self) -> ObjectOwnership
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Copy for ObjectOwnership
[src]
impl Debug for ObjectOwnership
[src]
impl Eq for ObjectOwnership
[src]
impl From<ObjectOwnership> for c_int
[src]
fn from(value: ObjectOwnership) -> Self
[src]
impl From<i32> for ObjectOwnership
[src]
impl PartialEq<ObjectOwnership> for ObjectOwnership
[src]
fn eq(&self, other: &ObjectOwnership) -> bool
[src]
fn ne(&self, other: &ObjectOwnership) -> bool
[src]
impl StructuralEq for ObjectOwnership
[src]
impl StructuralPartialEq for ObjectOwnership
[src]
Auto Trait Implementations
impl RefUnwindSafe for ObjectOwnership
impl Send for ObjectOwnership
impl Sync for ObjectOwnership
impl Unpin for ObjectOwnership
impl UnwindSafe for ObjectOwnership
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> CastInto<U> for T where
U: CastFrom<T>,
[src]
U: CastFrom<T>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> StaticUpcast<T> for T
[src]
unsafe fn static_upcast(ptr: Ptr<T>) -> Ptr<T>
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,