{"id":13439698,"url":"https://github.com/cyndis/qmlrs","last_synced_at":"2025-04-12T21:26:18.377Z","repository":{"id":24567305,"uuid":"27974723","full_name":"cyndis/qmlrs","owner":"cyndis","description":"QtQuick interface for Rust","archived":false,"fork":false,"pushed_at":"2018-09-17T15:54:04.000Z","size":124,"stargazers_count":437,"open_issues_count":15,"forks_count":43,"subscribers_count":25,"default_branch":"master","last_synced_at":"2024-10-30T00:33:02.289Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cyndis.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-12-13T21:43:42.000Z","updated_at":"2024-09-25T18:48:06.000Z","dependencies_parsed_at":"2022-08-06T03:00:36.955Z","dependency_job_id":null,"html_url":"https://github.com/cyndis/qmlrs","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cyndis%2Fqmlrs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cyndis%2Fqmlrs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cyndis%2Fqmlrs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cyndis%2Fqmlrs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cyndis","download_url":"https://codeload.github.com/cyndis/qmlrs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248633459,"owners_count":21136872,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T03:01:16.356Z","updated_at":"2025-04-12T21:26:18.356Z","avatar_url":"https://github.com/cyndis.png","language":"Rust","readme":"# qmlrs - [QtQuick](http://doc.qt.io/qt-5/qtquick-index.html) bindings for Rust\n\n[![Travis Build Status](https://travis-ci.org/cyndis/qmlrs.svg?branch=master)](https://travis-ci.org/cyndis/qmlrs)\n[![Coverage Status](https://coveralls.io/repos/github/cyndis/qmlrs/badge.svg?branch=master)](https://coveralls.io/github/cyndis/qmlrs?branch=master)\n[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE-MIT)\n[![Apache licensed](https://img.shields.io/badge/license-Apache-blue.svg)](./LICENSE-APACHE)\n[![crates.io](https://img.shields.io/crates/v/qmlrs.svg)](https://crates.io/crates/qmlrs)\n\n![Image of example](https://raw.githubusercontent.com/cyndis/qmlrs/ghstatic/screenshot.png)\n\nqmlrs allows the use of QML/QtQuick code from Rust, specifically\n\n- Rust code can create a QtQuick engine (QQmlApplicationEngine) with a loaded QML script\n- QML code can invoke Rust functions\n\n…with certain limitations. The library should be safe (as in not `unsafe`) to use, but no promises\nat this time. Reviews of the code would be welcome.\n\n## News\n\nSee the [Changelog](./CHANGELOG.md) for the version history and what's waiting in master to be released.\n\n## Requirements\n\nThe library consists of a Rust part and a C++ part. The C++ part will be compiled automatically\nwhen building with Cargo. You will need `cmake`, Qt5 and a C++ compiler that can compile Qt5 code.\nYour Qt5 installation should have at least the following modules: Core, Gui, Qml, Quick and Quick Controls.\n\nIf you are installing Qt5 from source, please note that passing \"-noaccessibility\" to the configure\nscript disables the qtquickcontrols module.\n\n## Usage\n\nAdd the latest version of qmlrs from [crates.io](https://crates.io/crates/qmlrs/) in your project's `Cargo.toml`.\n\n## Example\n\nThis is the Rust code for an application allowing the calculation of factorials.\nYou can find the corresponding QML code in the `examples` directory.\n\n```rust\n#[macro_use]\nextern crate qmlrs;\n\nstruct Factorial;\nimpl Factorial {\n    fn calculate(\u0026self, x: i64) -\u003e i64 {\n        (1..x+1).fold(1, |t,c| t * c)\n    }\n}\n\nQ_OBJECT! { Factorial:\n    slot fn calculate(i64);\n}\n\nfn main() {\n    let mut engine = qmlrs::Engine::new();\n\n    engine.set_property(\"factorial\", Factorial);\n    engine.load_local_file(\"examples/factorial_ui.qml\");\n\n    engine.exec();\n}\n\n```\nTo run the above example, execute `cargo run --example factorial` in the project's root directory.\n\n## Note regarding the Qt event loop and threads\n\nCreating an `Engine` automatically initializes the Qt main event loop if one doesn't already exist.\nAt least on some operating systems, the event loop must run on the main thread. Qt will tell you\nif you mess up. The `.exec()` method on views starts the event loop. This will block the thread\nuntil the window is closed.\n\n## Licensing\n\nThe code in this library is dual-licensed under the MIT license and the Apache License (version 2.0).\nSee [LICENSE-APACHE](./LICENSE-APACHE) and [LICENSE-MIT](./LICENSE-MIT) for details.\n","funding_links":[],"categories":["Libraries","库 Libraries","Rust","库","Binding"],"sub_categories":["GUI","GUI GUI","图形用户界面 GUI"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcyndis%2Fqmlrs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcyndis%2Fqmlrs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcyndis%2Fqmlrs/lists"}