You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- `impl cxx_qt::Initialize for x {}` can now be written in the bridge as shorthand
- It is shorthand for `impl cxx_qt::Constructor<()> for x {}`
- Update book, qml_features and docs
Copy file name to clipboardExpand all lines: book/src/bridge/extern_rustqt.md
+13Lines changed: 13 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -99,6 +99,19 @@ For more information on inheritance and how to override methods see the [Inherit
99
99
### Traits
100
100
101
101
The [`Default` trait](https://doc.rust-lang.org/std/default/trait.Default.html) needs to be implemented for the `#[qobject]` marked struct either by hand or by using the derive macro `#[derive(Default)]`. Or the [`cxx_qt::Constructor`](https://docs.rs/cxx-qt/latest/cxx_qt/trait.Constructor.html) trait needs to be implemented for the type.
102
+
In order to simply implement the `Constructor` trait, the following shorthand is available:
103
+
104
+
```rust,ignore
105
+
impl cxx_qt::Initialize for x {}
106
+
```
107
+
108
+
is equivalent to writing
109
+
110
+
```rust,ignore
111
+
impl cxx_qt::Constructor<()> for x {}
112
+
```
113
+
114
+
inside the bridge.
102
115
103
116
For further documentation see the [traits page](./traits.md).
-[Initialize](https://docs.rs/cxx-qt/latest/cxx_qt/trait.Initialize.html) - execute Rust code when the object is constructed
27
+
-[Initialize](https://docs.rs/cxx-qt/latest/cxx_qt/trait.Initialize.html) - execute Rust code when the object is constructed, or as shorthand for an empty constructor
28
28
-[Threading](https://docs.rs/cxx-qt/latest/cxx_qt/trait.Threading.html) - marker trait whether CXX-Qt threading should be enabled
Copy file name to clipboardExpand all lines: crates/cxx-qt/src/lib.rs
+4Lines changed: 4 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -214,6 +214,7 @@ pub trait Upcast<T> {}
214
214
/// To reduce the boilerplate of this use-case, CXX-Qt provides the [Initialize] trait.
215
215
///
216
216
/// If a QObject implements the `Initialize` trait, and the inner Rust struct is [Default]-constructible it will automatically implement `cxx_qt::Constructor<()>`.
217
+
/// Additionally, implementing `impl cxx_qt::Initialize` will act as shorthand for `cxx_qt::Constructor<()>`.
217
218
pubtraitConstructor<Arguments>:CxxQtType{
218
219
/// The arguments that are passed to the [`new()`](Self::new) function to construct the inner Rust struct.
0 commit comments