简体   繁体   English

QML错误:未安装qrc:/Main.qml:24模块“系统”

[英]QML error: qrc:/Main.qml:24 module “system” is not installed

I am new in QML and I have a project. 我是QML的新手,并且有一个项目。 In one of my directories I have /imports/system/qmldir file where I have he following code: 在我的一个目录中,我有/imports/system/qmldir文件,在其中我有以下代码:

singleton System 1.0 System.qml
App 1.0 App.qml

and in my source file I have 在我的源文件中

import system 1.0

And the error says that module system is not installed. 该错误表明未安装模块系统。

qrc:/Main.qml:24 module "system" is not installed

Could you please tell me the steps or flow of installing the module. 您能否告诉我安装模块的步骤或流程。

You must call QQmlEngine::addImportPath() and pass the path to /imports . 您必须调用QQmlEngine::addImportPath()并将路径传递到/imports

int main(int argc, char *argv[])
{
    QGuiApplication app(argc, argv);

    QQmlApplicationEngine engine;
    engine.addImportPath("/path/to/imports"); // <==
    engine.load(...);

    return app.exec();
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM