QObjectHolder

Trait QObjectHolder 

Source
pub trait QObjectHolder:
    DispatchMetaCall
    + QMetaInfo
    + Default {
    // Provided methods
    fn default_with_attached_qobject() -> Rc<RefCell<Self>> { ... }
    fn attach_qobject(instance: &Rc<RefCell<Self>>) { ... }
    fn detach_qobject(&self) { ... }
    fn as_qvariant(&self) -> QVariant { ... }
}
Expand description

Enable access to C++ and QML.

This trait is automatically implemented by qobject and qobject_impl and should never be implemented manually.

Provided Methods§

Source

fn default_with_attached_qobject() -> Rc<RefCell<Self>>

Create a new default-initialized instance of this type and attach the required [QObject]. This enables use of this instance in QML. Instances created with this function must remain at its original heap location and must not be moved out of Rc<RefCell<T>>.

Source

fn attach_qobject(instance: &Rc<RefCell<Self>>)

Create and attach a dedicated [QObject] to the instance. The instance must remain at its original heap location and must not be moved out of Rc<RefCell<T>>.

Source

fn detach_qobject(&self)

Detach and remove the dedicated [QObject] from the specified object. This function is intended to be called during the Drop implementation of this type.

Source

fn as_qvariant(&self) -> QVariant

Return a QVariant containing a pointer to this object.

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.

Implementors§