I want to use Qt's resource system for my program. Visual Studio's resource system is giving me headaches while loading non text based files like .png, .bmp, .jpeg, etc. I have read a bit about Qt and it seems very interesting. I would like to use its resource system. I have downloaded the Qt Visual Studio Tool extension. I have also made a resource file containing the files that I would like to embed in the executable (NOT Qt's executable). I have made a Visual Studio Project, NOT a Qt Project. The only reason I installed the extension is to embed the resources in my executable and access them. Also, if possible I would like to include Qt's headers in my non-Qt Project, so I can easily register and read those resources. So, in a nutshell, this is what I want to do:
Something like this:
#include <Qtheaderfiles>
struct FileData {
unsigned char* bytes;
unsigned int size;
};
FileData loadFromResource(const std::string& res) {
QtFile file(res);
//get all the data from the file and return it in bytes.
return FileData { fileBytes, fileSize };
}
I expect the above code to compile even when there is no actual file in the directory "res", because all of the resources have been embedded into the executable.
Skimming the Qt documentation on resources :
.qrc
file that contains a list of the resources you would like to include rcc
on that file ( documentation )
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.