How to import Rust struct as a parameter of another Rust struct? (minimal example provided) #1313
Unanswered
shanmukhateja
asked this question in
Q&A
Replies: 1 comment
-
The bridge in use std::pin::Pin;
use crate::{class1::qobject::Class1, class2::qobject::Class2};
#[cxx_qt::bridge]
pub mod qobject {
unsafe extern "C++" {
// define Class2 as a C++ type the same as the one from the other bridge
// note that you may need to include the header of the file here too with include!("myheader.h");
type Class2 = crate::class2::qobject::Class2;
}
unsafe extern "RustQt" {
#[qobject]
#[qml_element]
type Class1 = super::Class1Rust;
#[qinvokable]
fn foo(self: Pin<&mut Class1>, class2: Pin<&Class2>);
}
}
#[derive(Default)]
pub struct Class1Rust;
impl Class1Rust {
fn append_item(mut self: Pin<&mut Class1>, class2: &Class2) {}
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
I have 2 classes - class1.rs & class2.rs.
I am trying to use
Class2
as a parameter for aqinvokable
function insideclass1.rs
.Please look at the code:
class1.rs
class2.rs
What I have tried:
I tried declaring
extern "Rust" { type Class2; }
block but then it complains about "no throw destructors in Qt" or something.I also tried declaring the type outside of
qobject
module (insideclass1.rs
) but that gives me aPin
related error.Beta Was this translation helpful? Give feedback.
All reactions