Proper way to remove items from a QListWidget[Solved]
General and Desktop
13
Posts
6
Posters
15.8k
Views
1
Watching
-
No, your usage is still wrong.
You should always remove the second item, until there is no second item any more, which mean you have only one item now!
or you should remove your item from the last to the second item.
-
To add to 1+1=2, your list size still changes, so your counter is going to grow past the size of your list
-
It's explained in the "documentation":http://qt-project.org/doc/qt-4.8/qlistwidget.html#takeItem
-
Rather
@
while (!mListWidget.isEmpty()) {
QListWidgetItem *item ' mListWidget->takeItem();
delete item;
}
@