PDA

View Full Version : How can I delete several rows from QTableWidget at the same time?



ricardo
12th May 2009, 22:44
Hi dudes!


I have a QTableWidget, and using:
QList<QTableWidgetSelectionRange> ranges=ui.tableWidgetTextureLibrary->selectedRanges();

I know what rows are selected (indexes), but obviusly I can't do
ui.tableWidgetTextureLibrary->removeRow(row);

Because once I do it, my rows to delete list, is not valid.

Does anyone have any suggestion?

I guess I colud do something using an auxiliar struct... But must be an easier way.

Thanks for help.

wysota
13th May 2009, 00:25
You can start deleting from the last row. In that case the indexes will stay valid.

Or you can probably just delete the items returned by QTableWidget::selectedItems() using qDeleteAll().

ricardo
13th May 2009, 10:35
Used sorted version and evidently worked.

I don't know why I didn't have that idea.

Thanks a lot for your help.