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. Qt 6.5 QML-in-QRC vs qt_add_qml_module. What is better?
Forum Updated to NodeBB v4.3 + New Features

Qt 6.5 QML-in-QRC vs qt_add_qml_module. What is better?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
9 Posts 5 Posters 2.4k 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.
  • B Offline
    B Offline
    bogong
    wrote on last edited by bogong
    #1

    Hello!

    Just got confused with new Qt functionality qt_add_qml_module() The question is about what is better to use? In official documentation mentioned that both ways could be used in Qt 6.5. But what is preferable and why?

    For now all of projects maintained by me using QML-in-QRC and really don't know why it should be changed on qt_add_qml_module() functionality.

    1 Reply Last reply
    1
    • E Offline
      E Offline
      eton-esi
      wrote on last edited by
      #2

      I have same question, do you resolve it ?

      1 Reply Last reply
      0
      • F Offline
        F Offline
        felix_u
        wrote on last edited by
        #3

        I am asking myself the same question - I think I read somewhere that adding qml files as well as image resources with qt_add_qml_module() is really the preferred way (because of linting, cachegen and so on) - I think it was in one of the qt blog post regarding this topic.
        My main concern is that this really clutters the CMakeLists when you have many files.

        kkoehneK 1 Reply Last reply
        0
        • F felix_u

          I am asking myself the same question - I think I read somewhere that adding qml files as well as image resources with qt_add_qml_module() is really the preferred way (because of linting, cachegen and so on) - I think it was in one of the qt blog post regarding this topic.
          My main concern is that this really clutters the CMakeLists when you have many files.

          kkoehneK Offline
          kkoehneK Offline
          kkoehne
          Moderators
          wrote on last edited by
          #4

          qt_add_qml_module() is indeed the way to go, as it standardizes a lot of things, and therefore makes qml more toolable.

          For the 'cluttering' aspect, you can use include() and CMake variables to separate things if you want to. But personally, I think the list of files is the core of a build system, so I think 'hiding' it in a separate .qrc file is actually a bit of a misfeature ;)

          Director R&D, The Qt Company

          B JoeCFDJ 2 Replies Last reply
          0
          • kkoehneK kkoehne

            qt_add_qml_module() is indeed the way to go, as it standardizes a lot of things, and therefore makes qml more toolable.

            For the 'cluttering' aspect, you can use include() and CMake variables to separate things if you want to. But personally, I think the list of files is the core of a build system, so I think 'hiding' it in a separate .qrc file is actually a bit of a misfeature ;)

            B Offline
            B Offline
            bogong
            wrote on last edited by
            #5

            @kkoehne But what about security? If there are using of qt_add_qml_module() will be it stored in application in plain QML text or it will be transformed in C++? Haven't found any info about it in any manuals? Main reason of using *.qrc within QML were security. It was making harder process of reading QMLs.

            kkoehneK 1 Reply Last reply
            0
            • kkoehneK kkoehne

              qt_add_qml_module() is indeed the way to go, as it standardizes a lot of things, and therefore makes qml more toolable.

              For the 'cluttering' aspect, you can use include() and CMake variables to separate things if you want to. But personally, I think the list of files is the core of a build system, so I think 'hiding' it in a separate .qrc file is actually a bit of a misfeature ;)

              JoeCFDJ Offline
              JoeCFDJ Offline
              JoeCFD
              wrote on last edited by
              #6

              @kkoehne good to know. Does qmake have the similar setting? a qrc file would be able to be applied in both qmake and cmake files, right? Or you guys are dropping qmake?

              kkoehneK 1 Reply Last reply
              0
              • B bogong

                @kkoehne But what about security? If there are using of qt_add_qml_module() will be it stored in application in plain QML text or it will be transformed in C++? Haven't found any info about it in any manuals? Main reason of using *.qrc within QML were security. It was making harder process of reading QMLs.

                kkoehneK Offline
                kkoehneK Offline
                kkoehne
                Moderators
                wrote on last edited by
                #7

                @bogong said in Qt 6.5 QML-in-QRC vs qt_add_qml_module. What is better?:

                But what about security? If there are using of qt_add_qml_module() will be it stored in application in plain QML text or it will be transformed in C++? Haven't found any info about it in any manuals? Main reason of using *.qrc within QML were security. It was making harder process of reading QMLs.

                qt_add_qml_module() allows to use the Qt Quick Compiler , which actually generates C++ code: https://www.qt.io/blog/the-new-qtquick-compiler-technology . If it can't be used, it falls back to qrc though.

                (But please note that embedding QML sources in the binary via qrc is obfuscation as best. It's not rocket science to extract the sources back if you have access to the binary).

                Director R&D, The Qt Company

                1 Reply Last reply
                0
                • JoeCFDJ JoeCFD

                  @kkoehne good to know. Does qmake have the similar setting? a qrc file would be able to be applied in both qmake and cmake files, right? Or you guys are dropping qmake?

                  kkoehneK Offline
                  kkoehneK Offline
                  kkoehne
                  Moderators
                  wrote on last edited by
                  #8

                  @JoeCFD said in Qt 6.5 QML-in-QRC vs qt_add_qml_module. What is better?:

                  Does qmake have the similar setting? a qrc file would be able to be applied in both qmake and cmake files, right?

                  qmake does miss the high level abstraction for QML modules. But if you're asking whether you can embed qml files without a .qrc file ... you can:

                  assets.files = file1.qml file2.qml
                  assets.prefix = /
                  
                  RESOURCES += assets
                  

                  Or you guys are dropping qmake?

                  Not any time soon :) But we don't develop it much further.

                  Director R&D, The Qt Company

                  JoeCFDJ 1 Reply Last reply
                  0
                  • kkoehneK kkoehne

                    @JoeCFD said in Qt 6.5 QML-in-QRC vs qt_add_qml_module. What is better?:

                    Does qmake have the similar setting? a qrc file would be able to be applied in both qmake and cmake files, right?

                    qmake does miss the high level abstraction for QML modules. But if you're asking whether you can embed qml files without a .qrc file ... you can:

                    assets.files = file1.qml file2.qml
                    assets.prefix = /
                    
                    RESOURCES += assets
                    

                    Or you guys are dropping qmake?

                    Not any time soon :) But we don't develop it much further.

                    JoeCFDJ Offline
                    JoeCFDJ Offline
                    JoeCFD
                    wrote on last edited by
                    #9

                    @kkoehne that is unfortunate. cmake is kind of messy. qmake is much simpler.

                    1 Reply Last reply
                    0
                    • EwaldVDME EwaldVDM referenced this topic

                    • Login

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