#includeint main() { QFileInfo fileInfo("/home/user/Documents"); if (fileInfo.isDir()) { qDebug() << "The path points to a directory."; } else { qDebug() << "The path points to a file."; } return 0; }
#includeIn this example, we use the QDir class to open the directory "/home/user/Documents". We then use the entryInfoList() function to get a list of all files and directories in the folder. We loop through each QFileInfo object in the list and check if it is a directory using the isDir() function. If it is, we print a message with the absolute path of the directory. Package library: Qt (QtCore module)int main() { QDir directory("/home/user/Documents"); foreach (QFileInfo fileInfo, directory.entryInfoList()) { if (fileInfo.isDir()) { qDebug() << fileInfo.absoluteFilePath() << "is a directory."; } } return 0; }