- Notifications
You must be signed in to change notification settings - Fork42
QtQuick interface for Rust
License
Apache-2.0, MIT licenses found
Licenses found
cyndis/qmlrs
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
qmlrs -QtQuick bindings for Rust
qmlrs allows the use of QML/QtQuick code from Rust, specifically
- Rust code can create a QtQuick engine (QQmlApplicationEngine) with a loaded QML script
- QML code can invoke Rust functions
…with certain limitations. The library should be safe (as in notunsafe
) to use, but no promisesat this time. Reviews of the code would be welcome.
See theChangelog for the version history and what's waiting in master to be released.
The library consists of a Rust part and a C++ part. The C++ part will be compiled automaticallywhen building with Cargo. You will needcmake
, Qt5 and a C++ compiler that can compile Qt5 code.Your Qt5 installation should have at least the following modules: Core, Gui, Qml, Quick and Quick Controls.
If you are installing Qt5 from source, please note that passing "-noaccessibility" to the configurescript disables the qtquickcontrols module.
Add the latest version of qmlrs fromcrates.io in your project'sCargo.toml
.
This is the Rust code for an application allowing the calculation of factorials.You can find the corresponding QML code in theexamples
directory.
#[macro_use]externcrate qmlrs;structFactorial;implFactorial{fncalculate(&self,x:i64) ->i64{(1..x+1).fold(1, |t,c| t* c)}}Q_OBJECT!{Factorial: slotfn calculate(i64);}fnmain(){letmut engine = qmlrs::Engine::new(); engine.set_property("factorial",Factorial); engine.load_local_file("examples/factorial_ui.qml"); engine.exec();}
To run the above example, executecargo run --example factorial
in the project's root directory.
Creating anEngine
automatically initializes the Qt main event loop if one doesn't already exist.At least on some operating systems, the event loop must run on the main thread. Qt will tell youif you mess up. The.exec()
method on views starts the event loop. This will block the threaduntil the window is closed.
The code in this library is dual-licensed under the MIT license and the Apache License (version 2.0).SeeLICENSE-APACHE andLICENSE-MIT for details.
About
QtQuick interface for Rust
Resources
License
Apache-2.0, MIT licenses found
Licenses found
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors8
Uh oh!
There was an error while loading.Please reload this page.