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. re-compiling (cached) qml components
Forum Updated to NodeBB v4.3 + New Features

re-compiling (cached) qml components

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
6 Posts 2 Posters 879 Views 1 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.
  • D Offline
    D Offline
    drmhkelley
    wrote on last edited by
    #1

    Please forgive me if I've missed a prior post on this topic.

    What must I do to ensure that updated .qml files re-compiled when I try to use them? I assume this is related to how the QML engine caches components, but I need to know how to "force" re-compilation when the essential .qml source files are changed.

    I use a Windows 10 platform and the MinGw-64 compiler for C, C++, etc. installed. I routinely use Qt 6, but occasionally need Qt 5, which may be related to my current difficulty.

    I am a casual and infrequent user of QML. However, I have a legacy app that requires QtLocation (and a few other) packages that were available in Qt 5 but are not available in Qt 6. The still work fine, but I'd like to tweak the app a bit. I no longer have an installation of QtCreator for Qt5, so cannot really debug the app. That is not directly the problem, because I have always ensured that I can compile and use my apps outside of the Qt environment (I use many 3rd party libraries that are sort of incompatible with Qt).

    In any event, changes that I make to .qml files ARE NOT recognized when I run the app that uses them.

    What might I be missing?

    Thanks for any pointers.

    JKSHJ 1 Reply Last reply
    0
    • D drmhkelley

      Please forgive me if I've missed a prior post on this topic.

      What must I do to ensure that updated .qml files re-compiled when I try to use them? I assume this is related to how the QML engine caches components, but I need to know how to "force" re-compilation when the essential .qml source files are changed.

      I use a Windows 10 platform and the MinGw-64 compiler for C, C++, etc. installed. I routinely use Qt 6, but occasionally need Qt 5, which may be related to my current difficulty.

      I am a casual and infrequent user of QML. However, I have a legacy app that requires QtLocation (and a few other) packages that were available in Qt 5 but are not available in Qt 6. The still work fine, but I'd like to tweak the app a bit. I no longer have an installation of QtCreator for Qt5, so cannot really debug the app. That is not directly the problem, because I have always ensured that I can compile and use my apps outside of the Qt environment (I use many 3rd party libraries that are sort of incompatible with Qt).

      In any event, changes that I make to .qml files ARE NOT recognized when I run the app that uses them.

      What might I be missing?

      Thanks for any pointers.

      JKSHJ Offline
      JKSHJ Offline
      JKSH
      Moderators
      wrote on last edited by
      #2

      @drmhkelley said in re-compiling (cached) qml components:

      What must I do to ensure that updated .qml files re-compiled when I try to use them?

      Basically, you want ensure that your *.qml files are being managed under the Qt Quick Compiler. This process has changed quite significantly in recent years, so the first questions are:

      1. What is the exact version of Qt that you're using?
      2. How are your QML files added to your project?

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      D 1 Reply Last reply
      0
      • JKSHJ JKSH

        @drmhkelley said in re-compiling (cached) qml components:

        What must I do to ensure that updated .qml files re-compiled when I try to use them?

        Basically, you want ensure that your *.qml files are being managed under the Qt Quick Compiler. This process has changed quite significantly in recent years, so the first questions are:

        1. What is the exact version of Qt that you're using?
        2. How are your QML files added to your project?
        D Offline
        D Offline
        drmhkelley
        wrote on last edited by
        #3

        @JKSH

        Thank you for the hints - I'll try to figure that out. In the meantime, I'll attempt to answer your questions below.

        First, there are three important disclaimers.

        1. As only an occasional user of QML there are many aspects of which I have at best a rudimentary understanding - such as proper use of the Qt Quick Compiler. But you've given me a good reason to dig a bit into that.

        2. It may be difficult to figure this out if there was significant change between Qt 5 and Qt 6. I no longer have an installation of Qt Creator that uses Qt 5. The app in question relies on the packages such as QtLocation that are not available in Qt 6. So I can probably figure this out for Qt 6, but perhaps not for Qt 5.

        3. I typically compile apps outside the Qt environment and just use Qt Creator for debugging purposes.

        Now for answers to your specific questions (with my very incomplete understanding of QML)

        I use Qt 5, in particular QtLocation and QtPositioning, which were not available for Qt 6.

        I add QML files to my project thusly:

        1. the .cpp app calls qmlRegisterType<SomeObject> for some locally developed objects.

        2. initialize an instance of QQmlApplicationEngine via:

        QQmlApplicationEngine engine;
        engine.addImportPath(QStringLiteral(":/imports"));
        engine.load(QUrl(QStringLiteral("qrc:///qml/newmap.qml")));

        I am not quite sure what either method does, but newmap.qml is the main QML module and all of its components exist in the local folder qml.

        1. newmap.qml explicitly imports all of the required components.

        Is this helpful to suggest any specific next steps?

        Thanks in advance

        JKSHJ 1 Reply Last reply
        0
        • D drmhkelley

          @JKSH

          Thank you for the hints - I'll try to figure that out. In the meantime, I'll attempt to answer your questions below.

          First, there are three important disclaimers.

          1. As only an occasional user of QML there are many aspects of which I have at best a rudimentary understanding - such as proper use of the Qt Quick Compiler. But you've given me a good reason to dig a bit into that.

          2. It may be difficult to figure this out if there was significant change between Qt 5 and Qt 6. I no longer have an installation of Qt Creator that uses Qt 5. The app in question relies on the packages such as QtLocation that are not available in Qt 6. So I can probably figure this out for Qt 6, but perhaps not for Qt 5.

          3. I typically compile apps outside the Qt environment and just use Qt Creator for debugging purposes.

          Now for answers to your specific questions (with my very incomplete understanding of QML)

          I use Qt 5, in particular QtLocation and QtPositioning, which were not available for Qt 6.

          I add QML files to my project thusly:

          1. the .cpp app calls qmlRegisterType<SomeObject> for some locally developed objects.

          2. initialize an instance of QQmlApplicationEngine via:

          QQmlApplicationEngine engine;
          engine.addImportPath(QStringLiteral(":/imports"));
          engine.load(QUrl(QStringLiteral("qrc:///qml/newmap.qml")));

          I am not quite sure what either method does, but newmap.qml is the main QML module and all of its components exist in the local folder qml.

          1. newmap.qml explicitly imports all of the required components.

          Is this helpful to suggest any specific next steps?

          Thanks in advance

          JKSHJ Offline
          JKSHJ Offline
          JKSH
          Moderators
          wrote on last edited by
          #4

          You're welcome.

          Rudimentary understanding is not a problem; we're here to learn and teach :-)

          @drmhkelley said in re-compiling (cached) qml components:

          I use Qt 5

          Can you be more specific? IIRC, Qt 5.15 uses the Qt Quick Compiler by default, whereas Qt 5.12 doesn't. Make sure you're using Qt 5.15 unless you have a very good reason to use an older one.

          I add QML files to my project thusly:

          1. the .cpp app calls qmlRegisterType<SomeObject> for some locally developed objects.

          2. initialize an instance of QQmlApplicationEngine via:

          QQmlApplicationEngine engine;
          engine.addImportPath(QStringLiteral(":/imports"));
          engine.load(QUrl(QStringLiteral("qrc:///qml/newmap.qml")));

          I am not quite sure what either method does, but newmap.qml is the main QML module and all of its components exist in the local folder qml.

          OK, this tells me that your QML files are all managed inside a *.qrc file. That's a good start.

          This means each time you modify your *.qml source files, as long as you run your compilation (and as long as your computer's clock is correct), your build system should automatically pack the modified files into your final application.

          (But just to double-check: Are ALL of your *.qml files put inside a *.qrc file?)

          1. I typically compile apps outside the Qt environment and just use Qt Creator for debugging purposes.

          qmake or CMake? Can you share your project file (*.pro or CMakeLists.txt)?

          I no longer have an installation of Qt Creator that uses Qt 5.

          A single installation of Qt Creator can be used to build projects with multiple versions of Qt.

          in particular QtLocation and QtPositioning, which were not available for Qt 6.

          • Qt Positioning is available: https://doc.qt.io/qt-6/location-positioning-cpp.html
          • Qt Location is currently being ported: https://bugreports.qt.io/browse/QTBUG-96795

          Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

          D 1 Reply Last reply
          1
          • JKSHJ JKSH

            You're welcome.

            Rudimentary understanding is not a problem; we're here to learn and teach :-)

            @drmhkelley said in re-compiling (cached) qml components:

            I use Qt 5

            Can you be more specific? IIRC, Qt 5.15 uses the Qt Quick Compiler by default, whereas Qt 5.12 doesn't. Make sure you're using Qt 5.15 unless you have a very good reason to use an older one.

            I add QML files to my project thusly:

            1. the .cpp app calls qmlRegisterType<SomeObject> for some locally developed objects.

            2. initialize an instance of QQmlApplicationEngine via:

            QQmlApplicationEngine engine;
            engine.addImportPath(QStringLiteral(":/imports"));
            engine.load(QUrl(QStringLiteral("qrc:///qml/newmap.qml")));

            I am not quite sure what either method does, but newmap.qml is the main QML module and all of its components exist in the local folder qml.

            OK, this tells me that your QML files are all managed inside a *.qrc file. That's a good start.

            This means each time you modify your *.qml source files, as long as you run your compilation (and as long as your computer's clock is correct), your build system should automatically pack the modified files into your final application.

            (But just to double-check: Are ALL of your *.qml files put inside a *.qrc file?)

            1. I typically compile apps outside the Qt environment and just use Qt Creator for debugging purposes.

            qmake or CMake? Can you share your project file (*.pro or CMakeLists.txt)?

            I no longer have an installation of Qt Creator that uses Qt 5.

            A single installation of Qt Creator can be used to build projects with multiple versions of Qt.

            in particular QtLocation and QtPositioning, which were not available for Qt 6.

            • Qt Positioning is available: https://doc.qt.io/qt-6/location-positioning-cpp.html
            • Qt Location is currently being ported: https://bugreports.qt.io/browse/QTBUG-96795
            D Offline
            D Offline
            drmhkelley
            wrote on last edited by
            #5

            @JKSH

            Ooops - stopped paying attention for a bit, but thanks very much for the additional imformation.

            For your new questions:

            1. Version of Qt 5 was Qt 5.15. The app was developed starting with version Qt 4.??, but I kept it going through 5.15.

            2. files managed inside a *.qrc file ...
              What specifically do you mean by "run your compilation"? Are you referring to the steps I specifically initiate via "make"? Or do you refer to steps taken more indirectly through the QML compilation engine? That's where I start getting pretty confused.

            Also, what uses the info in the .qrc file? It is referenced in the .pro file (RESOURCES += ...), but it isn't obvious what is done with that.

            1. I don't use either qmake or CMake - never found a "simple" enough explanation/example to figure them out. Instead, I just use mingw32-make, which I've used extensively for many eons.

            2. "multiple versions of Qt" with single Qt Creator. When I was first starting to use Qt, I tried to do that, but was never successful. Can you point me to any simple description of how to accomplish that?

            3. Many thanks for the pointers to ports of positioning and location to Qt 6. When I first converted to Qt 6, I tried to keep up with that, but stopped once it seemed unlikely to ever reach any sensible stage of utility. I will definitely look more into whether the current status allows users like me to use them productively.

            Many thanks

            JKSHJ 1 Reply Last reply
            0
            • D drmhkelley

              @JKSH

              Ooops - stopped paying attention for a bit, but thanks very much for the additional imformation.

              For your new questions:

              1. Version of Qt 5 was Qt 5.15. The app was developed starting with version Qt 4.??, but I kept it going through 5.15.

              2. files managed inside a *.qrc file ...
                What specifically do you mean by "run your compilation"? Are you referring to the steps I specifically initiate via "make"? Or do you refer to steps taken more indirectly through the QML compilation engine? That's where I start getting pretty confused.

              Also, what uses the info in the .qrc file? It is referenced in the .pro file (RESOURCES += ...), but it isn't obvious what is done with that.

              1. I don't use either qmake or CMake - never found a "simple" enough explanation/example to figure them out. Instead, I just use mingw32-make, which I've used extensively for many eons.

              2. "multiple versions of Qt" with single Qt Creator. When I was first starting to use Qt, I tried to do that, but was never successful. Can you point me to any simple description of how to accomplish that?

              3. Many thanks for the pointers to ports of positioning and location to Qt 6. When I first converted to Qt 6, I tried to keep up with that, but stopped once it seemed unlikely to ever reach any sensible stage of utility. I will definitely look more into whether the current status allows users like me to use them productively.

              Many thanks

              JKSHJ Offline
              JKSHJ Offline
              JKSH
              Moderators
              wrote on last edited by
              #6

              @drmhkelley said in re-compiling (cached) qml components:

              Ooops - stopped paying attention for a bit, but thanks very much for the additional imformation.

              No problem.

              For your new questions:

              1. Version of Qt 5 was Qt 5.15. The app was developed starting with version Qt 4.??, but I kept it going through 5.15.

              Great!

              1. files managed inside a *.qrc file ...
                What specifically do you mean by "run your compilation"? Are you referring to the steps I specifically initiate via "make"?

              I meant "run qmake + make"

              Or do you refer to steps taken more indirectly through the QML compilation engine? That's where I start getting pretty confused.

              Programmers are not meant to run the QML compiler directly. Most of the time, you don't even have to think about it because qmake and make take care it it for you automatically.

              Also, what uses the info in the .qrc file? It is referenced in the .pro file (RESOURCES += ...), but it isn't obvious what is done with that.

              1. I don't use either qmake or CMake - never found a "simple" enough explanation/example to figure them out. Instead, I just use mingw32-make, which I've used extensively for many eons.

              At the core of it, qmake converts your *.pro file into a Makefile. Programmers would run qmake first, then run make. when qmake sees the RESOURCES += ... in your *.pro file, it writes the relevant rules into your Makefile to run rcc.exe.

              Anyway, this might be the source of your problem. rcc.exe reads the *.qrc file, collects the latest version of the resource files, and embeds them into your executable. If you have a *.qml file that isn't listed in the *.qrc file, or if your Makefile does not contain rules to invoke rcc.exe when those files are changed, then that would explain why your modified *.qml files are not getting processed.

              If you're running mingw32-make directly but not running qmake, that means your *.pro file is not actually getting used at all. You can probably delete the *.pro file and see no difference.

              1. "multiple versions of Qt" with single Qt Creator. When I was first starting to use Qt, I tried to do that, but was never successful. Can you point me to any simple description of how to accomplish that?
              1. Use the Qt Online Installer to install all the versions of Qt that you want (ensure that you have also installed the relevant compilers too)
              2. Create or open a project in Qt Creator. It will ask you which installed version(s) of Qt you want to use with your project, so make your selection.
              3. Click the "Run" button to build and run your application with your first selected version of Qt.
              4. Use the "Kit Selector" to select a different version of Qt, and click the "Run" button to build and run your application with that other version of Qt (see https://doc.qt.io/qtcreator/creator-building-targets.html for the diagram)

              That's the gist of it.

              1. Many thanks for the pointers to ports of positioning and location to Qt 6. When I first converted to Qt 6, I tried to keep up with that, but stopped once it seemed unlikely to ever reach any sensible stage of utility. I will definitely look more into whether the current status allows users like me to use them productively.

              Many thanks

              👍

              Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

              1 Reply Last reply
              2

              • Login

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