Results 1 to 1 of 1

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

  1. #1
    Join Date
    Feb 2012
    Posts
    24
    Thanks
    4
    Thanked 11 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    Windows

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

    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:

    Qt Code:
    1. //Gets called on App startup
    2. void PanasonicViewer::onCamStartup()
    3. {
    4. m_SystemModel = new QFileSystemModel(this);
    5. m_SystemListViewModel = new QFileSystemModel(this);
    6. m_SystemModel->setRootPath(QDir::homePath());
    7. ui->DriveView->setModel(m_SystemModel); //Left side TreeView
    8. ui->DriveListView->setModel(m_SystemListViewModel); //Right Side TreeView
    9.  
    10. // regard less how many columns you can do this using for:
    11. for(int nCount = 1; nCount < m_SystemModel->columnCount(); nCount++)
    12. ui->DriveView->hideColumn(nCount);
    13. }
    14.  
    15. void PanasonicViewer::on_DriveView_clicked(const QModelIndex &index)
    16. {
    17. QStringList sDriveFilters;
    18.  
    19. QString sPath = m_SystemModel->fileInfo(index).absoluteFilePath();
    20. ui->DriveListView->setRootIndex(m_SystemListViewModel->setRootPath(sPath));
    21.  
    22. m_SystemModel->setRootPath(QDir::homePath());
    23. m_SystemModel->setFilter(QDir::NoDotAndDotDot | QDir::AllDirs );
    24. m_SystemListViewModel->setFilter( QDir::Files | QDir::NoDotAndDotDot );
    25.  
    26. sDriveFilters << "*.aac" << "*.wmv" << "*.avi" << "*.mpeg" << "*.mov" << "*.3gp" << "*.flv" << "*.mp3" ;
    27.  
    28. m_SystemListViewModel->setNameFilters(sDriveFilters);
    29. m_SystemListViewModel->setNameFilterDisables(false);
    30. }
    To copy to clipboard, switch view to plain text mode 

    Here is my .h file:

    Qt Code:
    1. QFileSystemModel *m_SystemModel;
    2. QFileSystemModel *m_SystemListViewModel;
    To copy to clipboard, switch view to plain text mode 

    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?
    Last edited by owais_blore; 19th November 2012 at 08:17.

  2. The following user says thank you to owais_blore for this useful post:


Similar Threads

  1. Failing to use QFileSystemModel in Qt
    By owais_blore in forum Newbie
    Replies: 1
    Last Post: 16th November 2012, 14:50
  2. Detecting changes to file system for QFileSystemModel
    By blackmarlin in forum Qt Programming
    Replies: 4
    Last Post: 10th October 2012, 16:29
  3. Replies: 0
    Last Post: 15th April 2011, 11:03
  4. Replies: 3
    Last Post: 5th July 2009, 17:22
  5. Greenphone audio/video
    By void* in forum Qt for Embedded and Mobile
    Replies: 3
    Last Post: 2nd February 2007, 05:41

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.