[Qt-interest] Deleting the treewidget item
Ferenc Stelcz
ferenc at stelcz.hu
Mon Jun 22 09:39:59 CEST 2009
Ferenc Stelcz wrote:
>
> //This will remove all the children of *item*
> //Be warned, that the child items won't be deleted!
> for(int childcount=0; i<item->childCount(); ++i)
> {
> QTreeWidgetItem *currentChildItem = item->child(i);
> item->removeChild(currentChildItem);
>
> /*
> delete currentChildItem;
> currentChildItem = 0;
> */
> }
>
> //This piece tries to remove *item*
> QTreeWidgetItem *rootItem = item->parent(); //We get the parent of item
> rootItem->removeChild(item); //Then remove item
>
Ok, remembering myself: the quick thought is worth more than the quick move.
use takeChild(int index) or takeChildren() instead of removeChild(int index).
__________ Information from ESET Smart Security, version of virus signature database 4175 (20090621) __________
The message was checked by ESET Smart Security.
http://www.eset.com
More information about the Qt-interest-old
mailing list