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. How to display Details of Audio File in QTreeView
Forum Updated to NodeBB v4.3 + New Features

How to display Details of Audio File in QTreeView

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 869 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 need to display details of all .mp3 files present in my drives. I am using QTreeView to display. Here is the code:
    @ // Displays Files in Detail View on Clicking Drive
    void DetailView::on_DriveView_clicked(const QModelIndex &index)
    {
    int m_count=0;
    QStandardItemModel *model = new QStandardItemModel(0,0);
    QString sPath = m_SystemModel->fileInfo(index).absoluteFilePath();
    m_SystemListViewModel->setRootPath(sPath);
    ui->DriveListView->setRootIndex(m_SystemListViewModel->index(sPath));

    m_SystemModel->setRootPath(QDir::currentPath());
    m_SystemModel->setFilter(QDir::NoDotAndDotDot | QDir::AllDirs );
    m_SystemListViewModel->setFilter( QDir::Files | QDir::NoDotAndDotDot );
     
    QStringList m_list;
    QDirIterator dirIt(sPath,QDirIterator::Subdirectories);
     
    while (dirIt.hasNext())
    {
    dirIt.next();
    if (QFileInfo(dirIt.filePath()).isFile())
    {
    if (QFileInfo(dirIt.filePath()).suffix() == "mp3" || QFileInfo(dirIt.filePath()).suffix() == ".avi")
    {
    m_list << dirIt.filePath();
     
    QModelIndex index = model->index(m_count, 0, QModelIndex());
    model->setHeaderData( 0, Qt::Horizontal, "File Name" );
    model->setHeaderData( 1, Qt::Horizontal, "Size" );
    model->setHeaderData( 2, Qt::Horizontal, "Type" );
    model->setHeaderData( 3, Qt::Horizontal, "Date Modified" );
     
    model->setData( index, dirIt.fileName(), Qt::DecorationRole );
    QStandardItem *item = new QStandardItem(dirIt.fileName());
    model->setItem(m_count, item);
     
    ui->DriveListView->setModel(model);
    m_count++;
    }
    }
    m_SystemListViewModel->setNameFilterDisables(false);
    }
    }@
    

    Even though I have used setHeaderData for Size, Type and Date Modified.... it doesnt 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.

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