I want to traverse the drives present in my system and search for audio/video files inside it. Basically I need to traverse my drives and display only .mp3 and .avi files. Then set the filter to these extensions and display the files in a treeview. I have 2 tree views, One to display System Directories and other to display audio/video files
Qt Code:
// Gets called when application starts void DetailView::onCamStartup() { m_SystemModel = new QFileSystemModel(this); m_SystemListViewModel = new QFileSystemModel(this); ui->DriveView->setModel(m_SystemModel); ui->DriveListView->setModel(m_SystemListViewModel); // regard less how many columns you can do this using for: for(int nCount = 1; nCount < m_SystemModel->columnCount(); nCount++) ui->DriveView->hideColumn(nCount); } // Displays Files in Detail View on Clicking Drive { QStringList sDriveFilters; m_SystemListViewModel->setRootPath(sPath); ui->DriveListView->setRootIndex(m_SystemListViewModel->index(sPath)); sDriveFilters << "*.aac" << "*.wmv" << "*.avi" << "*.mpeg" << "*.mov" << "*.3gp" << "*.flv" << "*.mp3" ; m_SystemListViewModel->setNameFilters(sDriveFilters); m_SystemListViewModel->setNameFilterDisables(false); }To copy to clipboard, switch view to plain text mode
You can notice in the above click event that I have set Filter to selected extensions. It displays the mp3 files which are in the drive but it doesnt parse the subfolders and fails to display the audio/video files present inside it.
Here is the image:
4nxBa.png
If you notice there are Folders inside SONGS folder where mp3 files are present but it doesnt display at all. Basically if i click New Volume E: it should display all mp3/.avi files in my right side treeview. Now i clicked SONGS folder, it displays one file inside the folder but it doesnt display the files inside the subfolders present. Where am i making mistake?
Bookmarks