Results 1 to 2 of 2

Thread: QSortFilterProxyModel mapping

  1. #1
    Join Date
    Apr 2008
    Posts
    17
    Thanks
    4

    Default QSortFilterProxyModel mapping

    Hi All,

    I have an issue, and maybe you can suggest me a workaround. I have implemented a QAbstractItemModel that can have a huge amount of rows (several thousands) that are fetching from database on demand. I subclass QSortFilterProxyModel, to give dynamic filters. All data is show on QTableView. I'm using Qt 4.7.3.

    Suppose this sequence: I set the model for QTableView to be QSortFilterProxyModel. QTableView is then show to user. Internally, QTableView on paintEvent, has a call to QSortFilterProxyModel::index(row, column, parent) that, internally, has a call to d->create_mapping (Qt sources), that force QSortFilterProxyModel to fetch all rows calling to filterAcceptsRow.

    It is supossed that QTableView only needs to call to QSortFilterProxyModel to get the visible rows using, rowCount from QSortFilterProxyModel, but "index" on QSortFilterProxyModel is fetching all rows... Is there any solution to that? Maybe am I using a wrong idea? The only solution I see is reimplement all QSortFilterProxyModel with my own mapping source-proxy.

    Thanks a lot!!!

  2. #2
    Join Date
    Apr 2008
    Posts
    17
    Thanks
    4

    Default Re: QSortFilterProxyModel mapping

    Reply myself: The key is to have a very good accept row rule. In my case, I modified the QSortFilterProxyModel to count the row using an appropiate sql query. I put a fetched mark to the row that I read from database on source model. On filterAccepsRow all the rows that wasn't fetched, are accepted, and the filter is only applied to fetched row: because this row was requested by the widgets to be shown to user.

    It is hard to explain, but you must be very careful with filter on a large amount of rows.

Similar Threads

  1. Mapping between two comboboxes
    By codeman in forum Qt Programming
    Replies: 1
    Last Post: 28th December 2009, 17:32
  2. Mapping Question
    By rogerholmes in forum Qt Programming
    Replies: 0
    Last Post: 26th April 2009, 00:29
  3. Mapping QGraphicsItem objects
    By ashukla in forum Qt Programming
    Replies: 4
    Last Post: 4th February 2008, 14:47
  4. mapping manager
    By sreedhar in forum Qt Programming
    Replies: 6
    Last Post: 16th February 2007, 13:48

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.