Solved How to implementing qml module identified?
-
I'm confused about implementing Use QML Module with Plugin, there are my references
https://doc.qt.io/qt-5/qtqml-modules-identifiedmodules.html#semantics-of-identified-modules
https://doc.qt.io/qtcreator/creator-qml-modules-with-plugins.htmlMy goal is I can import my custom QML modules as "import My.Modules 1.0" then QtDesign/QML-Preview can render it.
Here my project directory structure and error what I get:
On the popup message, said that I already added my custom QML module path to QML_IMPORT_PATH, but QtCreator still said can not find the module.
How to resolve it?
My Tools: MacOS Catalina + Qt5.14
-
@kangherr , you can add
QML_IMPORT_PATH = $$PWD
in your .pro file and make sure haveengine.addImportPath("qrc:/");
in your main.cpp file. -
@Quang-Phu Thanks for your reply but still not work on my project.
Here my code:
https://github.com/mangherr769/QtUsingModuleWithPluginFeel free to modify my code to show the working example. Thanks.
-
@kangherr ,
It seems you have to create other resource file (*.qrc) to import as a module.
https://github.com/1799/QtUsingModuleWithPlugin
This source code works, you can try it. -
@Quang-Phu Oh Ok it's work, just to separate the component's resources with main QML resources. Thanks.