How to open other QML files in main.qml (error: no such file or directory)
-
Hello!
According to this article I am not using *.qrc files. Instead of it I have in my *.pro file this peace of code:
RESOURCES += \ app/qtquickcontrols2.conf \ app/main.qml \ $$files(app/pages/*.qml) \ $$files(app/widgets/*.qml)
In result I have very neat Project view without any Resources level...
but here is the problem! In
main.c
this works perfectly:const QUrl url(QStringLiteral("qrc:/app/main.qml"));
but in
main.qml
this is problem:StackView { id: stackView initialItem: "pages/HomeFrom.ui.qml" // I've tried "app/pages/HomeFrom.ui.qml" and just "HomeFrom.ui.qml" too :-) anchors.fill: parent }
Specifically it is this error:
W libFaceHasherExh_x86.so: qrc:/app/main.qml:64:5: QML StackView: initialItem: qrc:/app/pages/HomeFrom.ui.qml:-1 No such file or directory
Can you please tell what am I doing wrong? Thank you very much!
PS: I almost forgot... this is showing in my General messages. Do you know what is means?
/home/frantisek/Tools/Qt/5.15.0/android/mkspecs/features/android/android_deployment_settings.prf(78): contains(): Encountered invalid regular expression '.*\qmake_qmake_immediate.qrc$'.
-
I think the issue may be that you wrote
HomeFrom
instead ofHomeForm
😜
Edit:
Protip to prevent such typos: Right click in your project tree on the target file, select copy path or copy url and simply paste it in your codeedit sniped by @sierdzio 😉 -
@fpartl said in How to open other QML files in main.qml (error: no such file or directory):
According to this article I am not using *.qrc files
Quoting from that article:
This can be inefficient, especially for large sets of files. In this case, a better approach is to separate each type of resource into its own .qrc file
Anyway, coming to your problem:
initialItem: "pages/HomeFrom.ui.qml" // I've tried "app/pages/HomeFrom.ui.qml" and just "HomeFrom.ui.qml" too :-)
It's always a trial and error thing with QRC and QML :-D A few other things to try:
":/app/pages/HomeFrom.ui.qml"
":/pages/HomeFrom.ui.qml"
"qrc:///app/pages/HomeFrom.ui.qml"
"qrc:///pages/HomeFrom.ui.qml"
PS: I almost forgot... this is showing in my General messages. Do you know what is means?
I may be misremembering something but I think updating to Qt 5.15.1 fixes this issue.
-
@sierdzio do you think 12 files is "large set of files"? Alright, I hope for slightly quicker build while changing my .pro file to this :-)
# QML resources qml_pages.files = $$files(*qml) qml_pages.prefix = /qml/pages qml_widgets.files = $$files(*.qml) qml_widgets.prefix = /qml/widgets RESOURCES += \ qml/qtquickcontrols2.conf \ qml/main.qml \ qml_pages \ qml_widgets
Using your shotgun debugging method I've come to this results :-D
":/qml/pages/HomeFrom.ui.qml" # invalid url: :/qml/pages/HomeFrom.ui.qml ":/pages/HomeFrom.ui.qml" # invalid url: :/pages/HomeFrom.ui.qml "qrc:///qml/pages/HomeFrom.ui.qml" # initialItem: qrc:/qml/pages/HomeFrom.ui.qml:-1 No such file or directory "qrc:///pages/HomeFrom.ui.qml" # initialItem: qrc:/pages/HomeFrom.ui.qml:-1 No such file or directory
Do you have any other suggestions? It annoys me that I end up on such a basic thing... Thank you for your help.
PS: After using resources.files stuff my Project view looks exacly the same (I've just renamed app to qml). :-)
PS2: Maybe it could help if I show you my build settings. I am not sure the rcc is called but as I wrote in the
main.cpp
the file is found... :-/
-
I think the issue may be that you wrote
HomeFrom
instead ofHomeForm
😜
Edit:
Protip to prevent such typos: Right click in your project tree on the target file, select copy path or copy url and simply paste it in your codeedit sniped by @sierdzio 😉 -
@fpartl said in How to open other QML files in main.qml (error: no such file or directory):
Do you have any other suggestions? It annoys me that I end up on such a basic thing... Thank you for your help.
PS: After using resources.files stuff my Project view looks exacly the same (I've just renamed app to qml). :-)
You can right-click on any QML file and select "Copy URL" or "Copy Path" - Qt Creator will automatically provide you with a correct path.
-
@sierdzio said in How to open other QML files in main.qml (error: no such file or directory):
You can right-click on any QML file and select "Copy URL" or "Copy Path" - Qt Creator will automatically provide you with a correct path.
I do not have this option in my context menu when I click on any .qml file. :-/ I have the last version of QtCreator.