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
QmlExtensionPlugin
for that purpose. You can also use as a module plain QML files in one
directory with aqmldir
describing this module. It is a matter of
distributing your code. WithQmlExtensionPlugin
you 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
qmldir
should be the same as the directory
name, where the module actually resides. For example if your module
has module identifiermodule Test.Module
inqmldir
, 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 is2
in the name) env variable to point to directory containing your module. There is also aQQmlEngine::addImportPath
method, 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
ldd
command on Linux. - Setting
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. - 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=1
andQML_IMPORT_TRACE=1
environment variables
You can also read this link:
https://doc.qt.io/qt-5/qtqml-modules-identifiedmodules.html