Traits
CXX-Qt uses multiple traits to cleanly encode its behavior and supported features into Rusts type system.
Some of these traits use a special syntax inside the #[cxx_qt::bridge]
similarly to explicit shim trait impls in CXX.
Depending on the trait, this either tells CXX-Qt that it should automatically implement the trait, or that it should use an existing trait implementation for code generation.
impl UniquePtr<A> {} // explicit CXX trait implementation of UniquePtr for A
impl cxx_qt::Trait for A {} // explicit CXX-Qt trait implementation of Trait for A
For further documentation, refer to the documentation of the individual traits:
- CxxQtType - trait to reach the Rust implementation of a
QObject
- This trait is automatically implemented for any
#[qobject]
type insideextern "RustQt"
blocks.
- This trait is automatically implemented for any
- Constructor - custom constructor
- Initialize - execute Rust code when the object is constructed
- Threading - marker trait whether CXX-Qt threading should be enabled