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. Display Audio & Video Files In TreeView on Clicking Any Drive (QFileSystemModel)

Display Audio & Video Files In TreeView on Clicking Any Drive (QFileSystemModel)

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 1.2k 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 want to traverse the drives present in my system and search for audio/video files inside it. Basically traverse the sub directories and display the file inside the treeview. I have 2 tree views, One to display System Directories and other to display audio/video files.

    @// Displays System Drives inside TreeView When Application Starts
    void PanasonicViewer::onCamStartup()
    {
    m_SystemModel = new QFileSystemModel(this);
    m_SystemListViewModel = new QFileSystemModel(this);
    m_SystemModel->setRootPath(QDir::currentPath());
    ui->DriveView->setModel(m_SystemModel); //Left side TreeView
    ui->DriveListView->setModel(m_SystemListViewModel); //Right Side TreeView

    // regard less how many columns you can do this using for:
    for(int nCount = 1; nCount < m_SystemModel->columnCount(); nCount++)
       ui->DriveView->hideColumn(nCount);
    

    }

    //On Clicking The TreeView, it should display Audio and Video files in my another tree view (DriveListView)
    void PanasonicViewer::on_DriveView_clicked(const QModelIndex &index)
    {
    QStringList sDriveFilters;

    QString sPath = m_SystemModel->fileInfo(index).absoluteFilePath();
    ui->DriveListView->setRootIndex(m_SystemListViewModel->setRootPath(sPath));    
    
    m_SystemModel->setRootPath(QDir::currentPath());
    m_SystemModel->setFilter(QDir::NoDotAndDotDot | QDir::AllDirs );
    m_SystemListViewModel->setFilter( QDir::Files | QDir::NoDotAndDotDot );
    
    sDriveFilters << "*.aac" << "*.wmv" << "*.avi" << "*.mpeg" << "*.mov" << "*.3gp" << "*.flv" << "*.mp3" ;
    
    m_SystemListViewModel->setNameFilters(sDriveFilters);
    m_SystemListViewModel->setNameFilterDisables(false);
    

    }@

    You can notice in the above click event that I have set Filter to selected extensions. This seems to work and displays audio and video files when I click a drive i.e. E:\ but doesnt display the files present inside subfolders. Where am i going wrong?

    --
    Thanks & Regards,
    Stoned Jesus

    1 Reply Last reply
    0
    • EddyE Offline
      EddyE Offline
      Eddy
      wrote on last edited by
      #2

      this is the same topic"as this one":http://qt-project.org/forums/viewthread/22050/

      Please continue in the same thread instead of making new ones.

      I'm closing this one.

      Qt Certified Specialist
      www.edalsolutions.be

      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