QDir dirName("C:/Users/User/Desktop"); QFileInfoList fileList = dirName.entryInfoList(); foreach(QFileInfo fileInfo, fileList) { qDebug() << fileInfo.absoluteFilePath(); }
QDir dirName("C:/Users/User/Documents"); if (dirName.mkdir("NewFolder")) { qDebug() << "Directory created successfully!"; } else { qCritical() << "Failed to create directory."; }This code creates a QDir object pointing to the Documents folder of the current user and uses the mkdir() function to create a new folder called "NewFolder". The function returns a boolean value indicating whether the directory was created successfully, which is printed out to the console. Package library: Qt Core module (QtGui and QtWidgets modules also include the QDir class)