Reputation: 17100
when working with Qt Creator and developing my project, I've added to a resource file my txt file which contains some information. I thought that this file will be incorporated into exe file and I won't have to supply this file with my exe file. Now I'm running this exe file of my project and I'm getting info that the txt file couldn't be found (although everything works perfectly when run via Qt creator). Is there any way to make it work as so I don't have to provide this txt file with my program?
EDIT:
Resource file:
<RCC>
<qresource prefix="/settings">
<file>Resources/setting_files/accepted_file_extensions.txt</file>
</qresource>
</RCC>
And I'm accessing it:
boost::filesystem3::ifstream fin("./Resources/setting_files/accepted_file_extensions.txt");
Upvotes: 0
Views: 1601
Reputation: 23921
It works when you run in Qt Creator because the working directory is where you have your Resources folder. That Boost ifstream does not read the resource from your exe but the real file on the disk. Boost has no idea about Qt resources (nor should it). Instead, use QResource to read the resource data from your exe or use QFile to read it as if it was a file (by prefixing the path with :
).
Upvotes: 1