View Full Version : QTableView problem - selecting multiple items
junhonguk
18th July 2012, 13:05
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.
aamer4yu
18th July 2012, 14:01
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 ?
junhonguk
18th July 2012, 14:16
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:
connect(entityTableView->selectionModel(),SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)), this,
SLOT(selectionChangedSlot(const QItemSelection &, const QItemSelection &)));
For the slot:
void Scope::selectionChangedSlot(const QItemSelection &selected, const QItemSelection &deselected)
{
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.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.