
Originally Posted by
Alina
I have a treewidget in a dock window . i want to know how can i delete the activated treewidgetitem,and then show the new treewidget in dock?
//TIP: Following code is only fabricated by looking at the docs, i have not tested it.
if(treeWidget->currentItem() && !treeWidget->currentItem()->parent()){
delete treeWidget->takeTopLevelItem(treeWidget->indexOfTopLevelItem(treeWidget->currentItem()));
}else if(treeWidget->currentItem() && treeWidget->currentItem()->parent()){
delete treeWidget->currentItem()->parent()->takeChild(treeWidget->currentItem()->parent()->indexOfChild(treeWidget->currentItem());
}
//TIP: Following code is only fabricated by looking at the docs, i have not tested it.
if(treeWidget->currentItem() && !treeWidget->currentItem()->parent()){
delete treeWidget->takeTopLevelItem(treeWidget->indexOfTopLevelItem(treeWidget->currentItem()));
}else if(treeWidget->currentItem() && treeWidget->currentItem()->parent()){
delete treeWidget->currentItem()->parent()->takeChild(treeWidget->currentItem()->parent()->indexOfChild(treeWidget->currentItem());
}
To copy to clipboard, switch view to plain text mode
One this is done, QTreeWidget should update it accordingly.
Hope this works
Bookmarks