delete QListWidgetItem in QListWidget
Hi:
I have add some QListWidgetItem into a QListWidget through the following codes, and the QListWidgetItem contains both QIcon and QSrting like this:
Code:
ui
->listWidget
->setIconSize
(QSize(40,
40));
//设置图标大小
But when I delete the QListWidgetItem in the QListWidget, I only know the QString of the QListWidgetItem to be deleted, and I use the following:
Code:
QListIterator<QListWidgetItem
*> i
(ui
->listWidget
->findItems
(QString("something"), Qt
::MatchCaseSensitive));
while(i.hasNext())
{
// QListWidgetItem *temp = i.next();
ui->listWidget->removeItemWidget(i.next());
// delete temp;
}
unfortunately I failed.
Do some guys know how to delete them?
Thanks!
Re: delete QListWidgetItem in QListWidget
I answer myself in case someone run into the same question.
well, I have made a mistake. I should use the condes which are commented to delete, and they work well.