Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved Add QML file NOT in resource file. How?

    General and Desktop
    3
    9
    369
    Loading More Posts
    • 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
      bogong last edited by bogong

      Hello!

      I've got forgotten how to add QML file into *.pro file directly without resources. I remember only this - there are need to be added something special that will deploy QML files to the distribution folder. Could someone refresh my memory?

      For now I am adding it through Qt Creator interface, but it's not deploying on device when building it.

      What am I missing?

      J.Hilk 1 Reply Last reply Reply Quote 0
      • J.Hilk
        J.Hilk Moderators @bogong last edited by

        @bogong
        DISTFILES iirc
        https://doc.qt.io/qt-5/qmake-variable-reference.html#distfiles

        Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct

        Qt Needs YOUR vote: https://bugreports.qt.io/browse/QTQAINFRA-4121


        Q: What's that?
        A: It's blue light.
        Q: What does it do?
        A: It turns blue.

        B 1 Reply Last reply Reply Quote 0
        • B
          bogong @J.Hilk last edited by bogong

          @J-Hilk It's ignored. I don't know why.

          Screenshot 2020-08-19 at 10.48.30.png

          It's the first thing that I've checked.

          J.Hilk 1 Reply Last reply Reply Quote 0
          • J.Hilk
            J.Hilk Moderators @bogong last edited by

            @bogong It says in the documentation, thats its for UnixMake specs only, I assume thats the issue 🤔

            I don't know, the other idea I have would be a QMake_POST_LINK export, that copies all files after compilation

            Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct

            Qt Needs YOUR vote: https://bugreports.qt.io/browse/QTQAINFRA-4121


            Q: What's that?
            A: It's blue light.
            Q: What does it do?
            A: It turns blue.

            B 1 Reply Last reply Reply Quote 0
            • B
              bogong @J.Hilk last edited by bogong

              @J-Hilk Now I have this

              Screenshot 2020-08-19 at 11.05.25.png

              Never been having this kind of troubles in any project

              Screenshot 2020-08-19 at 11.09.55.png

              1 Reply Last reply Reply Quote 0
              • fcarney
                fcarney last edited by

                In order to copy files we have a build step like this:

                templates.path = $$INSTALL_BASE
                templates.files = \
                     ../file.txt \
                     ../file2.txt
                INSTALLS += templates
                

                You will have to figure out the correct paths though. I believe "templates" is a name you can choose.

                C++ is a perfectly valid school of magic.

                B 1 Reply Last reply Reply Quote 0
                • B
                  bogong @fcarney last edited by

                  @fcarney It's not working. Still ignoring copying files totally.

                  J.Hilk 1 Reply Last reply Reply Quote 0
                  • J.Hilk
                    J.Hilk Moderators @bogong last edited by

                    @bogong

                    defineTest(copyToDestDir) {
                        files = $$1
                        dir = $$2
                        # replace slashes in destination path for Windows
                        win32:dir ~= s,/,\\,g
                    
                        for(file, files) {
                            # replace slashes in source path for Windows
                            win32:file ~= s,/,\\,g
                    
                            QMAKE_POST_LINK += $$QMAKE_COPY_DIR $$shell_quote($$file) $$shell_quote($$dir) $$escape_expand(\\n\\t)
                        }
                    
                        export(QMAKE_POST_LINK)
                    }
                    
                    copyToDestDir(sourceFolder, destination)
                    

                    Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct

                    Qt Needs YOUR vote: https://bugreports.qt.io/browse/QTQAINFRA-4121


                    Q: What's that?
                    A: It's blue light.
                    Q: What does it do?
                    A: It turns blue.

                    B 1 Reply Last reply Reply Quote 0
                    • B
                      bogong @J.Hilk last edited by bogong

                      @J-Hilk Everything ignored on MacOS. I really don't know what is going on. It's DO NOT copying any files. I just need to add *.qml files to the project without resource files, directly. Nothing more.

                      1 Reply Last reply Reply Quote 0
                      • First post
                        Last post