Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
[Solved] Resources and folders
I need a little help here.
I want to save qmls in folders so they are easier to find and work with, but I don't know how to deal with the resources system when doing this. (If all files are saved in the same directory it works fine but it's a mess)
So let's say that my filesytem is:
And that my resource file follows the same hierarchy.
If I try to load keyboard component from main.qml such as
qtcreator complains that it doesn't know what "Keyboard" is, so I guess it has something to do with imports.
I've tried lots of combinations but none of them worked.
Vincent007 last edited by
Thank you. Unfortunately this only works if I don't use the qt resource system.
If I use it, so my resource file looks like this:
And my main.cpp looks like this:
int main(int argc, char *argv)
QGuiApplication app(argc, argv);
QtQuick2ApplicationViewer viewer; viewer.setSource(QUrl("qrc:/qml/Main/qml/test4/Main/main.qml")); viewer.showExpanded(); return app.exec();
This doesn't work anymore
eliseev last edited by
You shall remove prefixes. QRC file shall look something like that:
Then relative paths act as they are on real FS.
Note, most likely you will have to modify QtQuick2ApplicationViewer::setSource to get it working with QRC-based system, "see here":http://stackoverflow.com/questions/20104514/how-to-load-qml-file-from-resources-using-qtquick-2-controls
Thank you. That worked.
I was expecting that I could maintain the same hierarchy on the resources file too so it could be cleaner and more organized, but it seems that you can't do that.
Anyway, this solutions is good enough for me since it allows me, at least, to keep my files organized.