-
Notifications
You must be signed in to change notification settings - Fork 43
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
calling QML from Rust #22
Comments
The proper way to do this would be to support defining signals on the Rust side; the C++ wrapper library already supports this and the Rust side also once upon a time used to support them, but the implementation was horrible hack that mungled with internal Rust representations and was not memory safe either. So not really right now, but it could be implemented. The hard part is making a nice and safe Rust interface for signals. |
Well, it seems to me a lot of functionality is missing when you can't communicate with the GUI from your rust code. My project certainly needs this. |
Yes, that is true. Unfortunately the time I have been able to spend on this project lately has been very low. |
I'd be willing to implemented it if I knew what's the problem with the current solution. Looking at the commented-out code signals are identified by their signature via string comparison and invoked using |
There are a couple of issues, nothing really fundamental. Mostly figuring out how to present things in a safe way.
Thanks :) |
Any news on this? I need to be able to send signals from Rust in my project |
I extended qmlrs to allow emitting signals in Rust code as well as defining singleton type that allows QML code to call Rust functions. The code isn't really PR-ready. I ignore thread-safety completely, the Q_OBJECT! macro is broken and I don't know if the API is usable outside of my limited use-case. You can take a look on it here: https://github.com/das-labor/panopticon/blob/master/qt/src/controller.rs |
Hi everyone, i'm the author of the DOtherSide C++ library that basically implements a C layer for creating bindings to the Qml layer. I developed the DQml and NimQml bindings. Maybe we can work together by porting your C++ code to my library. In this way we can arrive at a common implementation for Nim, D and Rust. Furthermore i find it stupid to rewrite the C++ part. Btw the DOtherSide project already support creation of singletons, custom types, signals, slots. You should just call the C functions for having the work done. :) |
Do you think it's possible to have safe Rust code work with your OtherSide implementation? |
It depends on what do you mean with safe. I'm not a rust expert and i just 2016-04-30 11:28 GMT+02:00 colms notifications@github.com:
Filippo Cucchetto |
@filcuc I was intending to rewrite qmlrs based on libqmlbind, see #22 for the discussion. I was not aware that there is a competitor to libqmlbind, though. Is there any documentation for DOtherSide, especially on how it can be used from a library author's point of view? I can't find any, so it's hard for me to spot the differences between DOtherSide and libqmlbind. Or could you compare DOtherSide to libqmlbind? (libqmlbind's documentation can be found at https://seanchas116.github.io/libqmlbind/) In any case, I'll list DOtherSide as an alternative to libqmlbind: seanchas116/libqmlbind#40 |
@colms A safe Rust interface will be possible regardless of the underlying backend library. 😄 That's the main job of qmlrs if you take the C wrapper away - creating a safe rust interface without exposing the unsafeness of the used C functions. 😉 |
@florianjacob @colms as long as the C library is "safe" :D @florianjacob
We've two complete bindings in place DQml and NimQml. The logic is more or less the same in both bindings. I think that there's no better example that a full binding for a different language.
From the outside they're very similar if not identical. Both are
On the other hand i don't know the internals but i can guess that they both works the same more or less. For the rest the DOtheSide library:
|
Support for QAbstractItemModels in qmlrs would be very welcome. It can be emulated a bit by populating a ListModel via JavaScript that calls into Rust. |
Is it possible to call QML functions from Rust?
The text was updated successfully, but these errors were encountered: