Results 1 to 4 of 4

Thread: Showing selected rows in a separate table

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Showing selected rows in a separate table

    One option could be to wrap the QItemSelectionModel into a QAbstractListModel. This way the model would operate on the selected indexes only (whereas the proxy operates on the whole source model).
    J-P Nurmi

  2. #2
    Join Date
    Oct 2006
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Showing selected rows in a separate table

    Thanks a lot for your hint! Here is what I did, I created a class ProxyModel which extends QAbstractListModel and takes the source model and the item selection model as arguments. The proxy model contains the list of selected indexes from the source model. I connect the QItemSelectionModel::selectionChanged signal to a slot which updates the Proxy Model, ie. removes the indexes which were diselected and appends indexes which were selected. I also overwrite the data() method in the Proxy Model so that it returns data from the source model.

    You can find a working implementation attached, there might be some additional checkings/optimizations to be done, but it shows the idea. Comments are welcome.
    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
  •  
Qt is a trademark of The Qt Company.