PDA

View Full Version : Why is QListView::setRootIndex() necessary when working with Dir's?



ayanda83
11th November 2016, 08:00
I created a post about a week ago and my problem was not resolved. I am pretty sure my problem will be resolved if I could only understand why QListView::setRootIndex() is necessary when working with Dir's. I've used a QListView before and I've never had to use this function but now that I am displaying Dir files on a QListView, I now have to use this function. The problem I have is that I have a QSortFilterProxyModel which I am using to search for certain files in the Dir, but because the view is linked to the underlying model (i.e. QFileSystemModel) through setRootIndex(), my program crashes everytime I try to search for certain files. Is there a way of mapping the root index of the QSortFilterProxyModel to the QListView because that would be my solution to the problem. My code is on my post from last week here (http://www.qtcentre.org/threads/67236-QSortFilterPoxyModel-not-filtering)

anda_skoa
11th November 2016, 18:29
setRootIndex() has nothing to do with QDir, it is needed to select which node if a tree model to consider as the "root" for which to display the list.

I.e. QListView can only show a list, if you pass a tree model, you can specify which node in the tree is the one you want listed.

Cheers,
_