Important: Please read the Qt Code of Conduct -

[Resolved]add bundle resource to *.app , what is the relative path of "APP_QML_FILES.files"

  • I am building a qml project and add some javascript source files in "Other files"(generated by Qt Creator).
    These files is put in my folder named "jssrc/test.js".

    What I want to do is copy these files as bundle resource in to the .app, when the project is built.
    And I found the way in forum, like this:

    APP_QML_FILES.files = /Users/jw/mycode/xcode/colorbox/colorbox/jssrc/test.js
    APP_QML_FILES.path = jssrc

    But I have to use the full path "/Users/jw/mycode/xcode/colorbox/colorbox/jssrc/test.js".
    If I use "jssrc/test.js", it doesn't work.

    Two questions:
    So what is the search path of the .pro file,and how can I use relative path?
    Why other flags ,which use relative path, works,such as:


    If I want to add some other files such as image files, should I add these bundle files one by one in .pro file?
    Is there convenient or maybe smart way to do such thing automatically?

    Who can explain that to me in detail.
    Thanks in advance.

  • Moderators

    Please try using $$PWD to automatically add the path to current dir.

    Qt offers the Qt Resource System "link": You can use it to store any number and type of files.

  • Thanks, sierdzio.
    I write the .pro like below and it works.

    APP_QML_FILES.files = @PWD/jssrc/test.js
    APP_QML_FILES.path = jssrc

    I did use qrc system and now I am trying dynamically load file.
    Your link does help, thanks a lot.

    Another question , where can I find the pre-defined Macro in .pro,like PWD, QMAKE_BUNDLE_DATA, and so on ?
    Can you give me the link please?

  • Moderators

    All the ones that Qt decided to make official are listed in the documentation: "qmake variable reference": This is not all qmake can do, there are also built-in functions and conditionals (all in the docs). You can also make system calls in .pro files, but that is - obviously - platform-dependent.

    And apart from that all, qmake has a lot of undocumented features. Some of them can be very useful, but since they are not documented, they are also not officially supported and can be changed or removed between releases - without any warning. You would have to dig a bit to find them (try Googling "undocumented qmake" if you are curious).

  • Thanks ,sierdzio. ; )

Log in to reply