0

QTableWidget is model-less, and I run into similar situations to this question, there is no functions to erase multiple rows simultaneously, only a:

void QTableWidget::removeRow ( int row )

And there's no persistent index I think, what to do now?

Community
  • 1
  • 1
daisy
  • 22,498
  • 29
  • 129
  • 265

1 Answers1

0

You should get a list of selected items and then iterate through each of them and delete the pointer to each item. For example:

foreach(QTableWidgetItem * item, tableWidget.selectedItems())
{
    delete item;
}

It's safe to delete the pointer directly as I've used this method to delete similar items from QTreeWidgets and QListWidgets.

Hope this helps.

Cameron Tinker
  • 9,634
  • 10
  • 46
  • 85