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
+13
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
29
29
30
30
> ⚠️ These traits should only be implemented if you are sure you need to, they are automatically implemented for RustQt types.
Copy file name to clipboardExpand all lines: crates/cxx-qt/src/lib.rs
+4
Original file line number
Diff line number
Diff line change
@@ -313,6 +313,7 @@ impl<T: Sized> Downcast for T {}
313
313
/// To reduce the boilerplate of this use-case, CXX-Qt provides the [Initialize] trait.
314
314
///
315
315
/// If a QObject implements the `Initialize` trait, and the inner Rust struct is [Default]-constructible it will automatically implement `cxx_qt::Constructor<()>`.
316
+
/// Additionally, implementing `impl cxx_qt::Initialize` will act as shorthand for `cxx_qt::Constructor<()>`.
316
317
pubtraitConstructor<Arguments>:CxxQtType{
317
318
/// The arguments that are passed to the [`new()`](Self::new) function to construct the inner Rust struct.
0 commit comments