QDirIterator file filtering issue

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


    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.

  • Lifetime Qt Champion


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

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

    So the file filter would be


  • @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!

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.