I'm trying to import the modules from papyros to my application. For that I cloned the repo, and then I added the modules path to the QML2_IMPORT_PATH env var.
The papyros is already with the qmldir files set correctly, so all I'd to do is to add the dirs to the QML2_IMPORT_PATH
i.e: If the qmldir is inside /myhome/qml-material/modules/Material dir, then I added the /myhome/qml-material/modules/Material to the QML2_IMPORT_PATH var.
I also tried to add using:
engine.addImportPath("/myhome/qml-material/modules/Material");
in the main.cpp just before load the main qml file.
Nothing seems to be working, I can't import the components inside my app and the Qt Creator code completion completely ignore the new dirs. I tried to add in several different ways:
import modules.Material.Action 0.1
import Material.Action 0.1
import Action 0.1
But I keep receiving the error: module "Module name" is not installed
The only way it works is using the full path:
import "/myhome/qml-material/modules/Material/Action.qml" as Action
But, of course, it's not what I want to.
Any idea how can I solve that?
答案 0 :(得分:3)
你应该做engine.addImportPath("/myhome/qml-material/modules/");
不是engine.addImportPath("/myhome/qml-material/modules/Material");
因为当你写import Material 0.1
时,Qt将搜索一个名为Material的文件夹,如果你已经在其中,这将无效。