I’ll try to answer your questions:
- I think installed means they are located in the proper paths, so
that they can be found at runtime - You should not necessarily create/build a
QmlExtensionPluginfor that purpose. You can also use as a module plain QML files in one
directory with aqmldirdescribing this module. It is a matter of
distributing your code. WithQmlExtensionPluginyou provide the
module compiled, if you want to hide the code. - The modules can be in resources system or as files on disk, it is up to you.
- The app looks for modules in predefined paths – in your app’s directory, in Qt plugins path, in
QML2_IMPORT_PATH, in directories that you added usingengine->addImportPath()
There are a bunch of things that can lead to a module not being loaded. You can check the following:
- Module identifier in
qmldirshould be the same as the directory
name, where the module actually resides. For example if your module
has module identifiermodule Test.Moduleinqmldir, your module’s
relative path must beTest/Module. - If it is a QML extension
plugin (shared library), make sure that plugin’s directory name is
the same as plugin’s name. - export
QML2_IMPORT_PATH(make sure there is2in the name) env variable to point to directory containing your module. There is also aQQmlEngine::addImportPathmethod, which adds the directory to the list to lookup for plugins. - If it is a qml extension plugin (shared library), then there might be missing dependencies for it. You can check it by Dependency Walker on Windows or
lddcommand on Linux. - Setting
QT_PLUGIN_PATHruntime variable may help to load plugins. It should point to a directory containing you plugin’s directory, not the plugin’s directory itself. - You can also enable traces to see what’s going on while plugins are loaded for better understanding of the problem – export
QT_DEBUG_PLUGINS=1andQML_IMPORT_TRACE=1environment variables
You can also read this link:
https://doc.qt.io/qt-5/qtqml-modules-identifiedmodules.html