View Full Version : treeview show dirs and tableview show files with one filesystemmodel?
qt_gotcha
3rd July 2010, 11:02
playing with this example.
ttp://doc.qt.nokia.com/4.6/model-view-using.html
how can I make the treview display only directories and the table view only files? If I change something in the model with setfilter, both react to it.
thanks
qt_gotcha
3rd July 2010, 11:11
sorry, I mean there is something like QSortFilterProxyModel but that does not have the convenient setFilter for dirs, files etc.
qt_gotcha
12th July 2010, 07:06
ok found it for those who are interested:
I use two models, one for the treeview (QDirModel) and one for the tableview (QFileSystemModel)
then when the directory is changed in the treeview, I set the setRootPath of the QFileSystemModel
...
QModelIndex dir = index.sibling(index.row(), 0);
if (dir != fileView->rootIndex() && dirModel->isDir(dir))
{
currentPath = dirModel->filePath(dir);
treeView->setCurrentIndex(index);
fileModel->setRootPath(currentPath);
fileView->setRootIndex(fileModel->index(currentPath));
}
franz
12th July 2010, 13:12
You could of course subclass the QSortFilterProxyModel as well...
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.