How can I clear a QListWidget without deleting all the QListItemWidgets it contains?

QListWidget has a member named clear (). Documents for this method:

void QListWidget::clear () [slot] Removes all items and selections in the view. Warning: All items will be permanently deleted. 

How can I avoid all deleted items? I just want to clear the contents of the lists so that I can re-populate it with different data (however, I want the data that was in it to be displayed again if the user wants it).

+4
source share
1 answer

QListWidget :: takeItem

 while(listwidget->count()>0) { listwidget->takeItem(0);//handle the item if you don't //have a pointer to it elsewhere } 
+9
source

Source: https://habr.com/ru/post/1400129/


All Articles