pub struct QmlModule { /* private fields */ }Expand description
This is a description of a QML module for building by the crate::CxxQtBuilder.
It allows registering QML files that will be included in the QML module. For further resources such as images, these can be added to the Qt resources system via the appropriate CxxQtBuilder functions.
Implementations§
Source§impl QmlModule
impl QmlModule
Sourcepub fn depends<T: Into<QmlUri>>(
self,
depends: impl IntoIterator<Item = T>,
) -> Self
pub fn depends<T: Into<QmlUri>>( self, depends: impl IntoIterator<Item = T>, ) -> Self
Add multiple QML module dependencies
Sourcepub fn version(self, version_major: usize, version_minor: usize) -> Self
pub fn version(self, version_major: usize, version_minor: usize) -> Self
Add a version to the QML module.
The default version is 1.0.
Sourcepub fn plugin_type(self, plugin_type: PluginType) -> Self
pub fn plugin_type(self, plugin_type: PluginType) -> Self
Specify the plugin type for the QML module (PluginType::Static by default).
§Limitations of dynamic plugins
Warning: The following limitations apply to building QML modules with PluginType::Dynamic:
§Crate must be built to cdylib
Even though it is possible to build both a staticlib and cdylib from one crate, any
crate that uses PluginType::Dynamic for the QML module must build to cdylib.
The QML module will not work as expected if built into a staticlib.
§Only One Dynamic Plugin Per Library
There can only be one dynamic QML module plugin per dynamic library. This also applies to sub-crates, so no sub-crate in the dependency tree can build to a dynamic QML module plugin if the main crate is already doing so.
§Final binary should be built with CXX-Qt-CMake
Any binary that loads a dynamic QML module plugin expects a certain file layout of the qmldir and dynamic library files. The easiest way to ensure this is to build the final binary with CXX-Qt-CMake. CXX-Qt does not currently provide any way to generate the required file layout with pure Cargo builds. Prefer building static QML module plugins when building with Cargo only.
§MSVC Runtime Compatibility on Windows
As outlined in the CXX-Qt book, Rust always links to the release runtime under MSVC on Windows. To ensure compatibility when loading dynamic QML module plugins, CXX-Qt will set the QT_NO_DEBUG definition when compiling the C++ code for dynamic QML module plugins under MSVC. This will disable debug features in Qt, even when building a debug build of the Rust crate.
Sourcepub fn qml_file(self, file: impl Into<QmlFile>) -> Self
pub fn qml_file(self, file: impl Into<QmlFile>) -> Self
Add a single QML file to the module.
If the Qml file starts is uppercase, it will be treated as a QML component and registered in the qmldir file.
See QmlFile for more information on configuring the behavior of QML files.
The crate::CxxQtBuilder will register the file with the Qt Resource System in
the default QML import path qrc:/qt/qml/uri/of/module/.
When using Qt 6, the crate::CxxQtBuilder will run qmlcachegen
to compile the specified .qml file ahead-of-time.
Additional resources such as images can be added to the Qt resources for the QML module by using the crate::CxxQtBuilder::qrc_resources or crate::CxxQtBuilder::qrc functions.
Note that if no version is specified for the QML file, the version of the QML module will be used automatically.
Sourcepub fn qml_files(
self,
files: impl IntoIterator<Item = impl Into<QmlFile>>,
) -> Self
pub fn qml_files( self, files: impl IntoIterator<Item = impl Into<QmlFile>>, ) -> Self
Add multiple QML files to the module, see Self::qml_file.