Traits

Traits can be implemented (or in some cases negated) inside the #[cxx_qt::bridge] in a similar way to explicit shim trait impls in CXX.

Except instead of the T being a generic it is the struct the trait is implemented for. This is because some of the traits themselves require generics.

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
  • CxxQtType - trait to reach the Rust implementation of a QObject
  • Constructor - custom constructor
  • Initialize - execute Rust code when the object is constructed
  • Locking - marker trait whether locking is enabled
  • Threading - marker trait whether CXX-Qt threading should be enabled