Results 1 to 3 of 3

Thread: QSortFilterProxyModel vs setRootIndex()

  1. #1
    Join Date
    Apr 2011
    Posts
    132
    Thanks
    14
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QSortFilterProxyModel vs setRootIndex()

    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

  2. #2
    Join Date
    Apr 2011
    Posts
    132
    Thanks
    14
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QSortFilterProxyModel vs setRootIndex()

    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 ?

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QSortFilterProxyModel vs setRootIndex()

    Could you explain more what the problem is about?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Replies: 8
    Last Post: 26th May 2011, 15:52
  2. QTreeView & setRootIndex
    By Anonymous in forum Qt Programming
    Replies: 1
    Last Post: 11th May 2010, 05:51
  3. Replies: 4
    Last Post: 16th August 2008, 02:42
  4. QTableView row height via delegate and setRootIndex
    By pmaktieh.sirhc in forum Qt Programming
    Replies: 2
    Last Post: 18th January 2007, 19:06

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.