Unsolved How to force QML to import local file component first and foremost?
-
I'm new to QML (although I did already spend a lot of time evaluating and trying out things), and I am trying to wrap my head around the import order and logic when importing components.
I would like to deliver my application with all the qml files as part of the resources. So far so good, no problems there (that I couldn't fix myself).
However, for design purposes, I would like to allow a "design test mode" for my application: In this mode, files would be loaded from the file system first and foremost. Ideally, the remaining files would be loaded from the resources (but I could live with having to copy all qml files to the file system if that's what it takes to make it work).The problem is, QML seems to implicitly use resource paths as valid import folders, so it keeps finding my QML files in the resources ahead of those on the file system.
Here is what I tried:
- I wrote my main QML scene file names "helloworld.qml". I have the file both in my resources and on the local file system.
- I wrote a QWidget wrapper around QQuickView and use that to show "helloworld.qml"
- I wrote a simple resolver that decides whether to load "helloworld.qml" from resources or local disk. Then I use QQuickView::setSource to load the correct QML file. Works like a charm.
- I created a component named "NamedComponent" in the same resource file and prefix as "helloworld.qml"
- I use QQmlEngine::setImportPathList to define the order in which imports should happen. First, the path on the local disk, then the path to my resources, last the path to the standard QML components.
For some reason, 5) doesn't seem to do any good. Even if I completely remove my resource path from the ImportPathList, "NameComponent" will always be loaded from resources, never from disk.
Any ideas or suggestions?