QTableView problem - selecting multiple items
I have set up a QAbstractItemModel for a QTableView.
Also implemented a selectionChanged signal for selecting multiple rows in QTableView.
However, when I select more than one items in the QTableView, I found only the last item has been identified by the QModelIndexList (selected.indexes()).
Anyone has any advice.
I am grateful for your comment and suggestions.
Re: QTableView problem - selecting multiple items
What did you do in selectionChanged slot ? Its a virtual slot, and what changes have you done to it ?
Also have you tried setting the selection mode to multi selection ?
Re: QTableView problem - selecting multiple items
Do you mean selectionChanged signal? I made a customised slot to be invoked by the selectionChanged signal.
Yes, I have set the selection mode of the QTableView as QAbstractItemView::ExtendedSelection.
Added after 6 minutes:
For the connection:
For the slot:
Code:
{
int selectedItems = 0;
QModelIndexList items = selected.indexes();
selectedItems = selected.indexes().size();
...
}
Everytime, the selectedItems is equal to 1 not the number that I have selected.