Skip to content

Commit

Permalink
cxx-qt-lib: Add binding for QQmlApplicationEngine::loadFromModule
Browse files Browse the repository at this point in the history
This function was added in Qt 6.5, as an alternative from loading files
by file path.
  • Loading branch information
redstrate committed Dec 10, 2024
1 parent f5afefe commit 3232bc3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- QObject subclasses can now inherit from other CXX-Qt generated QObject classes
- `BUILD_WASM` CMake option to support WebAssembly builds and a book page for building for WASM
- Add support for cxx_name and rust_name on qproperty attributes which applies to the QProperty generated as well as functions
- Add support for loading QML files in `QQmlApplicationEngine` from modules with `loadFromModule`.

### Changed

Expand Down
8 changes: 8 additions & 0 deletions crates/cxx-qt-lib/src/qml/qqmlapplicationengine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ mod ffi {
type QStringList = crate::QStringList;
include!("cxx-qt-lib/qurl.h");
type QUrl = crate::QUrl;
include!("cxx-qt-lib/qanystringview.h");
type QAnyStringView<'a> = crate::QAnyStringView<'a>;

include!("cxx-qt-lib/qqmlapplicationengine.h");
type QQmlApplicationEngine;
Expand All @@ -36,6 +38,12 @@ mod ffi {
/// Loads the root QML file located at url.
fn load(self: Pin<&mut QQmlApplicationEngine>, url: &QUrl);

/// Loads the QML type typeName from the module specified by uri.
/// This function was introduced in Qt 6.5.
#[cfg(any(cxxqt_qt_version_at_least_7, cxxqt_qt_version_at_least_6_5))]
#[rust_name = "load_from_module"]
fn loadFromModule(self: Pin<&mut QQmlApplicationEngine>, uri: QAnyStringView, typeName: QAnyStringView);

/// This property holds the directory for storing offline user data
#[rust_name = "offline_storage_path"]
fn offlineStoragePath(self: &QQmlApplicationEngine) -> QString;
Expand Down

0 comments on commit 3232bc3

Please sign in to comment.