Results 1 to 2 of 2

Thread: qtableview - selected row after add new row

  1. #1
    Join Date
    May 2013
    Posts
    45
    Thanks
    11
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default qtableview - selected row after add new row

    Hi.
    I have QTableView with QAbstractTableModel and QSortFilterProxyModel for my custom sorting.

    But when i am added row before selected row, selection on table is wrong. (before update is selected row 10, i add row at position 5, and selected row is still 10, but i need 11) When i am added row after selected row, all is OK.

    How can i fix it?

  2. #2
    Join Date
    Mar 2010
    Location
    Heredia, Costa Rica
    Posts
    253
    Thanks
    23
    Thanked 16 Times in 13 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: qtableview - selected row after add new row

    I reckon the issue is with the sorting. You can use the sorting QSortFilterProxyModel to map a sort index to the index of the model. See:

    mapSelectionFromSource(const QItemSelection &sourceSelection) const
    mapSelectionToSource(const QItemSelection &proxySelection) const

Similar Threads

  1. QTableView, selected row?
    By postb99 in forum Newbie
    Replies: 1
    Last Post: 25th February 2014, 14:57
  2. QTableView get selected row
    By raphaelf in forum Qt Programming
    Replies: 8
    Last Post: 12th July 2013, 03:35
  3. Replies: 6
    Last Post: 25th September 2012, 23:41
  4. QTableView selected a full row
    By pmjz in forum Qt Programming
    Replies: 0
    Last Post: 28th October 2011, 00:22
  5. Replies: 1
    Last Post: 4th March 2011, 09:19

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.