PDA

View Full Version : QSortFilterProxyModel vs setRootIndex()



migel
18th July 2012, 20:59
Hi

I have a custom model and use QSortFilterProxyModel for filtering. Problem is when I setRootIndex() for one of the child index for the view and use the filtering. It filters all items in the model and not up to that index previously set in rootIndex(), also when I take my filtering out, it displays all items in the view and not children of index set to the root any more.

Is it normal behave or I do something strange ?

Thanks

migel
19th July 2012, 14:44
What I found out that I need to do it manually unfortunately. So I hooked up to QSortFilterProxyModel and check if current filtering index is below the parent set in setRootIndex.

Unfortunately all my tries failed.

In filterAcceptsRow ( int sourceRow, const QModelIndex & sourceParent ) function I do

bool CustomProxyl::allowIndex(const QModelIndex &index) const
{
if ( index < mapToSource( _rootIndex ) )
return true;

return false;
}

Which should show some progress. I have tried also check by recursive if some of the top parent indexes are my rootIndex. Nada.

Any clues ?

wysota
20th July 2012, 19:43
Could you explain more what the problem is about?