QTreeModel->setRootIndex when using QSortFilterProxyModel segfaults
So this works when I don't use a QSortFilterProxyModel but when I make QTreeView use a QSortFilterProxyModel, the compiled code seg faults...
Code:
proxyDirModel->setSourceModel(dirModel);
treeView->setModel(proxyDirModel);
// I have tried it both of these ways:
treeView->setRootIndex(dirModel->index("/"));
//treeView->setRootIndex(treeProxyModel->sourceModel()->index("/"));
How can I make this work? Right now it seems like having two QDirModels works without problems when I use one dirmodel and try to do this the right way I run into lots of problems and not a lot of good documentation...:eek:
Re: QTreeModel->setRootIndex when using QSortFilterProxyModel segfaults
Which Qt version do you use?
Re: QTreeModel->setRootIndex when using QSortFilterProxyModel segfaults
Upgraded to 4.4.1 a few days back...
Re: QTreeModel->setRootIndex when using QSortFilterProxyModel segfaults
Quote:
Originally Posted by
killerwookie99
treeView->setModel(proxyDirModel);
// I have tried it both of these ways:
treeView->setRootIndex(dirModel->index("/"));
//treeView->setRootIndex(treeProxyModel->sourceModel()->index("/"));
You can't give dirModel's indices to the treeView, because it operates on treeProxyModel.
Use:
Code:
QModelIndex idx
= treeProxyModel
->mapFromSource
( dirModel
->index
("/") );
treeView->setRootIndex( idx );
Re: QTreeModel->setRootIndex when using QSortFilterProxyModel segfaults