0

I have done this code in QT in order to open a Directory Dialog, choose a directory and read all the files in it:

QFileDialog dialog;
dialog.setFileMode(QFileDialog::Directory);
dialog.setOption(QFileDialog::ShowDirsOnly);
dialog.setViewMode(QFileDialog::Detail);
int res = dialog.exec();
QDir directory;

if (res) {
    directory = dialog.selectedFiles()[0];
    QStringList filesList = directory.entryList(QDir::Files);
    QString fileName;
    foreach(fileName, filesList) {
        qDebug() << "FileName " << fileName;
    }
}

The problem now is that I would also like to be able to read all the files in the subdirectories of the chosen directory.. do you know how it could be done?

ayasha
  • 1,221
  • 5
  • 27
  • 46
  • There are a lot of solutions. For example, http://www.qtcentre.org/threads/4307-how-to-recursive-a-directory-in-qt – Ilya Apr 14 '14 at 10:13
  • 2
    The same question with a solution: http://stackoverflow.com/questions/8052460/recursive-scanning-of-directories – Ilya Apr 14 '14 at 10:15

0 Answers0