[SailfishDevel] Application specific write-access folder

Robin Burchell robin+meego at viroteck.net
Wed Nov 13 22:53:00 UTC 2013


Hi,

On Sun, Nov 10, 2013 at 12:02 AM, Mark Johnson <markydon1501 at hotmail.com> wrote:
> For some reason when I try to open a file with QIODevice::ReadWrite access
> in the following directory it fails every time (the file should be
> instantiated as a result of the QFile::open() call):
>
> QString mainFileName =
> QStandardPaths::writableLocation(QStandardPaths::DataLocation) + "/" +
> KUserProfilesFilename;

Per the documentation[1] for writableLocation, you also need to make
sure the folder exists using QDir::mkpath[2].

Also note that you can check QFileDevice::error[3] on your QFile
instance to try find out why operations fail.

[1]: http://qt-project.org/doc/qt-5.0/qtcore/qstandardpaths.html#writableLocation
[2]: http://qt-project.org/doc/qt-5.0/qtcore/qdir.html#mkpath
[3]: http://qt-project.org/doc/qt-5.0/qtcore/qfiledevice.html#error

BR,

Robin


More information about the Devel mailing list