Closed vandenoever closed 5 years ago
fn connect<A, B>(sender: &mut A, signal: &str, receiver: &mut B, slot: &str)
...
let si = signal.as_ptr() as *const i8;
signal
and slot
are not zero-terminated strings. Could you check if using std::ffi::CString
helps?
The connect function refuses to work because the signal and slot specifiers are incorrect. They should be "2accepted()"
and "1quit()"
because that's what SIGNAL()
and SLOT()
macros do:
# define SLOT(a) qFlagLocation("1"#a QLOCATION)
# define SIGNAL(a) qFlagLocation("2"#a QLOCATION)
And indeed, Rust strings are not null terminated, so you would need to either use CString
or write a null terminated literal, e.g. b"2accepted()\0"
.
Note that cpp_to_rust
generates high-level API for connections. You can see an example at variant_animation2.rs. So there is no need to construct signal and slot specifiers manually.
There are also conversion functions between qt_core::string::String
and std::string
(called from_std_str
and to_std_string
).
I've tried writing a hello world application that shows a message box with 'Hello World!".
Here is the code:
The signal and slot are not connected. This is the error message on the command-line: