Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. file search with regexp
Qt 6.11 is out! See what's new in the release blog

file search with regexp

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 2 Posters 464 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kgregory
    wrote on last edited by
    #1

    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?

    jsulmJ 1 Reply Last reply
    0
    • K kgregory

      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?

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @kgregory said in file search with regexp:

      QStandardPaths::locateAll

      This is not what you need.

      QDir dir("YOUR SEARCH PATH");
      qDebug() << dir.entryList(QStringList() << "*.txt", QDir::Files);
      

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      3

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved