首页 文章

QML模块未找到错误

提问于
浏览
3

使用QtCreator时,我在编辑器中显示qml文件 . qml文件用于名为 main.qml 的文件,该文件是一个插件 .

然后我点击 Design 按钮 . 它显示错误消息: QML module not found .

如果我使用 Go to error 链接,它将转到包含以下 import com.name.os.app.all 1.0 的行 . 这是插件所需的各种组件qml文件的位置 .

我已将路径 c:\users\me\ui\viewer\ 添加到我的 QML_IMPORT_PATH env 变量中 . 如果QtCreater将qml文件import语句中的 com.name... 附加到我添加到 QML_IMPORT_PATH 的路径名,它将找到所需的目录 . 它没有 .

该项目使用qmake .

我已经尝试使用 qmlplugindump.exe 为我的主qml视图容器文件生成 qmltypes 文件,但是 qmlplugindump.exe 给了我一个错误,说 component is not readyfile::///c:/Users/name/ui/viewer/modules/app/qml/com/name/os/app/all/typelist.qml:2:1 module MyViewContainer.qml is not installed .

我使用的命令是 qmlplugindump.exe MyViewContainer.qml 1.0 c:\users\myname\ui\viewer\modules\app\qml\com\name\os\app\all\ > ...

3 回答

  • 1

    你是否完全测试了这个插件?我问这个是因为我写了很多插件并多次遇到这个问题 . 可能的问题包括您正在使用的Qt版本,以及插件uri / classname中的某种形式的命名错误 .

    我有一个应用程序,我为Qt的多个版本构建,似乎qmlplugindump工具具有不同的有效性水平 .

    很抱歉这么一般,但希望它指出你正确的方向 .

  • 1

    From within QtCreator, do a "project-clean", and then rebuild. The module will be found.

    我遇到了同样的问题,偶然发现了你的问题 . 经过一番努力,“清洁”和重建工作 .

    在构建过程中似乎有"incomplete-dependency-checking" "understand"需要重建 main.cpp ,然后将公开 qmlRegisterType<MyType>() 以便可以在 main.qml 中找到它 .

  • 1

    This Error Ruin My Life
    Real Solution for "QML module not found error":
    让我们说如果你在这样的目录中有插件,里面有qmldir "myproject/modules/mymodule/blabla.qmldir"
    你需要在".pro"文件中导入这样的父目录:

    QML_IMPORT_PATH += $$PWD/modules
    

    不喜欢这个(这个不会工作):
    QML_IMPORT_PATH = $$ PWD / modules / mymodule
    // ---------------------------------------------
    边注:
    这将发生在qml的其他部分,就像 qmlplugindump 你需要给父目录不精确的文件夹!但 windeployqt 正在使用exact文件夹

    例如:

    qmlplugindump KiMa 1.0 C:\Users\Administrator\Documents\DynamicView\3rdparty > C:\Users\Administrator\Documents\DynamicView\3rdparty\KiMa\KiMa.qmltypes
    

    // ---------------------------------------------
    第二个最重要的部分是 QML emulation layer
    在Qt Creator中去 tools->option->Qt Quick->Qt Quick Designer
    选择“ Use Qml emulation layer that is built with the selected qt
    如果已经选中了那个"Top level build path"下的文本框
    它应该引用Qt版本bin目录,它应该与插件Qt版本相同:

    ..\5.12.1\msvc2017\bin
    

    对我来说:(它应该与你用于套件和blabla的版本相同)

    C:\QtN\5.12.1\msvc2017\bin
    

    它不应该像这样:

    C:\用户\管理\应用程序数据\漫游\ QtProject \ qtcreator \ qmlpuppet
    不要忘记在插件中添加新项目后部署(cmd命令):

    windeployqt --qmldir C:\Users\Administrator\Documents\DynamicView C:\Users\Administrator\Documents\build-DynamicView-5_12-Debug\debug
    

    和插件转储:

    qmlplugindump KiMa 1.0 C:\Users\Administrator\Documents\DynamicView\3rdparty > C:\Users\Administrator\Documents\DynamicView\3rdparty\KiMa\KiMa.qmltypes
    

    在此之后,如果QtCreator为插件中的新对象提供错误,则需要重启QtCreator,这就是它!

    如果仍然有问题你需要 - 全部清理 - 运行Qmake - 重建所有解决了这么多问题 .

相关问题