I\'m confused about modules in Qt QML. I\'ve read all the docs, but it doesn\'t make clear some basic ideas.
I understand that i can put a bunch of QML files into a
I'll try to answer your questions:
QmlExtensionPlugin for that purpose. You can also use as a module plain QML files in one
directory with a qmldir describing this module. It is a matter of
distributing your code. With QmlExtensionPlugin you provide the
module compiled, if you want to hide the code.QML2_IMPORT_PATH, in directories that you added using engine->addImportPath()There are a bunch of things that can lead to a module not being loaded. You can check the following:
qmldir should be the same as the directory
name, where the module actually resides. For example if your module
has module identifier module Test.Module in qmldir, your module's
relative path must be Test/Module.QML2_IMPORT_PATH (make sure there is 2 in the name) env variable to point to directory containing your module. There is also a QQmlEngine::addImportPath method, which adds the directory to the list to lookup for plugins.ldd command on Linux.QT_PLUGIN_PATH runtime variable may help to load plugins. It should point to a directory containing you plugin's directory, not the plugin's directory itself.QT_DEBUG_PLUGINS=1 and QML_IMPORT_TRACE=1 environment variablesYou can also read this link: https://doc.qt.io/qt-5/qtqml-modules-identifiedmodules.html