2

How to add qrc file to "QML app with C++ plugin (cmake)" project ? I can't find a working instruction. I found only one thing, add this to CMakeLists.txt:

qt5_add_resources(RESOURCES modules/ProjectName/resources.qrc)

with this the file is finally shown in the files tree in Qt but it's clearly that the file is not included in the executable after compiling so what to do ?

leouss4dev
  • 33
  • 5

2 Answers2

0
qt5_add_resources(RESOURCES modules/ProjectName/resources.qrc)

That thing converts qrc files into C++ files. Names of C++ files are stored in the RESOURCES variable.

Executables and libraries are compiled from C++ files by using add_executable and add_library in CMakeFiles.txt. In the "QML app with C++ plugin (cmake)" project template the "C++ plugin" part means library. So somewhere in CMakeFiles.txt there is an add_library. Resource files should be added there:

add_library(Myappbackend MODULE
    ${Myappbackend_SRCS}
    ${RESOURCES}
)

Alternatively, the qrc can be compiled directly into separate library by the qt5_add_resources macro or not compiled at all (so no qt5_add_resources at all) and be load by the Qt application in runtime (see source of the core ubuntu-terminal-app for example).

Velkan
  • 3,516
  • 4
  • 24
  • 45
  • Even that did not work the main thing I want to do is copy an SQLite database template and other files from the sources file to specific folder so what to do ? – leouss4dev Apr 13 '15 at 12:58
0
set(CMAKE_AUTORCC ON)
add_executable(${PROJECT_NAME} ${SRC_LIST} modules/ProjectName/resources.qrc)
Tim Jenßen
  • 101
  • 2
  • 1
    Welcome to Ask Ubuntu! I recommend [edit]ing this answer to expand it with specific details about what this is supposed to do. (See also [How do I write a good answer?](/help/how-to-answer) for general advice about what sorts of answers are considered most valuable on Ask Ubuntu.) – David Foerster Feb 11 '16 at 10:23