Create and use dynamic library with Qt resources

I have created a Dynamic Library using Qt Creator which I have included in another Qt Project but when I call functions with works with resource files for example reading the contents of a .txt in resources, it does not work.

Once I have the Build of the Dynamic Library which created the *.so, *.a and the qrc_resources.cpp files in another folder outside the library project folder, example:

  • Project Folder: /home/username/Qt Project/library/
  • Build Folder: /home/username/Qt Project/build-library/

I then copy the build files into the library project folder and from the test project (a Qt Application Project), I right click on the project -> Add Library -> External Library -> Select the .so file (from the library project folder which I just copied).

Then, after including the header files and calling a function which reads the contents of a file from the qrc resources, it does not work.

UPDATE

I used a QFile to check if the Resource File exists in which it does but I get this error: QIODevice::read (QFile, ":/file.txt"): device not open


Adding Libraries to Projects

later

I think need to create an external resource file.