自定义QML模块部署到Android:缺少QML依赖项 [英] Custom QML module deployment to Android: QML dependencies missing

查看:46
本文介绍了自定义QML模块部署到Android:缺少QML依赖项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个包含一些特殊类型的自定义QML模块(我们称其为MyModule).它用作其他应用程序项目上的预编译库(即源代码不可用,可通过import MyModule 1.0使用,设置必要的导入路径等).该模块包含基于C ++的QML类型以及本身导入QtQuick模块(例如QtQuick.Controls和QtQuick.Window)的QML文件.

Im developing a custom QML module (let's call it MyModule) containing some special types. It is used as precompiled library on other application projects (i.e. the source code is not available to them, it's used via import MyModule 1.0, setting the necessary import paths etc.). The module contains C++-bases QML types as well as QML files that themselves import QtQuick modules like QtQuick.Controls and QtQuick.Window.

当我尝试将使用MyModule开发的应用程序部署并执行到Android时,androiddeployqt/qmlimportscanner不会拾取MyModule的依赖项,而是将其包含在APK中,从而导致显示如下消息: module"QtQuick.Controls未安装

When I try to deploy and execute an application developed using MyModule to Android, the dependencies of MyModule are not picked up by androiddeployqt/qmlimportscanner and included in the APK, which results in messages like: module "QtQuick.Controls" is not installed

是否有一种方法可以将这些QML依赖项包含在APK中,而不必在应用程序源目录中创建一个包含所有导入内容的虚拟qml文件,以便可以由qmlimportscanner进行提取?

Is there a way to have these QML dependencies included in the APK without having to create a dummy qml file containing all imports in the applications source directory, so they can be picked up by qmlimportscanner?

推荐答案

您可以尝试添加

You can try adding the depends keyword to your qmldir file:

声明此模块依赖于另一个模块.

Declares that this module depends on another.

示例:

依赖于MyOtherModule 1.0

仅在隐藏了依赖项的情况下才需要此声明:例如,当一个模块的C ++代码用于(可能有条件地)加载QML时,QML则依赖于其他模块.在这种情况下,必须将depends声明包括在应用程序包中.

This declaration is necessary only in cases when the dependency is hidden: for example, when the C++ code for one module is used to load QML (perhaps conditionally) which then depends on other modules. In such cases, the depends declaration is necessary to include the other modules in application packages.

要获得一些启发,请查看以下内容:

For some inspiration, check out this one:

http://code.qt.io/cgit/qt/qtquickcontrols2.git/tree/src/imports/controls/qmldir

这篇关于自定义QML模块部署到Android:缺少QML依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆