[SOLVED] Import directory in QML
-
wrote on 3 Oct 2014, 17:32 last edited by
Hello,
I've been reading the documentation on importing directories in QML: http://qt-project.org/doc/qt-5/qtqml-syntax-directoryimports.html
and what I am trying to do is not working.I have a QML file that imports an absolute path in another drive:
@import QtQuick 2.0
import "D:/My Documents/SametimeFileTransfers/importsTest/Level3/"Rectangle {
width: 800
height: 600
Text {
anchors.centerIn: parent
text: "Hello World"
}
MouseArea {
anchors.fill: parent
onClicked: {} } Cuadro{ id: yo color:"red" MouseArea { anchors.fill: parent onClicked: { yo.color="yellow"; yo.cambia("hola"); } } }
}
@According to the documentation, importing an absolute path is available but it's not working for me.
So I don't know if importing a directory in another drive will work. Right now I have the file "main.qml" located somewhere in drive C: and I would like to import a QML directory located in drive D:
If this is possible how can i handle this import?
Any comment regarding this issue is appreciated.
Thanks in advance.
-
wrote on 3 Oct 2014, 19:17 last edited by
Try to use import <dir> as name, example:
import "D:/My Documents/SametimeFileTransfers/importsTest/Level3/" as level3
Then you should be able to use:
level3.<some-file-there>
-
wrote on 3 Oct 2014, 20:24 last edited by
Hello, thanks for your reply.
I tried to import the directory and place an identifier or local namespace, as you explained, but it's also not working :(
-
This directory is outside the qml main files. Try to use QMLEngine.addImportPath(...) and qmldir to define the QML components.
1/5