Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to recursively create a directory in Qt?

Tags:

Is there a function that given an absolute path will attempt to create all directories in the path that do not exist?

like image 201
Nathan Osman Avatar asked Jun 03 '11 20:06

Nathan Osman


1 Answers

You can use

bool QDir::mkpath(const QString &dirPath) const

as described in the Qt4.x documentation and Qt5.x documentation

Creates the directorypath dirPath.

The function will create all parent directories necessary to create the directory.

Returns true if successful; otherwise returns false.

If the path already exists when this function is called, it will return true.

like image 67
azyoot Avatar answered Oct 13 '22 06:10

azyoot