This code generator gets you started quickly to use Rust code from Qt and QML. In other words, it helps to create a Qt based GUI on top of Rust code.
Qt is a mature cross-platform graphical user interface library. Rust is a new programming language with strong compile time checks and a modern syntax.
There are two template projects that help you to get started quickly. One for [Qt Widgets](templates/qt_widgets) and one for [Qt Quick](templates/qt_quick). Just copy these folders as new project and start coding.
To combine Qt and Rust, write an interface in a JSON file. From that, the generator creates Qt code and Rust code. The Qt code can be used directly. The Rust code has two files: interface and implementation. The interface can be used directly.
Only `implementation.rs` should be changed. The other files are the binding. `implementation.rs` is initialy created with a simple implementation that is shown here with some comments.
The building block of Qt and QML projects are QObject and the Model View classes. `rust_qt_binding_generator` reads a json file to generate QObject or QAbstractItemModel classes that call into generated Rust files. For each type from the JSON file, a Rust trait is generated that should be implemented.
This way, Rust code can be called from Qt and QML projects.
This Qt Quick (QML) code uses the Rust code written above.
```qml
Rectangle {
Greeting {
id: rust
}
Text {
text: rust.message
}
}
```
## Demo application
The project comes with a demo application that show a Qt user interface based on Rust. It uses all of the features of Object, List and Tree. Reading the demo code is a good way to get started.
<figure>
<imgsrc="demo/screenshots/demo.png"alt="Qt Widgets UI with Rust logic"/>
To get started quickly, the project comes with a `Dockerfile`. You can start a docker session with the required dependencies with `./docker/docker-bash-session.sh`.
Please [report bugs and feature requests](https://bugs.kde.org/enter_bug.cgi?product=rust-qt-binding-generator) in the KDE issue tracker, product "rust-qt-binding-generator".