PDA

View Full Version : Can't create folder



cpuinthebrain
21st August 2016, 16:16
Hi,

I read many many tutorials in internet how we can create new folder(directory) using QT.Unfortunately i can't have success with no one.I'm on Mac OS X 10.10 with Qt 5.7.

What i make is:



QString path1 = "Documents";

QDir dir(path1);
if(!dir.exists())
{
qDebug() << "Creating " << path1 << "directory";
dir.mkdir(path1);
}
else
{
qDebug() << path1 << " already exists";
}


I also can't understand how to create folder in Users/Library/Application Support/My_program_name_folder
using QStandardPaths in this case QStandardPaths::DataLocation.

anda_skoa
21st August 2016, 20:55
Your code tries to create a directory "Documents" inside a non-existing directory.



using QStandardPaths in this case QStandardPaths::DataLocation.

Maybe something like


QDir root = QDir::root();
root.mkpath(QStandardPaths::writableLocation(QStan dardPaths::DataLocation));


Cheers,
_

cpuinthebrain
23rd August 2016, 19:24
Thank you!