Logo

dev-resources.site

for different kinds of informations.

Creating Rust/QML Project using Templates

Published at
1/22/2022
Categories
kde
rust
Author
ayush1325
Categories
2 categories in total
kde
open
rust
open
Author
9 person written this
ayush1325
open
Creating Rust/QML Project using Templates

Background

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

cargo install cargo-generate

Enter fullscreen mode Exit fullscreen mode

With vendored OpenSSL

cargo install cargo-generate --features vendored-openssl

Enter fullscreen mode Exit fullscreen mode

Arch Linux

pacman -S cargo-generate

Enter fullscreen mode Exit fullscreen mode

Manual

  1. Download the binary tarball for your platform from releases page.
  2. 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
sudo apt install build-essential qtbase5-dev qtdeclarative5-dev libqt5svg5-dev qtquickcontrols2-5-dev qml-module-qtquick-layouts

Enter fullscreen mode Exit fullscreen mode

Generate Project

cargo generate --git https://invent.kde.org/oreki/rust-qt-template/ basic-qtquick --name myproject

Enter fullscreen mode Exit fullscreen mode

Run Project

We will also set RUST_LOG variable for enabling logs.

RUST_LOG=error,warn,info,debug,trace cargo run

Enter fullscreen mode Exit fullscreen mode

Screenshots

Screenshot

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
  1. QT can be installed using the installer. Be sure to install qmake since it is used by qmetaobject crate to detect system QT install.
  2. KDE Frameworks (Kirigami and KI18n) should also be installed. Be sure to install kf5-config since it is used to locate Kirigami and KI18n Frameworks.
Ubuntu
sudo apt install build-essential qtbase5-dev qtdeclarative5-dev libqt5svg5-dev qtquickcontrols2-5-dev qml-module-qtquick-layouts qml-module-org-kde-kirigami2 kirigami2-dev libkf5i18n-dev gettext libkf5coreaddons-dev libkf5kdelibs4support5-bin

Enter fullscreen mode Exit fullscreen mode

Arch-based

sudo pacman -Syu base-devel extra-cmake-modules cmake kirigami2 kde-sdk-meta gettext

Enter fullscreen mode Exit fullscreen mode

Fedora

sudo dnf groupinstall "Development Tools" "Development Libraries"
sudo dnf install extra-cmake-modules cmake qt5-qtbase-devel qt5-qtdeclarative-devel qt5-qtquickcontrols2-devel kf5-kirigami2 kf5-kirigami2-devel kf5-ki18n-devel kf5-kcoreaddons-devel gettext

Enter fullscreen mode Exit fullscreen mode

Generate Project

cargo generate --git https://invent.kde.org/oreki/rust-qt-template/ kirigami --name myproject

Enter fullscreen mode Exit fullscreen mode

Run Project

We will also set RUST_LOG variable for enabling logs.

RUST_LOG=error,warn,info,debug,trace cargo run

Enter fullscreen mode Exit fullscreen mode

Screenshots

Screenshot

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.

  1. qmetaobject
  2. Rust Qt Binding Generattor
  3. ki18n
  4. kconfig
  5. rust-qt-template
kde Article's
30 articles in total
Favicon
(Quick-note) Troubleshooting Dual Monitor Issues on KDE on Ubuntu/ Linux Mint
Favicon
bash: No such file or directory
Favicon
How To Unhide Titlebars on Maximised Windows in KDE Plasma 6
Favicon
DinaWall 0.2
Favicon
How to enable auto dark mode (night theme) in KDE Plasma
Favicon
Using KConfig with Rust
Favicon
Bitflags in Rust
Favicon
Season of KDE 2022
Favicon
Creating Rust/QML Project using Templates
Favicon
My sleek and modern Linux development machine in 2021
Favicon
Activate USB Wi-Fi Receiver from Terminal
Favicon
KDE Development with Podman
Favicon
My KDE Workfloaw
Favicon
How to recover KDE if it doesn't load after updating FreeBSD from 12.x to 13.0-RELEASE
Favicon
Fuck FreeBSD
Favicon
The state of Linux as a daily use OS in 2021
Favicon
SPOTIFY SYSTEM TRAY [KDE]
Favicon
Fedora - KDE development journey (Qt5X11Extras)
Favicon
Fedora - KDE development journey (Qt5UiPlugin)
Favicon
Fedora - KDE development journey (Qt5Qml / qmake)
Favicon
KDE vs GNOME
Favicon
Setting up Arch Linux with KDE Plasma in Windows Subsystem for Linux 2
Favicon
βš™ My Arch Linux setup
Favicon
Writing a KDE Plasmoid to display JioFi Stats
Favicon
KDE Plasma & ssh keys
Favicon
Trying out KDE
Favicon
My (k)Ubuntu (OSX look alike) desktop setup
Favicon
KDE Neon on 2017 MacBook Air
Favicon
Script your Yakuake with default tabs
Favicon
How to execute Firefox with support for KDE filepicker

Featured ones: