Results 1 to 4 of 4

Thread: Showing selected rows in a separate table

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2006
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Showing selected rows in a separate table

    Hi,

    I would like to have 2 separate tables, one showing all the items, and the other one the current selection of the original items.

    My current solution is as follows; I create a proxy of the original model, to which I also pass its item selection model. I overwrite the QSortFilterProxyModel::filterAcceptRow() function, and return true only if the row is selected. In order to ensure that the second table is updated each time that the selection is changed, I connect the signal selectionChanged which calles a wrapper slot that just invokes QSortFilterProxyModel::filterChanged(). I attach the minimal code that implements what I described above and a screenshot showing the desired behavior.

    Although it works, I don't like this solution for the following reasons:
    1) filterAcceptRow uses the info from the selection model and not from the source model to decide whether a row should be filtered or not, which may not be the neatest solution
    2) filterChanged() exists only from Qt4.2 and I need my application to be compatible with Qt4.1 too
    3) if I understand well, filterChanged() recalculates accepted rows for all the indexes of the source models, and not only the ones which were removed from/added to a selection. Given that I can have tens of thousands of rows in the original model, this does not look like an optimal solution.

    Does anyone have a better idea of implementing such functionality?
    Attached Images Attached Images
    Attached Files Attached Files

Similar Threads

  1. Remove selected rows from a QTableView
    By niko in forum Qt Programming
    Replies: 4
    Last Post: 3rd March 2016, 12:49
  2. Adding row in a Table after selected row
    By ankurjain in forum Qt Programming
    Replies: 3
    Last Post: 20th April 2006, 18: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.