For Qt5 there is QDir :: removeRecursively :
QDir dir("C:\\Path\\To\\Folder\\Here"); dir.removeRecursively();
For Qt4 or lower, you can use a recursive function that deletes each file:
bool removeDir(const QString & dirName) { bool result = true; QDir dir(dirName); if (dir.exists(dirName)) { Q_FOREACH(QFileInfo info, dir.entryInfoList(QDir::NoDotAndDotDot | QDir::System | QDir::Hidden | QDir::AllDirs | QDir::Files, QDir::DirsFirst)) { if (info.isDir()) { result = removeDir(info.absoluteFilePath()); } else { result = QFile::remove(info.absoluteFilePath()); } if (!result) { return result; } } result = dir.rmdir(dirName); } return result; }
as indicated here .
Iuliu source share