PDA

View Full Version : can't able to filter media files from a directory



baluk
4th November 2010, 14:30
Hi,

In my app, I want to read the media files with extension *.avi and *.mkv from the directory. But i am not able to filter them when reading through QDir. If I remove the filter I can get all the files listed in the directory. Here is my code..



QString path = QFileDialog::getExistingDirectory (this, tr("Directory"), directory[i].path());
if ( path.isNull() == false )
{
directory[i].setPath(path);

qDebug() << directory[i].entryList().filter("Media files (*.mkv *avi)");
}


If i Just use
directory[i].entryList(), I get all the files. Can any one please correct me If I am fallowing wrong filter format.

Thank You,
Baluk

high_flyer
4th November 2010, 15:23
QStringList::filter() is not the same as the file filter used by QFileDialog.
I think what you want is QFileDialog::getOpenFileNames ().

baluk
4th November 2010, 21:12
Yes you are right. I have to use
directory[i].setNameFilters() function for this.