Results 1 to 2 of 2

Thread: Checking if a row in a tableview is filtered when using a QSortFilterProxyModel

  1. #1
    Join Date
    May 2011
    Posts
    20
    Thanked 3 Times in 3 Posts
    Platforms
    Unix/X11

    Default Checking if a row in a tableview is filtered when using a QSortFilterProxyModel

    I have a tableview that uses a QSortFilterProxyModel. If I call tableView.isRowHidden() on a row that was filtered it will return false. I would have expected it to return true since the row is hidden. I could not find a isRowFiltered() function anywhere. How can I tell if a row is filtered within my table?

  2. #2
    Join Date
    Feb 2008
    Posts
    491
    Thanks
    12
    Thanked 142 Times in 135 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: Checking if a row in a tableview is filtered when using a QSortFilterProxyModel

    You're confusing a function of the view (hiding rows) with a function of the model (filtering).

    A filtered out row isn't hidden in the view, it will not exist in your proxy model.

    From the QSortFilterProxyModel docs:
    The model transforms the structure of a source model by mapping the model indexes it supplies to new indexes, corresponding to different locations, for views to use.
    You can check whether a row is filtered or not by using QSortFilterProxyModel::mapFromSource().
    Qt Code:
    1. if(!mapFromSource(sourceModel()->index("source model row",0)).isValid()) //source model row is filtered;
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Filter a Filtered QSortFilterProxyModel !?
    By solook in forum Qt Programming
    Replies: 4
    Last Post: 25th October 2011, 20:22
  2. Replies: 0
    Last Post: 8th March 2011, 13:58
  3. WM_INPUT not being filtered by winEventFilter()
    By been_1990 in forum Qt Programming
    Replies: 1
    Last Post: 12th October 2010, 04:19
  4. Replies: 1
    Last Post: 7th February 2010, 09:01
  5. Replies: 4
    Last Post: 20th September 2007, 14:11

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.