سؤال

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....
}
هل كانت مفيدة؟

المحلول

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

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top