Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

QDir mkdir with absolutepath

I have problem with the creation of dir with Qt. I would like to create a dir in documents'dir so, I make some things like that :

QString path("C:/Users/Me/Documents/MyApp/profiles/");
Qdir dir = QDir::root();
dir.mkdir(path);

But that doesn't work! I have test with "/" and "\" for the separators but in the two cases that not work.

How I can create my dir?

Thank you.

like image 717
Guillaume Avatar asked Mar 09 '12 22:03

Guillaume


2 Answers

You can do this:

QDir dir(path);
if (!dir.exists()){
  dir.mkdir(".");
}
like image 74
yerlilbilgin Avatar answered Nov 16 '22 17:11

yerlilbilgin


Instead of using dir.mkdir(), try to use QDir::mkpath;
i.e. as dir.mkpath(path);

like image 35
Dcow Avatar answered Nov 16 '22 17:11

Dcow