Directory imports when using a QRC resource file with prefixes
-
We have an application that has quite a lot of different views and controls - to keep things tidy, we have the files in different directories, and reference files within the directory structure using relative paths. The files are included in our application using the resource system.
This works with qmlscene and with the built application when there are no prefixes in the QRC file, but doesn't work in the application when prefixes are introduced. (Without prefixes, opening the QRC file in Creator shows a flat list of almost a hundred files - with prefixes, there's a folder structure, so the prefixes are nice to have.)
A quick example:
-
MainApplicationWindow.qml,
import "views" ApplicationWindow { SomeView {} }
Relative to MainApplicationWindow.qml, the file SomeView.qml is located at directory views/SomeView.qml.
It works with the QRC entry
<qresource prefix="/"> <file>MainApplicationWindow.qml</file> <file>views/SomeView.qml</file> </qresource>
but when the QRC entry is
<qresource prefix="/"> <file>MainApplicationWindow.qml</file> </qresource> <qresource prefix="/views"> <file>views/SomeView.qml</file> </qresource>
I get the runtime error "SomeView is not a type." Any ideas how to get this to work?
-
-
Thanks for the suggestion - it works now with the built application (albeit with problems caused by relative paths in the QML files in subfolders), but not with qmlscene ("views/views": no such directory). It'd be really nice to find a solution that works with both, and takes in both the need for a file structure with subfolders and a QRC file with prefixes...