Results 1 to 7 of 7

Thread: Display Filesystem Using QFileSystemModel & QStandardItemModel

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

    Question Display Filesystem Using QFileSystemModel & QStandardItemModel

    I had asked the question about displaying Filesystem inside a treeview in such a way where local drives and removable drive get displayed under a root node - Local Drivess & Removable Drives.
    Qt Code:
    1. pSystemPrimaryModel = new QFileSystemModel(this);
    2. pSystemPrimaryModel->setRootPath(QDir::currentPath());
    3. pSystemPrimaryModel->setFilter( QDir::AllDirs | QDir::NoDotAndDotDot );
    4.  
    5. QList<QStandardItem *> LocalItem;
    6. LocalItem.insert(0,new QStandardItem("Local Drives"));
    7. LocalItem.at(0)->setEditable(false);
    8. m_model->insertRow(0,LocalItem);
    9.  
    10. QStandardItem* Localchild = new QStandardItem();
    11. QStandardItem* LocalparentItem = m_model->item(0,0);
    12. LocalparentItem->appendRow(Localchild);
    13.  
    14. ui->PrimTreeView->setModel(m_model);
    To copy to clipboard, switch view to plain text mode 
    This displays output with only Local Drives and no drives under it since I am not setting pSystemPrimaryModel in setModel.
    untitled.JPG
    I wanna display the drives which are shown towards the bottom side of image under this "Local Drives" node which QFileSystemModel displays when used like this:
    Qt Code:
    1. pSystemPrimaryModel = new QFileSystemModel(this);
    2. pSystemPrimaryModel->setRootPath(QDir::currentPath());
    3. ui->PrimTreeView->setModel(pSystemPrimaryModel);
    To copy to clipboard, switch view to plain text mode 
    Last edited by owais_blore; 7th December 2012 at 12:28.

Similar Threads

  1. Replies: 0
    Last Post: 20th November 2012, 10:05
  2. Replies: 3
    Last Post: 17th August 2010, 17:58
  3. How to display entire directory(Filesystem)
    By deepakn in forum Newbie
    Replies: 11
    Last Post: 10th November 2009, 09:58
  4. gtk not working in qt filesystem
    By apulu in forum Newbie
    Replies: 11
    Last Post: 18th April 2008, 10:22
  5. Display data from QStandardItemModel in QTreeView
    By jprice01801 in forum Qt Programming
    Replies: 7
    Last Post: 10th January 2007, 09:34

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.