chore: initial commit
Initial commit
This commit is contained in:
@@ -0,0 +1 @@
|
||||
pub mod my_object;
|
||||
@@ -0,0 +1,31 @@
|
||||
#[cxx_qt::bridge]
|
||||
pub mod qobject {
|
||||
unsafe extern "C++" {
|
||||
include!("cxx-qt-lib/qstring.h");
|
||||
type QString = cxx_qt_lib::QString;
|
||||
}
|
||||
|
||||
extern "RustQt" {
|
||||
#[qobject]
|
||||
#[qml_element]
|
||||
#[qproperty(i32, counter)]
|
||||
type CounterLogic = super::CounterLogicRust;
|
||||
|
||||
#[qinvokable]
|
||||
fn increment(self: Pin<&mut Self>);
|
||||
}
|
||||
}
|
||||
|
||||
use core::pin::Pin;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct CounterLogicRust {
|
||||
counter: i32,
|
||||
}
|
||||
|
||||
impl qobject::CounterLogic {
|
||||
pub fn increment(self: Pin<&mut Self>) {
|
||||
let new_val = *self.counter() + 1;
|
||||
self.set_counter(new_val);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user