I want to import a custom module in my main.qml
file. Main.qml
is located under "/"
prefix of my qml.qrc
resource.
My custom module Config.qml
is located within Config
subdirectory. (Config
directory is where main.qml
is, i.e. /path/to/main/Config/Config.qml
.
The config.qml
and qmldir
files are stored under the prefix myPrefix
in the qml.qrc
file.
Project
|- Config
|- Config.qml
|- qmldir
|- main.qml
Also I created a qmldir
file which is according to the documentation http://doc.qt.io/qt-5/qtqml-modules-identifiedmodules.html necessary. Here are my Config.qml
and qmldir
files.
Config.qml
pragma Singleton
import QtQuick 2.0
QtObject {
property int myVariable: 10
}
qmldir
singleton Config 1.0 Config.qml
When I want to import my custom module asMyModule
in the main.qml
file.
import "???" as MyModule
How can I do that? Does someone have a suggestion?
Edit:
qrc file
<RCC>
<qresource prefix="/">
<file>main.qml</file>
</qresource>
<qresource prefix="/myPrefix">
<file>Config/qmldir</file>
<file>Config/Config.qml</file>
</qresource>