qt - QML importing module -


i want import custom module in main.qml file. main.qml located under "/" prefix of qml.qrc resource.

my custom module config.qml located within config subdirectory. (config directory main.qml is, i.e. /path/to/main/config/config.qml.

the config.qml , qmldir files stored under prefix myprefix in qml.qrc file.

project |- config     |- config.qml     |- qmldir |- main.qml 

also created qmldir file according documentation http://doc.qt.io/qt-5/qtqml-modules-identifiedmodules.html necessary. here config.qml , qmldir files.

config.qml

pragma singleton import qtquick 2.0 qtobject {     property int myvariable: 10 } 

qmldir

singleton config 1.0 config.qml 

when want import custom module asmymodule in main.qml file.

import "???" mymodule 

how can that? have 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> 

from documentation:

the module's qmldir file must reside in directory structure within import path reflects uri dotted identifier string, each dot (".") in identifier reflects sub-level in directory tree. example, qmldir file of module com.mycompany.mymodule must located in sub-path com/mycompany/mymodule/qmldir somewhere in import path.

so should change module mymodule module config or import within specific path:

import "./config" mymodule 

Comments

Popular posts from this blog

java - Suppress Jboss version details from HTTP error response -

gridview - Yii2 DataPorivider $totalSum for a column -

Sass watch command compiles .scss files before full sftp upload -