Reputation: 81
So I've created a folder using the answer and I'm sort of stuck. I create the directory and check if it exists
QDir().mkdir(path);
if(QDir(path).exists()) {
std::cout<<"created!\n";
}
else {
std::cout<<"not created!\n";
}
console outputs that the directory is created but I can't find it. It's not in the project folder. I also tried to search for it in Finder.
Upvotes: 0
Views: 525
Reputation: 5665
Assuming you are using Qt5.
The default constructor for QDir(const QString& path = QString())
creates instance of the QDir
pointing to the current working directory. Check the QDir::current()
static method.
The QDir::mkdir(const QString& dirName)
creates the sub directory in the current the instance points to. The return value is true if the directory was successfully created.
So for your specific case the directory described in path
will be created in current working directory of the program. For debugging purposes you can log QDir(path).absolutePath()
.
Normally while debugging in XCode it sets the current working directory to something like "~/Library/Developer/Xcode/DerivedData/-ddettossvnbbvaarrlgkfotjkeew/Build/Products/" with the "ddettossvnbbvaarrlgkfotjkeew" being generated for the target, project and some other parameters.
If the problem persists please add more data to your question.
Upvotes: 1