QTableView - Current index not correct for contiguous selection with mouse



  • I am using a QTableView with contiguous selection mode.

    When selecting multiple cells with the mouse, the current index returned by currentIndex() from a slot connected to the selectionChanged signal is always one cell prior to actual current cell (i.e. the cell with the focus rectangle).

    E.g. If the first two cells in the top row are selected (from right to left) with the mouse, currentIndex() will contain (0,0) as the current index, while the actual position (cell with focus rect) is (0,1).

    When using the keyboard to make the selection, the return from currentIndex() is correct.

    Is there a way to get the correct current index using the selectionChanged signal for a selection generated by the mouse?



  • does selectionModel().selectedIndexes() return the correct indexes?
    Are you using a proxy model?



  • Yes, selectionModel().selectedIndexes() returns the correct indexes. I am using a QStandardItemModel.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.