I have encountered a strange issue where QFile.open
is unable to open a file which is added in the qrc resource file. My qrc file looks like this
I'm using following code to read the file theme_normal.qss
QFile file(":/styles/theme_normal.qss");
if (file.open(QIODevice::ReadOnly | QIODevice::Text))
{
QString style(file.readAll());
file.close();
}
else
{
QMessageBox::critical(nullptr, "Error", "Error loading style file: " + file.errorString());
}
I'm getting following error: No such file or directory
Same code (as it is) works fine in Qt 5.7.0. I'm facing above issue with Qt 5.9.2. What could be the reason?
My example project: https://github.com/warunanc/QtFileFromResources