QListWidget has a member named clear(). The docs for this method state:
void QListWidget::clear () [slot]
Removes all items and selections in the view.
Warning: All items will be permanently deleted.
How can I avoid all of the items being permanently deleted? I just want to clear the lists contents so that I can re-populate it with different data (however, I want to keep the data that was in it to display again if the user chooses to do so).
QListWidget::takeItem
while(listwidget->count()>0)
{
listwidget->takeItem(0);//handle the item if you don't
//have a pointer to it elsewhere
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With