Hi:
I have add some QListWidgetItem into a QListWidget through the following codes, and the QListWidgetItem contains both QIcon and QSrting like this:
ui
->listWidget
->setIconSize
(QSize(40,
40));
//设置图标大小
ui->listWidget->addItem(new QListWidgetItem(icon, fileInfo.baseName()));
ui->listWidget->setIconSize(QSize(40, 40)); //设置图标大小
To copy to clipboard, switch view to plain text mode
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:
QListIterator<QListWidgetItem
*> i
(ui
->listWidget
->findItems
(QString("something"), Qt
::MatchCaseSensitive));
while(i.hasNext())
{
// QListWidgetItem *temp = i.next();
ui->listWidget->removeItemWidget(i.next());
// delete temp;
}
QListIterator<QListWidgetItem*> i(ui->listWidget->findItems(QString("something"), Qt::MatchCaseSensitive));
while(i.hasNext())
{
// QListWidgetItem *temp = i.next();
ui->listWidget->removeItemWidget(i.next());
// delete temp;
}
To copy to clipboard, switch view to plain text mode
unfortunately I failed.
Do some guys know how to delete them?
Thanks!
Bookmarks