Creating Rust/QML Project
For the last few months, I have been pushing Rust/Qt development along. I am the author of ki18n crate and am currently in the middle of creating kconfig crate as a part of Season of KDE 2022.
In this post, I will walk you through creating a new Rust/QML project using cargo-generate templates. I made these templates to encourage more people to test out Qt development with Rust.
Install Cargo Generate
Full Instructions are present in the repository here.
Using Cargo
With System’s OpenSSL
With vendored OpenSSL
Arch Linux
Manual
- Download the binary tarball for your platform from releases page.
- Unpack the tarball and place the binary
cargo-generate
in~/.cargo/bin/
Select the Template
Currently, there are two templates I have created for Rust/QML. The templates can be found here.
Basic QtQuick Application
This template creates a basic QtQuick Application with Rust. It does not contain any KDE Components. This template should work in all platforms Qt, and Rust is supported.
Dependencies
Manual
Qt can be installed using the installer. Be sure to install qmake
since it is used by qmetaobject crate to detect system Qt install.
Ubuntu
Generate Project
Run Project
We will also set RUST_LOG
variable for enabling logs.
RUST_LOG=error,warn,info,debug,trace
Screenshots
Kirigami Application
This template creates a basic Kirigami Application with Rust. Currently, this template is only tested in Linux. It can technically work in other platforms if the KDE Frameworks path is manually specified, but I have not tried that. If you would like to help, the crate for detecting KDE Frameworks is kde_frameworks.
Dependencies
Manual
Qt can be installed using the installer. Be sure to install
qmake
since it is used by qmetaobject crate to detect system Qt install.KDE Frameworks (
Kirigami
andKI18n
) should also be installed. Be sure to installkf5-config
since it is used to locateKirigami
andKI18n
Frameworks.
Ubuntu
Arch-based
Fedora
Generate Project
Run Project
We will also set RUST_LOG
variable for enabling logs.
RUST_LOG=error,warn,info,debug,trace
Screenshots
Conclusion
If you find this exciting or want to try something new in Rust/Qt, here is a list of crates related to Rust + Qt development.