1 Attachment(s)
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.
Code:
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);
This displays output with only Local Drives and no drives under it since I am not setting pSystemPrimaryModel in setModel.
Attachment 8483
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:
Code:
pSystemPrimaryModel = new QFileSystemModel(this);
pSystemPrimaryModel
->setRootPath
(QDir::currentPath());
ui->PrimTreeView->setModel(pSystemPrimaryModel);
Re: Display Filesystem Using QFileSystemModel & QStandardItemModel
Anyone here who can help me???
Re: Display Filesystem Using QFileSystemModel & QStandardItemModel
And what is the question?
Re: Display Filesystem Using QFileSystemModel & QStandardItemModel
If I'm right you want to combine QFileSystemModel and QStandardItemModel in one model and then display it in a treeview?
Then I'd sugegst using a QAbstractProxyModel, wysota correct me if I'm wrong, haven't dealt with that so much:)
Re: Display Filesystem Using QFileSystemModel & QStandardItemModel
Quote:
Originally Posted by
airglide
Then I'd sugegst using a QAbstractProxyModel, wysota correct me if I'm wrong, haven't dealt with that so much:)
Hard to say. I'm wondering if it's not going to be easier to create a new model from scratch. The problem with proxy models is that it is quite hard to implement a hierarchical proxy model if one is not used to the technology.
Re: Display Filesystem Using QFileSystemModel & QStandardItemModel
Then which is a better approach??? I tried a lot and everytime it seems to just give the same result. I googled a lot and i am surprised nobody has come across this scenario..... what has to be done?
Quote:
Originally Posted by
wysota
Hard to say. I'm wondering if it's not going to be easier to create a new model from scratch. The problem with proxy models is that it is quite hard to implement a hierarchical proxy model if one is not used to the technology.
Re: Display Filesystem Using QFileSystemModel & QStandardItemModel
Quote:
Originally Posted by
owais_blore
Then which is a better approach??? I tried a lot and everytime it seems to just give the same result. I googled a lot and i am surprised nobody has come across this scenario..... what has to be done?
To be honest we have no idea what you tried. I'm almost sure there is no "how to add another level of nodes to the filesystem model" tutorial available so you have to go past tutorials and do some thinking of your own. I would probably try some combined approach like having a custom model for the top nodes and attaching filesystem models for the nodes I need. But then I have some quite deep knowledge of how models work in Qt. I think building a model from scratch that is dynamically filled with data using canFetchMore() is also an option. But again this requires something more than just reading one or two tutorials.