PDA

View Full Version : Not able to remove the root of the tree widget.



aurora
30th December 2011, 06:42
hi all,
i added root tree widget item dynamically,
when i tried to access, i can its name but when i tried to remove that root with specified name, the effect was not reflecting in window...
Please tell me what i'm missing here...


void MainWindow::RemoveTreeRoot(QString Filename)
{

QList<QTreeWidgetItem *>TempRoot=ui->treeWidget_FilesSelected->findItems(Filename,Qt::MatchExactly,0);
foreach (QTreeWidgetItem *temp,TempRoot)
{
cout<<"ITS FOUND!!!!!!!!!!!!!!!!"<<endl;
std::cout<<"remove:"<<temp->text(0).toStdString()<<endl; ///PRINTING CORRECT NODE NAME....
ui->treeWidget_FilesSelected->removeItemWidget(temp,0); // <----This effect not reflecting in mainwindow while executing

}
}

amleto
30th December 2011, 14:04
removeitemwidget only removes the widget, not the node in the tree, according to the docs.

http://developer.qt.nokia.com/doc/qt-4.8/qtreewidget.html#setItemWidget
http://developer.qt.nokia.com/doc/qt-4.8/qtreewidget.html#removeItemWidget