Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

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

    General and Desktop
    1
    1
    864
    Loading More Posts
    • 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
      Stoned Jesus last edited by

      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 Reply Quote 0
      • First post
        Last post