Skip to content

Commit 3232bc3

Browse files
committed
cxx-qt-lib: Add binding for QQmlApplicationEngine::loadFromModule
This function was added in Qt 6.5, as an alternative from loading files by file path.
1 parent f5afefe commit 3232bc3

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3838
- QObject subclasses can now inherit from other CXX-Qt generated QObject classes
3939
- `BUILD_WASM` CMake option to support WebAssembly builds and a book page for building for WASM
4040
- Add support for cxx_name and rust_name on qproperty attributes which applies to the QProperty generated as well as functions
41+
- Add support for loading QML files in `QQmlApplicationEngine` from modules with `loadFromModule`.
4142

4243
### Changed
4344

crates/cxx-qt-lib/src/qml/qqmlapplicationengine.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ mod ffi {
1212
type QStringList = crate::QStringList;
1313
include!("cxx-qt-lib/qurl.h");
1414
type QUrl = crate::QUrl;
15+
include!("cxx-qt-lib/qanystringview.h");
16+
type QAnyStringView<'a> = crate::QAnyStringView<'a>;
1517

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

41+
/// Loads the QML type typeName from the module specified by uri.
42+
/// This function was introduced in Qt 6.5.
43+
#[cfg(any(cxxqt_qt_version_at_least_7, cxxqt_qt_version_at_least_6_5))]
44+
#[rust_name = "load_from_module"]
45+
fn loadFromModule(self: Pin<&mut QQmlApplicationEngine>, uri: QAnyStringView, typeName: QAnyStringView);
46+
3947
/// This property holds the directory for storing offline user data
4048
#[rust_name = "offline_storage_path"]
4149
fn offlineStoragePath(self: &QQmlApplicationEngine) -> QString;

0 commit comments

Comments
 (0)