Hello
I want to make a struct which will act as a kind of global variable. This to be able to pass a QWidget object to functions.
I'm using Qt-rs..
Code:
#![windows_subsystem = "windows"]
use qt_widgets::{
cpp_core::{CppBox, MutPtr},
qt_core::QString,
qt_core::Slot,
QApplication, QLineEdit, QMessageBox, QPushButton, QVBoxLayout, QWidget,
QLabel,
};
pub fn test(layout: QWidget) {
println!("test");
}
struct Test {
widget: QWidget,
}
impl Test {
pub fn test(&self) {
println!("Test");
}
}
fn main() {
/*
let t = Test {
widget: QWidget::new_0a(),
};
*/
QApplication::init(|_| unsafe {
//let mut widget = t.widget;
let mut widget = QWidget::new_0a();
let mut layout = QVBoxLayout::new_1a(&mut widget).into_ptr();
test(widget);
layout.add_widget(&mut btn_add);
widget.show();
QApplication::exec()
})
}
Error:
expected struct `qt_widgets::QWidget`, found struct `cpp_core::cpp_box::CppBox`
But when I change pub fn test(layout: QWidget)
to pub fn test(layout: cpp_core::cpp_box::CppBox)
I get this error:
use of undeclared type or module `cpp_core`
How can I solve this? What type do I need to use?
Thanks!