Skip to content

Commit 6d4dc03

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 6d4dc03

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-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: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@
55

66
#[cxx::bridge]
77
mod ffi {
8+
unsafe extern "C++" {
9+
#[cfg(any(cxxqt_qt_version_at_least_7, cxxqt_qt_version_at_least_6_5))]
10+
include!("cxx-qt-lib/qanystringview.h");
11+
type QAnyStringView<'a> = crate::QAnyStringView<'a>;
12+
}
13+
814
unsafe extern "C++" {
915
include!("cxx-qt-lib/qstring.h");
1016
type QString = crate::QString;
@@ -36,6 +42,16 @@ mod ffi {
3642
/// Loads the root QML file located at url.
3743
fn load(self: Pin<&mut QQmlApplicationEngine>, url: &QUrl);
3844

45+
/// Loads the QML type typeName from the module specified by uri.
46+
/// This function was introduced in Qt 6.5.
47+
#[cfg(any(cxxqt_qt_version_at_least_7, cxxqt_qt_version_at_least_6_5))]
48+
#[rust_name = "load_from_module"]
49+
fn loadFromModule(
50+
self: Pin<&mut QQmlApplicationEngine>,
51+
uri: QAnyStringView,
52+
typeName: QAnyStringView,
53+
);
54+
3955
/// This property holds the directory for storing offline user data
4056
#[rust_name = "offline_storage_path"]
4157
fn offlineStoragePath(self: &QQmlApplicationEngine) -> QString;

0 commit comments

Comments
 (0)