Skip to content

Commit 28db8bd

Browse files
committed
cxx-qt: explicit upcasting
1 parent f00edfb commit 28db8bd

File tree

2 files changed

+8
-4
lines changed
  • examples

2 files changed

+8
-4
lines changed

examples/cargo_without_cmake/src/main.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@
1414
// ANCHOR: book_cargo_imports
1515
pub mod cxxqt_object;
1616

17+
use std::pin::Pin;
18+
1719
use cxx_qt::Upcast;
18-
use cxx_qt_lib::{QGuiApplication, QQmlApplicationEngine, QUrl};
20+
use cxx_qt_lib::{QGuiApplication, QQmlApplicationEngine, QQmlEngine, QUrl};
1921
// ANCHOR_END: book_cargo_imports
2022

2123
// ANCHOR: book_cargo_rust_main
@@ -30,9 +32,9 @@ fn main() {
3032
}
3133

3234
if let Some(engine) = engine.as_mut() {
35+
let engine: Pin<&mut QQmlEngine> = engine.upcast_pin();
3336
// Listen to a signal from the QML Engine
3437
engine
35-
.upcast_pin()
3638
.on_quit(|_| {
3739
println!("QML Quit!");
3840
})

examples/qml_multi_crates/rust/main/src/main.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55

66
extern crate qml_multi_crates;
77

8+
use std::pin::Pin;
9+
810
use cxx_qt::Upcast;
9-
use cxx_qt_lib::{QGuiApplication, QQmlApplicationEngine, QUrl};
11+
use cxx_qt_lib::{QGuiApplication, QQmlApplicationEngine, QQmlEngine, QUrl};
1012

1113
fn main() {
1214
cxx_qt::init_crate!(qml_multi_crates);
@@ -21,9 +23,9 @@ fn main() {
2123
}
2224

2325
if let Some(engine) = engine.as_mut() {
26+
let engine: Pin<&mut QQmlEngine> = engine.upcast_pin();
2427
// Listen to a signal from the QML Engine
2528
engine
26-
.upcast_pin()
2729
.on_quit(|_| {
2830
println!("QML Quit!");
2931
})

0 commit comments

Comments
 (0)