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 Parse System Directories using QFileSystemModel for different Audio/Video Files
Forum Updated to NodeBB v4.3 + New Features

Failing to Parse System Directories using QFileSystemModel for different Audio/Video Files

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 901 Views 1 Watching
  • 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 have come across a situation where I need to parse/traverse my System Directories and search for files like .mp3, .mpg etc.

    Well in my .ui I have 2 Tree Views, one towards right and other towards left. The left one displays System Directories and on selecting the drive, the right treeview displays the .mp3, .mpg etc files.

    Here is my Cpp class:
    @
    //Gets called on App startup
    void PanasonicViewer::onCamStartup()
    {
    m_SystemModel = new QFileSystemModel(this);
    m_SystemListViewModel = new QFileSystemModel(this);
    m_SystemModel->setRootPath(QDir::homePath());
    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);
    

    }

    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::homePath());
    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);
    

    }@

    Here is my .h file:
    @QFileSystemModel *m_SystemModel;
    QFileSystemModel *m_SystemListViewModel;@

    When I run my app, it displays only those audio/video files which are present in the Drive. I mean it doesn't parse the folders present inside the drive where audio/video files are present. It just displays the files which are in the drive and not subdirectories. How can i achieve it? :)

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