Skip to content

Commit

Permalink
book: use an example for signals example
Browse files Browse the repository at this point in the history
  • Loading branch information
ahayzen-kdab committed Aug 3, 2022
1 parent a7b8db8 commit 35ee3ca
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
4 changes: 3 additions & 1 deletion book/src/getting-started/1-qobjects-in-rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -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++.
<!-- TODO: Add Signals enum, once #67 lands -->
- 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
Expand Down
9 changes: 1 addition & 8 deletions book/src/qobject/cpp_object.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 35ee3ca

Please sign in to comment.