Standard path save location
-
Hello guys, Can you help me with how I can save my data on every device using a standard path?
I think the best location to save is my application folder.QFile file("C:/Users/<USER>/Documents"); if (file.open(QIODevice::WriteOnly | QIODevice::Text)) { qDebug() << "SAVED"; QTextStream stream(&file); ....
-
QFile file(QStandardPaths::writableLocation(QStandardPaths::DesktopLocation));
I'm trying this actually, but i cant delete -j
https://forum.qt.io/topic/40720/permission-denied -
Golden rule of Qt is: when you need a class, search the docs for the first name that comes to your head :-)
And there is, just like you guessed, a class named QStandardPaths.
You need to use the
writableLocation()
function. -
Golden rule of Qt is: when you need a class, search the docs for the first name that comes to your head :-)
And there is, just like you guessed, a class named QStandardPaths.
You need to use the
writableLocation()
function. -
@sierdzio
Nice, I got it, but "Access is denied."I have Antivirus turned off but still the same problem.
@naax said in Standard path save location:
"Access is denied."
What is the patch you're trying to access when you get this error?
-
@naax said in Standard path save location:
"Access is denied."
What is the patch you're trying to access when you get this error?
-
QFile file(QStandardPaths::writableLocation(QStandardPaths::DesktopLocation));
I'm trying this actually, but i cant delete -j
https://forum.qt.io/topic/40720/permission-denied -
@naax You are trying to open a directory like a file.
Add a file name you want to use:QFile file(QStandardPaths::writableLocation(QStandardPaths::DesktopLocation) + "/somefile.txt");