Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. How to open other QML files in main.qml (error: no such file or directory)

How to open other QML files in main.qml (error: no such file or directory)

Scheduled Pinned Locked Moved Solved QML and Qt Quick
9 Posts 3 Posters 5.7k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    fpartl
    wrote on last edited by fpartl
    #1

    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...
    neat project view

    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$'.
    
    sierdzioS 1 Reply Last reply
    0
    • J.HilkJ Offline
      J.HilkJ Offline
      J.Hilk
      Moderators
      wrote on last edited by J.Hilk
      #4

      I think the issue may be that you wrote HomeFrom instead of HomeForm 😜


      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 code edit sniped by @sierdzio 😉


      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      F 1 Reply Last reply
      1
      • F fpartl

        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...
        neat project view

        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$'.
        
        sierdzioS Offline
        sierdzioS Offline
        sierdzio
        Moderators
        wrote on last edited by
        #2

        @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.

        F 1 Reply Last reply
        0
        • sierdzioS 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.

          F Offline
          F Offline
          fpartl
          wrote on last edited by fpartl
          #3

          @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). :-)
          Project view

          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... :-/
          Build settings

          sierdzioS 1 Reply Last reply
          1
          • J.HilkJ Offline
            J.HilkJ Offline
            J.Hilk
            Moderators
            wrote on last edited by J.Hilk
            #4

            I think the issue may be that you wrote HomeFrom instead of HomeForm 😜


            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 code edit sniped by @sierdzio 😉


            Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


            Q: What's that?
            A: It's blue light.
            Q: What does it do?
            A: It turns blue.

            F 1 Reply Last reply
            1
            • F fpartl

              @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). :-)
              Project view

              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... :-/
              Build settings

              sierdzioS Offline
              sierdzioS Offline
              sierdzio
              Moderators
              wrote on last edited by
              #5

              @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). :-)
              Project view

              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.

              F 1 Reply Last reply
              1
              • sierdzioS 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). :-)
                Project view

                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.

                F Offline
                F Offline
                fpartl
                wrote on last edited by
                #6

                @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.

                J.HilkJ 1 Reply Last reply
                0
                • F fpartl

                  @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.

                  J.HilkJ Offline
                  J.HilkJ Offline
                  J.Hilk
                  Moderators
                  wrote on last edited by J.Hilk
                  #7

                  @fpartl

                  I have the "last" version of QtC as well, its definitely there
                  47144744-f806-4539-9cdc-bcfb1ca9984e-image.png

                  may only be the case, if the file is inside your resource file/system 🤷‍♂️ Haven't checked that


                  Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                  Q: What's that?
                  A: It's blue light.
                  Q: What does it do?
                  A: It turns blue.

                  sierdzioS 1 Reply Last reply
                  0
                  • J.HilkJ J.Hilk

                    @fpartl

                    I have the "last" version of QtC as well, its definitely there
                    47144744-f806-4539-9cdc-bcfb1ca9984e-image.png

                    may only be the case, if the file is inside your resource file/system 🤷‍♂️ Haven't checked that

                    sierdzioS Offline
                    sierdzioS Offline
                    sierdzio
                    Moderators
                    wrote on last edited by
                    #8
                    This post is deleted!
                    1 Reply Last reply
                    0
                    • J.HilkJ J.Hilk

                      I think the issue may be that you wrote HomeFrom instead of HomeForm 😜


                      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 code edit sniped by @sierdzio 😉

                      F Offline
                      F Offline
                      fpartl
                      wrote on last edited by
                      #9

                      @J-Hilk OMG I am such an idiot... 4 hours of Googling... :D Thank you for saving my life! In conclusion of others the original code I've posted is not working only because of this typing laxity.

                      1 Reply Last reply
                      3

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved