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. Hide QML source files for deployment
Forum Updated to NodeBB v4.3 + New Features

Hide QML source files for deployment

Scheduled Pinned Locked Moved QML and Qt Quick
11 Posts 3 Posters 5.1k 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.
  • Q Offline
    Q Offline
    qttester5
    wrote on last edited by
    #1

    I've noticed that the qml source files must hang out in the open in the build directory when you deploy (I am deploying for Windows). Whereas other code is compiled into non-readable binary code, QML files remain as source code. Is there a way to avoid this? I have to place them in the directory with the executable for the app to run.

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      You can store all your QML file in a resource file (QRC). This way they will be compiled into your binary.

      (Z(:^

      1 Reply Last reply
      0
      • Q Offline
        Q Offline
        qttester5
        wrote on last edited by
        #3

        Cool, thanks. Can you point me in the right direction to do this?

        1 Reply Last reply
        0
        • sierdzioS Offline
          sierdzioS Offline
          sierdzio
          Moderators
          wrote on last edited by
          #4

          Sure. The right direction, as usual, is the Qt documentation :) "Link":http://qt-project.org/doc/qt-5.0/qtcore/resources.html. And "a more specific one":http://qt-project.org/doc/qt-5.0/qtquick/qtquick-deployment.html#managing-resource-files-with-the-qt-resource-system.

          (Z(:^

          1 Reply Last reply
          0
          • Q Offline
            Q Offline
            qttester5
            wrote on last edited by
            #5

            I think that these files even if in a resource file are not really compiled into the binary. They are not visible as separate files in your build directory, but they are not compiled, encrypted, or turned into binary code and the QML is easily seen by anyone who wishes to inspect the executable.

            1 Reply Last reply
            0
            • sierdzioS Offline
              sierdzioS Offline
              sierdzio
              Moderators
              wrote on last edited by
              #6

              [quote author="qttester5" date="1379344108"]I think that these files even if in a resource file are not really compiled into the binary. They are not visible as separate files in your build directory, but they are not compiled, encrypted, or turned into binary code and the QML is easily seen by anyone who wishes to inspect the executable. [/quote]

              Correct. AFAIK, no obfuscation is done. The only thing you can easily do is to turn on resource compression, but that is also not very secure. Otherwise, you need to implement your own solution, or start a playground project for such a system under Qt Project umbrella.

              (Z(:^

              1 Reply Last reply
              0
              • Q Offline
                Q Offline
                qttester5
                wrote on last edited by
                #7

                Actually I noticed that when included in a resource file, an actual c++ source is generated for the QML which would then be compiled into binary, suggesting that they are in fact compiled. But since QmL is interpreted in real-time, I don't know if either I am wrong about this, or something else is happening behind the scenes.

                1 Reply Last reply
                0
                • sierdzioS Offline
                  sierdzioS Offline
                  sierdzio
                  Moderators
                  wrote on last edited by
                  #8

                  They are simply encoded so that the compiler is fooled into thinking it's actual source code. You can put any file (text, binary) into Qt resource files and it will always work. This has nothing to do with QML. Once you run your app, Qt resource system will read those compiled files and expose them to QML engine as standard, plain text data.

                  (Z(:^

                  1 Reply Last reply
                  0
                  • Q Offline
                    Q Offline
                    qttester5
                    wrote on last edited by
                    #9

                    I previously thought - and you yourself also confirmed above - that text files such as QML are not really "hidden" in a binary executable and someone could technically see the plain text QML code if they inspected an executable. But this suggests that actually yes, they are indeed compiled into binary. Even if the resource system turns then back into plain text at runtime, they are still hidden for all practical purposes, no?

                    1 Reply Last reply
                    0
                    • sierdzioS Offline
                      sierdzioS Offline
                      sierdzio
                      Moderators
                      wrote on last edited by
                      #10

                      They are hidden, yes, but some people suggest that with right inspection tools they can still be read. I have never tried that myself, so I can't confirm. Just be aware that this might be a possibility.

                      (Z(:^

                      R 1 Reply Last reply
                      0
                      • sierdzioS sierdzio

                        They are hidden, yes, but some people suggest that with right inspection tools they can still be read. I have never tried that myself, so I can't confirm. Just be aware that this might be a possibility.

                        R Offline
                        R Offline
                        Richard Buchmann
                        wrote on last edited by Richard Buchmann
                        #11

                        https://bugreports.qt.io/browse/QTBUG-89292?focusedCommentId=541747&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-541747

                        Since Qt5.15, the sources are no longer removed from resources when using qtquickcompiler.

                        Qt6.5.2 seems to have the same behavior: qml sources are still in.

                        To check it: strings your-binary | grep import

                        1 Reply Last reply
                        0

                        • Login

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