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. QDirIterator file filtering issue
Qt 6.11 is out! See what's new in the release blog

QDirIterator file filtering issue

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 1.3k Views 2 Watching
  • 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.
  • HunterMetcalfeH Offline
    HunterMetcalfeH Offline
    HunterMetcalfe
    wrote on last edited by
    #1

    I'm attempting to filter the QDirIterator based upon multiple different file extensions. My extensions are in the form of

    *.(somePhrase)* 
    

    I save each of these filters into a QStringList called fileFilter. The location of the folder is set when the user selects a folder in a QFileDialog. Without the filters, this routine below works returning every file.

    However, this isn't working with the filters set, even though I know there are files with these extensions.

    QDirIterator it( folderLocation, fileFilter, QDir::Files, QDirIterator::Subdirectories );
    while( it.hasNext() )
    {
       QFile * file = new QFile( it.next() );
       //do things
    }
    

    This does not work. The iterator returns no files even though there are files following at least one of the file filters. What could be causing the issue? I feel as though I'm missing something simple.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Can you show a concrete sample of file filter you are using ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      HunterMetcalfeH 2 Replies Last reply
      0
      • SGaistS SGaist

        Hi,

        Can you show a concrete sample of file filter you are using ?

        HunterMetcalfeH Offline
        HunterMetcalfeH Offline
        HunterMetcalfe
        wrote on last edited by
        #3

        @SGaist A file will look something like - something.recordpart1 and something.recordpart2 and so on.

        So the file filter would be

        *.record*
        
        1 Reply Last reply
        0
        • SGaistS SGaist

          Hi,

          Can you show a concrete sample of file filter you are using ?

          HunterMetcalfeH Offline
          HunterMetcalfeH Offline
          HunterMetcalfe
          wrote on last edited by HunterMetcalfe
          #4

          @SGaist I figured it out. The files actually do not have "." in them. Silly; however, at least this might help someone use QDirIterator in the future. Thanks for taking a look!

          1 Reply Last reply
          0

          • Login

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