When I am to clear the QListWiget variant listWidget, a rather strange bugs occur.
first of all, I used the clear() method of QListWidget, it failed.
listWidget->clear();
then, I tried the takeItem() way, it failed again.
for (int i = 0; i < listWidget->count(); i++)
{
QListWidgetItem *item = listWidget->takeItem(0);
delete item;
}
after debugging step by step, I found that, the removing process goes well until it comes to the last item case. the QListWidgetItem *item = listWidget->takeItem(0); sentence failed with the accessing bugs.
Bookmarks