-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generic means to invoke and connect #1035
Comments
So we do have a "new" The idea of this is that there is an existing type in C++ that has signals/invokables and you would write this code to then express that there is a signal and then you can create connections from it on the Rust side. #[cxx_qt::bridge]
mod ffi {
extern "C++Qt" {
include!(<QtWidgets/QPushButton>);
type QPushButton;
#[qsignal]
fn clicked(self: Pin<&mut QPushButton>, checked: bool);
}
} Now to answer your questions directly...
Maybe once #562 is available you would be able to easily cast / reach the QMetaObject or get from a QObject* and test if you can downcast to MyObject*. As then you could have like Also note we have a Zulip chat if you want to have longer discussions on things :-) https://cxx-qt.zulipchat.com/ |
Thanks! That effort for QtObject traits seems to go exactly where I am hoping. I am currently taking a similar approach in my own codebase by having my own traits for QObject an QQuickItem, plus some C++-side templates that can be pulled in on-demand for I will close this though, seems it is clearly already being worked on! |
I noticed that the examples and documentation only provide a means to connect signals to Rust closures/functions.
Likewise, calling slots/invokables seems to be possible only through the bridge-generated Rust entry points.
It would be quite convenient in a mixed codebase to invoke or make connections to any Qt object, even if it was not defined on the Rust side of the bridge. Basically, it means having QMetaObject support, making generic connections between QMetaMethods and being able to pass around QObject handles to operate on.
Is it a design decision to not do such things because QObject handles cannot be guaranteed to be handled safely? Or is this something that might be added down the line?
For now, I am achieving this by having my own QObject type with C++-side helper methods, which I can pass around / connect to / invoke on via bridged C++ methods. This does mean I am having to mark lots of code unsafe and passing around a lot of
*mut QObject
handles.The text was updated successfully, but these errors were encountered: