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.
pSystemPrimaryModel = new QFileSystemModel(this);
pSystemPrimaryModel
->setRootPath
(QDir::currentPath());
pSystemPrimaryModel
->setFilter
( QDir::AllDirs |
QDir::NoDotAndDotDot );
QList<QStandardItem *> LocalItem;
LocalItem.at(0)->setEditable(false);
m_model->insertRow(0,LocalItem);
LocalparentItem->appendRow(Localchild);
ui->PrimTreeView->setModel(m_model);
QStandardItemModel *m_model = new QStandardItemModel(0,0);
pSystemPrimaryModel = new QFileSystemModel(this);
pSystemPrimaryModel->setRootPath(QDir::currentPath());
pSystemPrimaryModel->setFilter( QDir::AllDirs | QDir::NoDotAndDotDot );
QList<QStandardItem *> LocalItem;
LocalItem.insert(0,new QStandardItem("Local Drives"));
LocalItem.at(0)->setEditable(false);
m_model->insertRow(0,LocalItem);
QStandardItem* Localchild = new QStandardItem();
QStandardItem* LocalparentItem = m_model->item(0,0);
LocalparentItem->appendRow(Localchild);
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:
pSystemPrimaryModel = new QFileSystemModel(this);
pSystemPrimaryModel
->setRootPath
(QDir::currentPath());
ui->PrimTreeView->setModel(pSystemPrimaryModel);
pSystemPrimaryModel = new QFileSystemModel(this);
pSystemPrimaryModel->setRootPath(QDir::currentPath());
ui->PrimTreeView->setModel(pSystemPrimaryModel);
To copy to clipboard, switch view to plain text mode
Bookmarks