Results 1 to 3 of 3

Thread: How to display Details of Audio File in QTreeView

Threaded View

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

    Exclamation How to display Details of Audio File in QTreeView

    I need to display details of all .mp3 files present in my drives. I am using QTreeView to display. Here is the code:
    Qt Code:
    1. // Displays Files in Detail View on Clicking Drive
    2. void DetailView::on_DriveView_clicked(const QModelIndex &index)
    3. {
    4. int m_count=0;
    5. QString sPath = m_SystemModel->fileInfo(index).absoluteFilePath();
    6. m_SystemListViewModel->setRootPath(sPath);
    7. ui->DriveListView->setRootIndex(m_SystemListViewModel->index(sPath));
    8.  
    9. m_SystemModel->setRootPath(QDir::currentPath());
    10. m_SystemModel->setFilter(QDir::NoDotAndDotDot | QDir::AllDirs );
    11. m_SystemListViewModel->setFilter( QDir::Files | QDir::NoDotAndDotDot );
    12.  
    13. QStringList m_list;
    14. QDirIterator dirIt(sPath,QDirIterator::Subdirectories);
    15.  
    16. while (dirIt.hasNext())
    17. {
    18. dirIt.next();
    19. if (QFileInfo(dirIt.filePath()).isFile())
    20. {
    21. if (QFileInfo(dirIt.filePath()).suffix() == "mp3" || QFileInfo(dirIt.filePath()).suffix() == ".avi")
    22. {
    23. m_list << dirIt.filePath();
    24.  
    25. QModelIndex index = model->index(m_count, 0, QModelIndex());
    26. model->setHeaderData( 0, Qt::Horizontal, "File Name" );
    27. model->setHeaderData( 1, Qt::Horizontal, "Size" );
    28. model->setHeaderData( 2, Qt::Horizontal, "Type" );
    29. model->setHeaderData( 3, Qt::Horizontal, "Date Modified" );
    30.  
    31. model->setData( index, dirIt.fileName(), Qt::DecorationRole );
    32. QStandardItem *item = new QStandardItem(dirIt.fileName());
    33. model->setItem(m_count, item);
    34.  
    35. ui->DriveListView->setModel(model);
    36. m_count++;
    37. }
    38. }
    39. m_SystemListViewModel->setNameFilterDisables(false);
    40. }
    41. }
    To copy to clipboard, switch view to plain text mode 
    Have a look at my code, even though I have used setHeaderData for Size, Type and Date Modified, it gets displayed when run the application but when i click any drive, only File Name appears and rest doesn't get displayed. I am using QTreeView, as of now my code displays all the .mp3 files under Name category. I want to display the Size, Date Modified, Type etc details too. Here is sample pic:
    File.JPG
    How to achieve it?
    Last edited by owais_blore; 22nd November 2012 at 12:28.

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


Similar Threads

  1. Replies: 0
    Last Post: 20th November 2012, 10:05
  2. play audio file
    By hema in forum Qt Quick
    Replies: 1
    Last Post: 11th August 2011, 05:27
  3. Replies: 0
    Last Post: 1st July 2010, 04:21
  4. Replies: 1
    Last Post: 11th November 2009, 17:28
  5. Updating File attributes and it's summary details
    By senthilsp in forum Qt Programming
    Replies: 1
    Last Post: 11th November 2009, 13:31

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.