AngryDuck
AngryDuck

Reputation: 4607

Deselect a single row in QTableView

I am implementing an invert selection function where I get the selected items, select everything, and then I want to iterate over the list of selected items to deselect them.

QModelIndexList indexs = this->selectedIndexes();
this->selectAll();
foreach(QModelIndex index, indexs)
{
   // Deselect row at index....
}

Upvotes: 4

Views: 7981

Answers (1)

ratchet freak
ratchet freak

Reputation: 48186

You can access the selectionModel and call select(index, QItemSelectionModel::Deselect) on it. You can also loop over all indices and call toggle.

Upvotes: 12

Related Questions