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. Possible reasons for a "qrc:/main.qml:-1 File not found" error
Qt 6.11 is out! See what's new in the release blog

Possible reasons for a "qrc:/main.qml:-1 File not found" error

Scheduled Pinned Locked Moved Solved QML and Qt Quick
18 Posts 4 Posters 20.7k Views 3 Watching
  • 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.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #4

    @Andrey-Shmelew your problem seems unrelated or a least different.

    You are trying to load your .qml file using a relative path which is not same as @DuBu which is using Qt's resources to handle his .qml files.

    Interested in AI ? www.idiap.ch
    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

    1 Reply Last reply
    1
    • SGaistS SGaist

      Hi,

      Can you reproduce that with a minimal example ?

      DuBuD Offline
      DuBuD Offline
      DuBu
      wrote on last edited by
      #5

      @SGaist Yes, it's the same even with a "hello world" example.
      Thanks for your reply. I found the reason for my case, see below.

      1 Reply Last reply
      0
      • DuBuD Offline
        DuBuD Offline
        DuBu
        wrote on last edited by DuBu
        #6

        I compiled Qt 5.9 with a divergent "prefix" configure option. (I wanted to keep my old 5.6 installation.) So to get my app working on the target platform I had to set the environment variable LD_LIBRARY_PATH to the prefix path.
        The error was a bit misleading cause it was using my app compiled for 5.9 but the libraries of 5.6.

        Thanks for your time!

        A 1 Reply Last reply
        1
        • DuBuD DuBu

          I compiled Qt 5.9 with a divergent "prefix" configure option. (I wanted to keep my old 5.6 installation.) So to get my app working on the target platform I had to set the environment variable LD_LIBRARY_PATH to the prefix path.
          The error was a bit misleading cause it was using my app compiled for 5.9 but the libraries of 5.6.

          Thanks for your time!

          A Offline
          A Offline
          Andrey Shmelew
          wrote on last edited by
          #7

          @DuBu HI! did you downloaded any new-compiled libraries to armhf device?

          DuBuD 1 Reply Last reply
          0
          • A Andrey Shmelew

            @DuBu HI! did you downloaded any new-compiled libraries to armhf device?

            DuBuD Offline
            DuBuD Offline
            DuBu
            wrote on last edited by
            #8

            @Andrey-Shmelew Yes, but to a different path.

            A 1 Reply Last reply
            0
            • DuBuD DuBu

              @Andrey-Shmelew Yes, but to a different path.

              A Offline
              A Offline
              Andrey Shmelew
              wrote on last edited by Andrey Shmelew
              #9

              @DuBu
              you downloaded new *.so files (libQt5Gui.so.5.8.0, libQt5Qml.so.5.8.0...etc...) to a different path, but older *.so libraries still exsist, right? and you defined LD_LIBRARY_PATH to that new path...?

              DuBuD 1 Reply Last reply
              0
              • A Andrey Shmelew

                @DuBu
                you downloaded new *.so files (libQt5Gui.so.5.8.0, libQt5Qml.so.5.8.0...etc...) to a different path, but older *.so libraries still exsist, right? and you defined LD_LIBRARY_PATH to that new path...?

                DuBuD Offline
                DuBuD Offline
                DuBu
                wrote on last edited by
                #10

                @Andrey-Shmelew It have been 5.9.1 libs, but yes. The 5.6.2 ones still exist in "/usr/lib".

                A 1 Reply Last reply
                1
                • DuBuD DuBu

                  @Andrey-Shmelew It have been 5.9.1 libs, but yes. The 5.6.2 ones still exist in "/usr/lib".

                  A Offline
                  A Offline
                  Andrey Shmelew
                  wrote on last edited by Andrey Shmelew
                  #11

                  @DuBu sorry, the latest question:

                  How to properly put all new *.so.5.9.2 files to a different path , and how to tell new application to use these new libs instead so.5.6.2 ...???

                  very grateful!

                  DuBuD 1 Reply Last reply
                  0
                  • A Andrey Shmelew

                    @DuBu sorry, the latest question:

                    How to properly put all new *.so.5.9.2 files to a different path , and how to tell new application to use these new libs instead so.5.6.2 ...???

                    very grateful!

                    DuBuD Offline
                    DuBuD Offline
                    DuBu
                    wrote on last edited by DuBu
                    #12

                    @Andrey-Shmelew

                    • configure with --prefix "/your/new/path/on/target" (and other options you need)
                    • make
                    • make install
                    • copy resulting directory contents to target into "/your/new/path/on/target"
                    • set LD_LIBRARY_PATH=/your/new/path/on/target/lib" on target
                    A 1 Reply Last reply
                    3
                    • DuBuD DuBu

                      @Andrey-Shmelew

                      • configure with --prefix "/your/new/path/on/target" (and other options you need)
                      • make
                      • make install
                      • copy resulting directory contents to target into "/your/new/path/on/target"
                      • set LD_LIBRARY_PATH=/your/new/path/on/target/lib" on target
                      A Offline
                      A Offline
                      Andrey Shmelew
                      wrote on last edited by
                      #13

                      @DuBu
                      cool, thanks

                      1 Reply Last reply
                      0
                      • A Andrey Shmelew

                        hi! i have absolutely the same trouble:
                        i reproduse it with absolutely minimal qml example
                        When i deploy qt 5.5 application on beaglebone device (arm linux gnueabihf) - then works perfectly
                        When i deploy qt 5.8 - the error appears:

                        QQmlApplicationEngine failed to load component
                        qrc:/main.qml:-1 File not found
                        

                        // this somehow works but the window is blank
                        main.cpp:

                        #include <QGuiApplication>
                        #include <QQuickView>
                        
                        int main(int argc, char *argv[])
                        {
                            QGuiApplication app(argc, argv);
                        
                            QQuickView view;
                            view.setSource(QUrl::fromLocalFile("main.qml"));
                            view.show();
                        
                            return app.exec();
                        }
                        
                        DuBuD Offline
                        DuBuD Offline
                        DuBu
                        wrote on last edited by
                        #14

                        @Andrey-Shmelew I don't know why your error says "qrc:/main.qml" when you try to load your main.qml from the local file system. But I would recommend to load your qmls from the resource system. For your main.qml this would look like this:

                        view.setSource(QUrl(QStringLiteral("qrc:/main.qml")));
                        

                        It makes it a lot easier to deploy your app. Since all qml files are compressed and included in your app you just need to copy one file to deploy your app to the target.

                        A 1 Reply Last reply
                        0
                        • DuBuD DuBu

                          @Andrey-Shmelew I don't know why your error says "qrc:/main.qml" when you try to load your main.qml from the local file system. But I would recommend to load your qmls from the resource system. For your main.qml this would look like this:

                          view.setSource(QUrl(QStringLiteral("qrc:/main.qml")));
                          

                          It makes it a lot easier to deploy your app. Since all qml files are compressed and included in your app you just need to copy one file to deploy your app to the target.

                          A Offline
                          A Offline
                          Andrey Shmelew
                          wrote on last edited by Andrey Shmelew
                          #15

                          @DuBu said in Possible reasons for a "qrc:/main.qml:-1 File not found" error:

                          I don't know

                          i don't know too...
                          When i deploy with qt 5.5 it did not complain, and i think, it compressed all qml files and included in my app and loaded all qml files and executable automatically to armhf device.

                          Even if the application is running, I still can not find main.qml file on the device.

                          DuBuD 1 Reply Last reply
                          0
                          • A Andrey Shmelew

                            @DuBu said in Possible reasons for a "qrc:/main.qml:-1 File not found" error:

                            I don't know

                            i don't know too...
                            When i deploy with qt 5.5 it did not complain, and i think, it compressed all qml files and included in my app and loaded all qml files and executable automatically to armhf device.

                            Even if the application is running, I still can not find main.qml file on the device.

                            DuBuD Offline
                            DuBuD Offline
                            DuBu
                            wrote on last edited by
                            #16

                            @Andrey-Shmelew If your really use the files from the resources (what your don't do when you write QUrl::fromLocalFile) it should be hard to find them on the device. I think they got extracted to a temporary folder somewhere no one knows, at least I do. Maybe there's a function to get that path, but I never cared.
                            I just use two lines of code to make sure to load the qml files from the resource:
                            (I use QQmlApplicationEngine instead of QQuickView)

                              engine.addImportPath(QStringLiteral("qrc:/"));
                              engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
                            

                            Additionally you have to make sure to never load components from the local file system (i.e with a Loader).

                            1 Reply Last reply
                            0
                            • Q Offline
                              Q Offline
                              QtWorld
                              wrote on last edited by
                              #17
                              This post is deleted!
                              1 Reply Last reply
                              0
                              • DuBuD Offline
                                DuBuD Offline
                                DuBu
                                wrote on last edited by
                                #18

                                That's easy: Your file is named "Main.qml" and you try to load it as "main.qml".

                                1 Reply Last reply
                                1

                                • Login

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