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. Failing to SetFilter of QFileSystemModel for .mp3/.avi files

Failing to SetFilter of QFileSystemModel for .mp3/.avi files

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 920 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.
  • S Offline
    S Offline
    Stoned Jesus
    wrote on last edited by
    #1

    I need to traverse my drives in system and display only .mp3 and .avi files. basically set the filter to these extensions and display the files in a treeview.

    @QStringList sDriveFilters;
    QString sPath = m_SystemModel->fileInfo(index).absoluteFilePath();
    ui->DriveListView->setRootIndex(m_SystemListViewModel->setRootPath(sPath));

    sDriveFilters << "*.aac" << "*.wmv" << "*.avi" << "*.mpeg" << "*.mov" << "*.3gp" << "*.flv" << "*.mp3" ;
    
    m_SystemModel->setRootPath(QDir::currentPath());
    m_SystemModel->setFilter(QDir::NoDotAndDotDot | QDir::AllDirs );
    m_SystemListViewModel->setFilter( QDir::Files | QDir::AllDirs | QDir::NoDotAndDotDot );
    
    m_SystemListViewModel->setNameFilters(sDriveFilters);
    m_SystemListViewModel->setNameFilterDisables(false);@
    

    If you notice I have set filter as @setFilter( QDir::Files | QDir::AllDirs | QDir::NoDotAndDotDot )@

    and setNameFilters to sDriveFilters. This displays all the directories in my treeview. Ideally I want it to display only audio/video files.

    --
    Thanks & Regards,
    Stoned Jesus

    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