Open
Description
Currently, if you want to expose a function on the inner Rust struct to C++/QML, you always have to write a wrapper function outside the bridge.
E.g.:
#[cxx_qt::bridge]
mod qobject {
extern "RustQt" {
#[qobject]
type MyObject = super::MyObjectRust;
fn my_fun(self: &MyObject) -> i32;
}
}
impl qobject::MyObject {
fn my_fun(&self) -> i32 {
self.rust().my_fun();
}
}
We could consider automating this if you provide a given attribute to the declaration (e.g. #[inner]
).
Example:
#[cxx_qt::bridge]
mod qobject {
extern "RustQt" {
#[qobject]
type MyObject = super::MyObjectRust;
#[inner] // auto-generates the wrapper outside the bridge
fn my_fun(self: &MyObject) -> i32;
}
}
Note that this may cause issues with Result<>
, as the Error type wouldn't necessarily be known.