Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
file search with regexp
kgregory last edited by
I'm looking for a way to find all files in a directory with a particular extension. For example, all .txt files within the download folder.
This seems straightforward, and I thought I could do it with
QStandardPaths::locateAll(QStandardPaths::DownloadLocation, "*.txt")but that doesn't work.
However, if I do
QStandardPaths::locateAll(QStandardPaths::DownloadLocation, "somefile.txt")then it will return a QStringList with "somefile.txt" in it. So I think I'm close. I figured I might be able to use QRegularExpression here, but it's not clear to me how I would do that. Any suggestions?
This is not what you need.
QDir dir("YOUR SEARCH PATH"); qDebug() << dir.entryList(QStringList() << "*.txt", QDir::Files);