Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deselect a single row in QTableView

Tags:

c++

qt

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....
}
like image 906
AngryDuck Avatar asked Oct 26 '25 14:10

AngryDuck


1 Answers

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

like image 167
ratchet freak Avatar answered Oct 29 '25 06:10

ratchet freak



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!