I am using Qt 4.1, and my application works with qtreewidget. It crashes when I am destroying items from tree ( executing this code):

void Search:eleteItem(QTreeWidgetItem *item)
{
if (!item) return;

for(int i=item->childCount(); i>0; i--) {
DeleteItem(item->child(i));
}
delete item;
}

This piece of code is meant to delete all items from qtreewidget. I am calling this method number of times equal to number of top level items. Any advice? Is there any better way to delete qtreewidgetitems from qtreewidget?

Any idea's are apreciated, I am complete newbie with Qt....