[SOLVED] QFile open problem with path to resource file
-
Hi,
I have this code:
@QFile file(fileName);
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
qDebug() << "Could not open file:" << file.errorString();
file.close();
return;
}@If filename = "/absolute/path/to/appSettings.json" it opens the file.
If filename = ":/config/appSettings.json" it throws anUnknown error
.The thing is, I have the same code for reading the file, and it works with both versions of the path, so the qrc file is set correctly. I checked permissions and even changed them to -rwxrwxrwx but still get the same error (actually it would not work with absolute path if this were the problem, and it does).
Any clues on what may be going on?
Cheers!
-
Hi,
Resources files are read-only (and they are compiled in your binary executable).
If you need a read-write solution, you should copy the resource file somewhere (QStandardPaths comes to mind) and use that file instead.