I have a few text files embedded in a .qrc file. However, my back-end project is not based on Qt and a couple of times in the Qt front-end project, I have to call A::read(std::string const& filePath)
-like functions that utilize std::ifstream
to read the file. Of course, there's no way for std::ifstream
to find the file stored in Qt Resource System, so I started thinking about conversion.
Using std::stringstream
was the first thing that popped into my head:
std::istringstream iss(QTextStream(&file).readAll().toStdString());
// I didn't find any conversion functions in QTextStream
But I hope that there's something better. (I don't need to preserve unicode.) I will accept even solutions closer to the root of the problem - qrc.