Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Quick Compiler resources are not visible
QtWS25 Last Chance

Quick Compiler resources are not visible

Scheduled Pinned Locked Moved Unsolved General and Desktop
quickquickcompilerstatic linking
5 Posts 2 Posters 1.6k 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.
  • J Offline
    J Offline
    Jarek B
    wrote on 8 Jul 2020, 11:45 last edited by Jarek B 7 Aug 2020, 16:01
    #1

    I have a project with some resources. There is a problem when I am trying to load main screen from qml file.

    Resources are add as follows:

    RESOURCES += \
       ... \
        source/core/QmlFiles_ScreenBase.qrc \
       ...
    

    Then file is loaded as follows

    auto* engine = new QQmlApplicationEngine;
    engine->load(QUrl(QStringLiteral("qrc:///ui/qml/screens/MainScreen.qml")));
    

    If I use CONFIG+=qtquickcompiler, there are couple things generated under the hood
    Info: qrc files that contains some interesting resources is called QmlFiles_ScreenBase.qrc

    1. after running qmake - in main build directory there is a new file source_core_QmlFiles_ScreenBase_qmlcache.qrc which contains nothing except qmldir entry
    2. at some point cachegen is generating file source_core_ui_qml_screens_MainScreen_qml.cpp which contains some data and it is generated from existing qml file
    3. Compiler produces obj/source_core_ui_qml_screens_MainScreen_qml.o
    4. Linker generates application

    However if I try to run application only thing that is displayed is
    qrc:/ui/qml/screens/MainScreen.qml:-1 No such file or directory

    I tried to list resources that are available during runtime and nothing from that qrc file is listed. Contents from some other qrc files are not listed as well.

    Rebuilding or changing to Debug configuration does not fix anything. I tried to move file to other module and build application once again and suddenly it is working (resources are listed).

    1. qml cache file is not generated for new module
    2. cpp file is generated by cachegen (identical as in previous case, except internal naming)
    3. Compiler produce object file
    4. Linker is producing app file

    I could also turn off quick compiler, but this is not an option.

    I want to ask how to use quick compiler and build it correctly at the first time?

    K 1 Reply Last reply 8 Jul 2020, 12:08
    0
    • J Jarek B
      8 Jul 2020, 11:45

      I have a project with some resources. There is a problem when I am trying to load main screen from qml file.

      Resources are add as follows:

      RESOURCES += \
         ... \
          source/core/QmlFiles_ScreenBase.qrc \
         ...
      

      Then file is loaded as follows

      auto* engine = new QQmlApplicationEngine;
      engine->load(QUrl(QStringLiteral("qrc:///ui/qml/screens/MainScreen.qml")));
      

      If I use CONFIG+=qtquickcompiler, there are couple things generated under the hood
      Info: qrc files that contains some interesting resources is called QmlFiles_ScreenBase.qrc

      1. after running qmake - in main build directory there is a new file source_core_QmlFiles_ScreenBase_qmlcache.qrc which contains nothing except qmldir entry
      2. at some point cachegen is generating file source_core_ui_qml_screens_MainScreen_qml.cpp which contains some data and it is generated from existing qml file
      3. Compiler produces obj/source_core_ui_qml_screens_MainScreen_qml.o
      4. Linker generates application

      However if I try to run application only thing that is displayed is
      qrc:/ui/qml/screens/MainScreen.qml:-1 No such file or directory

      I tried to list resources that are available during runtime and nothing from that qrc file is listed. Contents from some other qrc files are not listed as well.

      Rebuilding or changing to Debug configuration does not fix anything. I tried to move file to other module and build application once again and suddenly it is working (resources are listed).

      1. qml cache file is not generated for new module
      2. cpp file is generated by cachegen (identical as in previous case, except internal naming)
      3. Compiler produce object file
      4. Linker is producing app file

      I could also turn off quick compiler, but this is not an option.

      I want to ask how to use quick compiler and build it correctly at the first time?

      K Offline
      K Offline
      KroMignon
      wrote on 8 Jul 2020, 12:08 last edited by KroMignon 7 Aug 2020, 12:09
      #2

      @Jarek-B said in Quick Compiler resources are not visible:

      qtquickcompiler

      Have you take a look at documentation? ==> https://doc.qt.io/qt-5/qtquick-deployment.html#managing-resource-files-with-the-qt-resource-system

      I think you are not using the right path to access main.qml.
      According to your code extract, QmlFiles_ScreenBase.qrc should looks like:

      <!DOCTYPE RCC>
      <RCC version="1.0">
      
      <qresource prefix="/">
          <file>ui/qml/main.qml</file>
      </qresource>
      
      </RCC>
      

      And the path structure as follow

      source/core
         |- QmlFiles_ScreenBase.qrc
         |- ui
            |- qml
                  |-main.qml
      

      Is this the case?

      It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

      1 Reply Last reply
      0
      • J Offline
        J Offline
        Jarek B
        wrote on 8 Jul 2020, 12:45 last edited by
        #3

        After moving a file to separate module I changed a name to main.qml from MainScreen.qml, but I forgot to update post text. Moreover if I do not use qtquickcompiler everything works like a charm, and finally there is a question: why some other resources are gone?
        This is how I am listing them

        QDirIterator it(":", QDirIterator::Subdirectories);
        while (it.hasNext()) {
            qDebug() << it.next();
        }
        

        Result without QuickCompiler

        ":/ui/qml/screens"
        ":/ui/qml/screens/qmldir"
        ":/ui/qml/screens/FullScreen.qml"
        ":/ui/qml/screens/ScreenManager.qml"
        ":/ui/qml/screens/BaseScreen.qml"
        ":/ui/qml/screens/MessageBoxScreen.qml"
        ":/ui/qml/screens/MessageBoxScreenForm.qml"
        ":/ui/qml/screens/StandardScreen.qml"
        ":/ui/qml/screens/MessageBox.js"
        ":/ui/qml/main.qml"
        

        Result with QuickCompiler

        ":/ui/qml/screens"
        ":/ui/qml/screens/qmldir"
        
        K 1 Reply Last reply 8 Jul 2020, 13:00
        0
        • J Jarek B
          8 Jul 2020, 12:45

          After moving a file to separate module I changed a name to main.qml from MainScreen.qml, but I forgot to update post text. Moreover if I do not use qtquickcompiler everything works like a charm, and finally there is a question: why some other resources are gone?
          This is how I am listing them

          QDirIterator it(":", QDirIterator::Subdirectories);
          while (it.hasNext()) {
              qDebug() << it.next();
          }
          

          Result without QuickCompiler

          ":/ui/qml/screens"
          ":/ui/qml/screens/qmldir"
          ":/ui/qml/screens/FullScreen.qml"
          ":/ui/qml/screens/ScreenManager.qml"
          ":/ui/qml/screens/BaseScreen.qml"
          ":/ui/qml/screens/MessageBoxScreen.qml"
          ":/ui/qml/screens/MessageBoxScreenForm.qml"
          ":/ui/qml/screens/StandardScreen.qml"
          ":/ui/qml/screens/MessageBox.js"
          ":/ui/qml/main.qml"
          

          Result with QuickCompiler

          ":/ui/qml/screens"
          ":/ui/qml/screens/qmldir"
          
          K Offline
          K Offline
          KroMignon
          wrote on 8 Jul 2020, 13:00 last edited by
          #4

          @Jarek-B I don't know what is your directory structure, this is how I would do:

          QmlFiles_ScreenBase.qrc
             |- ui
                |- qml
                      |-main.qml
                      |- screens
                          |- qmldir
                          |-FullScreen.qml
                          |-...
          

          And the resources file as follow:

          <!DOCTYPE RCC>
          <RCC version="1.0">
          
          <qresource prefix="/ui/qml">
              <file alias="main.qml">ui/qml/main.qml</file>
          </qresource>
          <qresource prefix="/ui/qml/screens">
              <file alias="qmldir">ui/qml/screens/qmldir</file>
              <file alias="FullScreen.qml">ui/qml/screens/FullScreen.qml</file>
              ...
          </qresource>
          </RCC>
          

          It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

          1 Reply Last reply
          0
          • J Offline
            J Offline
            Jarek B
            wrote on 8 Jul 2020, 16:01 last edited by Jarek B 7 Aug 2020, 16:02
            #5

            I found out that between two cases (working and not working one) only file that differs substantially is qmlcache_loader.cpp. In non-working case it was over 5 times smaller than normally, and that's because 80% of all resources were not there.

            Now, the only reason why it's happened is because some qrc files has been added to RESOURCES twice, and only those resources were available at the end.
            Why it worked after moving file from one qrc file to another? Probably because only those part of the project which depends on that two files has been updated and though every qrc file has been included only once (duplicates was in my case in the other part of the project).

            EDIT:
            Before marking it as solved I will try to confirm all of the above hypothesis.

            1 Reply Last reply
            0

            2/5

            8 Jul 2020, 12:08

            • Login

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