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



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


Log in to reply
 

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