How to import a QML file from a different Directory
I'am trying to use a qml in a different directory than my project directory.
The QT editor is recognises the qml. and Build is successful.
During runtime, there is an error message stating it cannot find the file.
In Main.qml, I am importing test.qml as
import "../Test/" , the path is not being recognised during runtime.
Can you please suggest me a solution for this.?
the import url is resovled from the base url the qml file was loaded from.
Are we talking about qrc or file paths here?
If MainApp/main.qml was loaded via qrc, then there Test/test.qml must also be available within qrc.
you can take a look at my struggle with this:
Could be helpful
the actual correct way to handle this correctly would be via your own qml module:
or as a plugin:
But I don't know more about it. That's as far as I got before something else came along with more priority x)
You can use alias in the qrc file to have all the files in a single directory so that you can use them directly or else you can import the qml stuffs by using import statement (make sure you give the correct path of the file)