diff --git a/book/src/getting-started/1-qobjects-in-rust.md b/book/src/getting-started/1-qobjects-in-rust.md index 31db14add..43eb21914 100644 --- a/book/src/getting-started/1-qobjects-in-rust.md +++ b/book/src/getting-started/1-qobjects-in-rust.md @@ -48,7 +48,9 @@ These CXX-Qt modules consist of multiple parts: - The `impl` of the `RustObj` struct (optional): - Contains any Rust code. - Functions marked with `#[invokable]` will be callable from QML and C++. - +- The `Signal` enum + - A normal Rust enum. + - Defines signals that are added to the QObject class CXX-Qt will then expand this Rust module into two separate parts: - A C++ subclass of QObject with the same name as the module diff --git a/book/src/qobject/cpp_object.md b/book/src/qobject/cpp_object.md index 4b2b569b7..e8b209dbf 100644 --- a/book/src/qobject/cpp_object.md +++ b/book/src/qobject/cpp_object.md @@ -24,14 +24,7 @@ If there is a [`Signals` enum](./signals_enum.md) then you can call `emit_queued Note that `emit_immediate` is unsafe as it can cause deadlocks if the `Q_EMIT` is `Qt::DirectConnection` connected to a Rust invokable on the same QObject that has caused the `Q_EMIT`, as this would then try to lock the `RustObj` which is already locked. ```rust,ignore,noplayground -impl RustObj { - #[invokable] - fn invokable(&self, cpp: &mut CppObj) { - unsafe { cpp.emit_immediate(Signal::Ready); } - - cpp.emit_queued(Signal::DataChanged { data: 1 }); - } -} +{{#include ../../../examples/qml_features/src/signals.rs:book_rust_obj_impl}} ``` ## Threading