rust-qt / ritual

Use C++ libraries from Rust
Apache License 2.0
1.22k stars 49 forks source link

Use custom C++ widgets in Ritual #99

Closed notgull closed 1 year ago

notgull commented 4 years ago

It would be nice to create a custom widget (derived from QWidget) in C++ code, then use it in Rust code. If this isn't possible already, I would be willing to add this functionality to the code.

notgull commented 4 years ago

It appears that the main obstacle to this is that the QT-related dependencies are hardcoded into the qt_ritual and qt_ritual_common crates. In addition, it also appears that installation data is checked, which assumes that the crate in question is a main QT lib. It would be nice if either qt_ritual or qt_ritual_common exported a way to retrieve data for the QT compiler without needing to check if the installation was present. Again, I can add this functionality to the code, if it is desired.

Riateche commented 4 years ago

I think the plan here is:

  1. Modify qt_ritual so that it can return a Config for a library that depends on specified Qt crates.
  2. Use a recently added feature that allows you to inject arbitrary C++ code in the FFI library. It allows to avoid having to compile another library.
  3. Modify target_include_paths logic to allow processing libraries that consist of only extra C++ code. Right now, if you don't specify it, the parser will parse all available symbols, which is not what we need in this case.
  4. Modify qt_ritual_build so that it can be used for the produced crate. It's necessary to reuse its Qt detection logic so that the user's crate links to the same Qt as the main Qt crates.
  5. Make an example that can be used for a quick start.

I'm currently working on the next release of Qt crates, so some relevant changes to the generator are not yet finished. After I finish that, I'll look into this issue.

notgull commented 1 year ago

Not interested in this anymore.