pub trait QmlObject: QObjectHolder {
// Provided methods
fn default_with_attached_qobject() -> Rc<RefCell<Self>>
where Self: Default { ... }
fn attach_qobject(instance: &Rc<RefCell<Self>>) { ... }
fn detach_qobject(&self) { ... }
fn get_thread_handle(&self) -> QThreadHandle<Self> { ... }
}Provided Methods§
Sourcefn default_with_attached_qobject() -> Rc<RefCell<Self>>where
Self: Default,
fn default_with_attached_qobject() -> Rc<RefCell<Self>>where
Self: Default,
Creates a default-initialized instance and attaches its
QObject eagerly.
The returned Rc<RefCell<Self>> is an ordinary handle, shared with
QML. Droping the handle does not drop the instance if it is in use by
QML or until the garbage collection delete the QML instance.
Sourcefn attach_qobject(instance: &Rc<RefCell<Self>>)
fn attach_qobject(instance: &Rc<RefCell<Self>>)
Attaches a dedicated QObject to an existing instance,
enabling its use in QML.
Sourcefn detach_qobject(&self)
fn detach_qobject(&self)
Detaches and deletes the dedicated QObject of this instance.
The instance continues as a plain Rust value and heals with a
fresh QObject on its next exposure to QML.
Sourcefn get_thread_handle(&self) -> QThreadHandle<Self>
fn get_thread_handle(&self) -> QThreadHandle<Self>
Returns a QThreadHandle that can schedule Rust closures to run
on this object on the Qt thread, from any thread.
This function can only be called on the Qt thread for QmlObject that live in this thread.
§Example
let backend = Backend::default_with_attached_qobject();
let handle = backend.borrow().get_thread_handle();
handle.invoke_mut(|b| b.value = 42);Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.