Hi,
I hope something like this will work:
bool bDeletion = true;
while (bDeletion)
{
//Search element to delete. We have to get the number of elements every start of searching
int i=0;
bool bFound = false;
int iNumElements = m_qListWidget.count();
while (!bFound && (i<iNumElements))
{
if (m_qListWidget.at(i)->elementHasToBeDeleted()) //Implement your method
bFound = true; // "i" points to element to delete
else
i++; //Jump to next element
}
//If we have found one element to delete, just delete it
if (bFound)
delete m_qListWidget.takeAt(i);
//If we have not found any element to delete just exit the loop (job finished)
else
bDeletion = false;
}
bool bDeletion = true;
while (bDeletion)
{
//Search element to delete. We have to get the number of elements every start of searching
int i=0;
bool bFound = false;
int iNumElements = m_qListWidget.count();
while (!bFound && (i<iNumElements))
{
if (m_qListWidget.at(i)->elementHasToBeDeleted()) //Implement your method
bFound = true; // "i" points to element to delete
else
i++; //Jump to next element
}
//If we have found one element to delete, just delete it
if (bFound)
delete m_qListWidget.takeAt(i);
//If we have not found any element to delete just exit the loop (job finished)
else
bDeletion = false;
}
To copy to clipboard, switch view to plain text mode
As I supose that no many items are there on the list, the search of an item to be deleted starts every time from item 0. You could save the deletion position and start the search againg from this value but you have to get the number of items again and check that it is not out of bounds.
Bookmarks