Hi All,
I am trying to search files from directories & its subdirectories. I want to do recursive searching. I am unable to find option to do it.
Please tell me the way to do recursive searching using QFileDialog.
Thanks in advance!
Printable View
Hi All,
I am trying to search files from directories & its subdirectories. I want to do recursive searching. I am unable to find option to do it.
Please tell me the way to do recursive searching using QFileDialog.
Thanks in advance!
You have to get the entries of a directory and then iterate over every single file and check whether it is a directory itself. If that is true, you recursively start the function on that file. Take a look at the entryList() and entryInfoList() members of QDir.
See this post for how to recursively iterate through a directory and its subdirectories: http://www.qtcentre.org/forum/p-recu...ostcount2.html. Alternatively, you could abuse QDirModel and QAbstractItemModel::match().
ugly implementation to give you a little bit of a hint on how to do it.
Code:
#include <QApplication> #include <QtGui> //#include "main.moc" int main(int argc, char* argv[]) { listFiles(dir, ""); return 0; } { indent += "\t"; qDebug() << indent + finfo.fileName() << endl; if (finfo.isDir()) { } } }
//Show All Files On Folder And Sub-folder With extinction "*.mov"
ui->listWidget_2->clear();
QStringList nameFilters;
nameFilters << "*.mov";
QDirIterator dirIterator(ui->TextPath->toPlainText(),nameFilters, QDir::Files, QDirIterator::Subdirectories);
while (dirIterator.hasNext()) {
ui->listWidget_2->addItem(dirIterator.next());
}