Resources problem
-
Hello.
In my last project, I didn't have any problems with Save data to my .txt file in project resources.
This time this not working and I don't know why. I used .errorString() and i got "Unknown Error"
If I save it not to resources, but to my local path then all works.QFile file(":/bin/Profile.txt"); if (file.open(QIODevice::WriteOnly | QIODevice::Text)) { QTextStream stream(&file); stream << ui->ShowName->text()<< '\n'; stream << Euro << "\n"; stream << Streak << "\n"; stream << isDataCorrect <<"\n"; stream << Tasks[0] <<"\n"; stream << Tasks[1] <<"\n"; stream << Tasks[2] <<"\n"; stream << Tasks[3] <<"\n"; stream << Tasks[4] <<"\n"; stream << isAccountCreated<<"\n"; } else qDebug() << file.errorString(); }
-
What I can do? My project will be used on other devices and I want to save this data somewhere.
Use program directories or any default path, specified by path variables (User dir, home dir, program files, etc.) and save your file, which seems to be a config file, there.
https://doc.qt.io/qt-5/qstandardpaths.html#StandardLocation-enum
-
You can't open a resource file in write mode.
-
But not in a compiled-in resource file...
-
What I can do? My project will be used on other devices and I want to save this data somewhere.
Use program directories or any default path, specified by path variables (User dir, home dir, program files, etc.) and save your file, which seems to be a config file, there.
https://doc.qt.io/qt-5/qstandardpaths.html#StandardLocation-enum