0

Is it possible to let QListWidget remove a QListWidgetItem, when the widget (I use setItemWidget()) gets closed()?

For now I pass in the row number and signal back to the main window, which will delete the item by row, but that sounds stupid.

Mat
  • 202,337
  • 40
  • 393
  • 406
daisy
  • 22,498
  • 29
  • 129
  • 265

1 Answers1

0

Do you want delete all items on QListWidget.close()? Let's try this

list = MyListWidget.items();
qDeleteAll(list.begin(), list.end());
list.clear();

in closeEvent(). Must create your own widget from QListWidget to reimplement|use protected methods.

dmr
  • 322
  • 1
  • 11