Question

This seems like it should be really easy. Basically I am implementing an invert selection function.

I am getting the selected items, then selecting everything and i want to iterate over the list of selected items and deselect them. If this isn't the best way of doing it i am open to ideas but what I'd like to know is how to deselect a specific row

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

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top