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();

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.


Try to use QDir::mkpath as dir.mkpath(path);

You can do this:

QDir dir(path);
if (!dir.exists()){

QDir dir = QDir::root() creates an instance of QDir configured to point to root and copies that setting to dir. To avoid the extra copy and code , you can use QDir dir(QDir::root);. On Windows it will point to the root of the system drive, usually C:\.

dir.mkdir(path); will attempt to create a subdirectory named path in the currently configured directory (root). This method expects a single directory name and not a full path. It also returns a bool result that you should be checking.

You probably want to be calling dir.mkpath(path) which will attempt to create the subdirectory specified along with all the necessary parent directories leading up to it. Again, you should check the result to see if it was successful.

please check the following links where they have described how to create the new directory..




Need Your Help

Android EditText, soft keyboard show/hide event?

android keyboard-events android-softkeyboard

Is it possible to catch the event that Soft Keyboard was shown or hidden for EditText?

iOS multiline label in Interface builder

ios objective-c swift uilabel line-breaks

How can I make a multiline UILabel in interface builder for iOS? I tried the UITextView but it didn't quite suit my needs.