My code below will display the whole file system. I just want to display a subfolder (ex D:\folder1), with all it's contents.
I tried setting the root index of the treeView but this will hide the folder (only the contents of the folder1 will be shown).
I also tried using "setFilterRegExp()" and "setFilterKeyColumn()", but this approach will also NOT work because it will filter the parents as well.
I also tried subclassing the QSortFilterProxy" but that seems a little too much for what I'm trying to achieve.
Is there an easier method here?
int main(int argc, char *argv[])
{
proxyModel->setSourceModel(model);
leftTree->setModel(proxyModel);
splitter->show();
return a.exec();
}
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QDirModel *model = new QDirModel();
QSplitter *splitter = new QSplitter();
QTreeView *leftTree = new QTreeView(splitter);
QSortFilterProxyModel *proxyModel = new QSortFilterProxyModel();
proxyModel->setSourceModel(model);
leftTree->setModel(proxyModel);
splitter->show();
return a.exec();
}
To copy to clipboard, switch view to plain text mode
Bookmarks