Results 1 to 3 of 3

Thread: can't able to filter media files from a directory

  1. #1
    Join Date
    Jun 2010
    Posts
    137
    Thanks
    9
    Qt products
    Qt4
    Platforms
    Windows

    Default can't able to filter media files from a directory

    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..

    Qt Code:
    1. QString path = QFileDialog::getExistingDirectory (this, tr("Directory"), directory[i].path());
    2. if ( path.isNull() == false )
    3. {
    4. directory[i].setPath(path);
    5.  
    6. qDebug() << directory[i].entryList().filter("Media files (*.mkv *avi)");
    7. }
    To copy to clipboard, switch view to plain text mode 

    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

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: can't able to filter media files from a directory

    QStringList::filter() is not the same as the file filter used by QFileDialog.
    I think what you want is QFileDialog::getOpenFileNames ().
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Jun 2010
    Posts
    137
    Thanks
    9
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: can't able to filter media files from a directory

    Yes you are right. I have to use
    directory[i].setNameFilters()
    function for this.

Similar Threads

  1. Hiding files which don´t fit the filter
    By Percy in forum Newbie
    Replies: 2
    Last Post: 27th April 2010, 16:51
  2. Listing files by filter on Macbook
    By dwarnold45 in forum Newbie
    Replies: 2
    Last Post: 30th March 2010, 05:01
  3. QDirModel (filter files, custom Icon, look)
    By prashant in forum Qt Programming
    Replies: 1
    Last Post: 6th September 2009, 10:39
  4. how to play media files.
    By hrudhay in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 28th August 2008, 11:24
  5. Playing Media files in Qt 4
    By sar_van81 in forum Qt Programming
    Replies: 2
    Last Post: 18th December 2007, 06:53

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.