Checking if a folder exists (and creating folders) in Qt, C++

Switch picture Switch · Feb 11, 2010 · Viewed 133.5k times · Source

In Qt, how do I check if a given folder exists in the current directory?
If it doesn't exist, how do I then create an empty folder?

Answer

Kyle Lutz picture Kyle Lutz · Feb 11, 2010

To check if a directory named "Folder" exists use:

QDir("Folder").exists();

To create a new folder named "MyFolder" use:

QDir().mkdir("MyFolder");