QMetaObject crate for Rust
min-sized-rust
Our great sponsors
QMetaObject crate for Rust | min-sized-rust | |
---|---|---|
20 | 101 | |
594 | 7,328 | |
2.9% | - | |
6.5 | 6.2 | |
29 days ago | 12 days ago | |
Rust | Rust | |
MIT License | MIT License |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
QMetaObject crate for Rust
-
9 years of Apple text editor solo dev
You can use Rust with QML[1].
QML is actually pretty amazing. I've been building my block editor[2] view entirely in QML while the model is in C++. This separation of logic and presentation works great. And yes, there are some crashes sometimes (that I find quite easy to debug thanks to the built-in debugger), but take for example a similar app that's built with Rust and Dart[3], in my testing there were still memory leaks that caused my computer to hang. It's better to know you have a bug than for it to be hidden from you.
I agree with parent commenter, saying these cross-platform frameworks will end up supporting the least common denominator set of features. But I found with external open source libraries, the community is catching up very fast. For example, you want the awesome translucency macOS apps have for your Qt app? Here you go[4]. Many such cases. It's also pretty straightforward to add your own custom OS-dependent code, especially so, if someone already open sourced his approach. I recently wanted to move the traffic light buttons on macOS for my app, but couldn't figure the Objective-C code for that. I ended up looking at either Tauri or Electron source code and found my answer.
[1] https://github.com/woboq/qmetaobject-rs
-
I like rust but want to use Qt.
I just used qmetaobject-rs and my experience with Qt/QML. There's the QML book from Qt if you're just starting, which is pretty nice https://www.qt.io/product/qt6/qml-book
You can use cxx-qt or qmetaobject-rs. Or use Slint
- GUI development with Rust and GTK 4
-
Made my first app in Rust! A notification daemon for Linux :)
qmetaobject is probably the most mature Qt Rust binding at the moment. It uses the cpp crate to embed C++ inline in Rust to create its bindings. There are some people using it and it does get some maintenance, but it's not under active development since the original author is now working on Slint.
-
Using KConfig with Rust
The bindings currently use the git version of qttypes since I had to merge some upstream changes that are needed for these bindings. So they are not ready for prime time just yet.
-
CXX-Qt: safe Rust bindings for Qt
- It does support plugins: https://github.com/woboq/qmetaobject-rs/tree/master/examples...
I wonder what problems from the list apply to another existing and more mature solution: https://github.com/woboq/qmetaobject-rs/
There are a bunch of bindings with different language, but even the ones that are officially supported like PySide will still be second class citizen and awkward to use.
Automated binding generation will never give you idiomatic API in whatever language. And if you want an idiomatic library that wraps Qt, it's going to take a huge amount of work.
Which is why I think restricting to QML makes sense because that's a much smaller API surface. That was the ambition behind my previous crate that exposes QML to rust: https://github.com/woboq/qmetaobject-rs/
But now I've moved on to another GUI project: Slint https://github.com/slint-ui/slint
-
Why does Rust code compile into a single executable binary?
Whisperfish does this with Qt: https://github.com/woboq/qmetaobject-rs/issues/102
min-sized-rust
-
The Linux Kernel Prepares for Rust 1.77 Upgrade
This is a good guide on building small Rust binaries: https://github.com/johnthagen/min-sized-rust
This talks about going to extreme lengths on making the smallest Rust binary possible, 400 bytes when it was written, https://darkcoding.net/software/a-very-small-rust-binary-ind...
The thing is, you lose a lot of nice features when you do this, like panic unwinding, debug symbols, stdlib… for kernel and some embedded development it’s definitely important, but for most use cases, does it matter?
-
Making Rust binaries smaller by default
Are you sure? If so then this is awesome news, but I'm a bit confused; the commit in that min-sized-rust repo adding `build-std` to the README was merged in August 2021: https://github.com/johnthagen/min-sized-rust/pull/30
Are you saying that at that point the feature still hadn't "landed in Rust nightly" until recently? If so then what's the difference between a feature just being available in Rust nightly, vs having "landed"?
It's really a shame that Rust includes the stdlib piecemeal in binary form, debug symbols and all, in every resulting binary.
I do love Rust but binary sizes have always annoyed me greatly and I always had this nagging feeling that part of all programmers don't rake Rust seriously because of that. And I actually have witnessed, several times in the last 2-ish years, older-school programmers berate and ignore Rust on that basis alone (so the author is quite right to call this out as a factor).
Looking at the https://github.com/johnthagen/min-sized-rust repo, final binary size of 51 KB when compilation / linking / stripping takes stdlib into account (and not just blindly copy-pasting the 4MB binary blob) is acceptable and much more reasonable. I wouldn't care for further micro-optimizations e.g. going to 20KB or even 5KB (further down the README file).
I also don't use nightly in my Rust work so I guess I'll have to wait several more years. :(
My go to reference when I want to reduce rust binary size is the excellent https://github.com/johnthagen/min-sized-rust, a set of guidelines on how to reduce size with explanations of the consequences
-
Was Rust Worth It?
Rust binaries are by default nowhere close to 500MB. If they are not small enough for you, you can try https://github.com/johnthagen/min-sized-rust. By avoiding the formatting machinery and using `panic_immediate_abort` you can get about the size of C binaries.
- Error on flashing embedded code to stm32f103
-
Shared libraries
This is not quite what you're asking, but it does also address the underlying concern: https://github.com/johnthagen/min-sized-rust
-
Announcing lavagna v2, a collaborative blackboard made with bevy and WebRTC
And what about the binary size? Applying some cheats found in the Unofficial Bevy Cheat Book and in the Minimizing Rust Binary Size article I’ve achieved to fit the whole wasm binary in less than 10M, which become 2.8M when gzip compressed.
-
Which GUI toolkit for Rust today.. few questions...
Rust binaries are so huge because the default settings turn off most size optimizations to reduce compile times. Read through this page.
What are some alternatives?
Slint - Slint is a toolkit to efficiently develop fluid graphical user interfaces for any display: embedded devices and desktop applications. We support multiple programming languages, such as Rust, C++ or JavaScript. [Moved to: https://github.com/slint-ui/slint]
slint - Slint is a declarative GUI toolkit to build native user interfaces for Rust, C++, or JavaScript apps.
smartstring - Compact inlined strings for Rust.
wxRust - A Rust binding of the wxWidgets cross platform toolkit.
Rust Qt Binding Generator git - Generate bindings to use Rust code in Qt and QML
Native Windows GUI - A light windows GUI toolkit for rust
ritual - Use C++ libraries from Rust
Azul - Desktop GUI Framework
c2rust - Migrate C code to Rust
Cargo - The Rust package manager
rustc_codegen_gcc - libgccjit AOT codegen for rustc
regex - An implementation of regular expressions for Rust. This implementation uses finite automata and guarantees linear time matching on all inputs.