merlvingian
2nd October 2006, 01:22
My question is how do I obtain a childs position index of a TopLevelItem in a QTreeWidget so I can remove it?
I understand how to obtain the index of a toplevelitem and how I can use it to remove the entry from the tree. It also appears I can remove specific children of a toplevelitem by using something like
QList<QTreeWidgetItem *> selected = selectedItems();
QTreeWidgetItem *item = selected.first(); // first and only selected child item
QTreeWidgetItem *parent = item->parent(); // childs parent will always be a toplevelitem
parent->takeChild(**INDEX NEEDED**); // remove the child
There will only be one level of children on any given toplevelitem and it looks at this point I could use the child *item reference and iterate through the toplevelitem children until I find an item match so I can remove it, but this seems like an awkward way to solve the problem.
Is there something I am missing? Is there no way to remove a QTreeWidget item directly using it's QTreeWidgetItem reference? Searched forum and docs and still have not found a solution :confused:
Any help would be appreciated.
I understand how to obtain the index of a toplevelitem and how I can use it to remove the entry from the tree. It also appears I can remove specific children of a toplevelitem by using something like
QList<QTreeWidgetItem *> selected = selectedItems();
QTreeWidgetItem *item = selected.first(); // first and only selected child item
QTreeWidgetItem *parent = item->parent(); // childs parent will always be a toplevelitem
parent->takeChild(**INDEX NEEDED**); // remove the child
There will only be one level of children on any given toplevelitem and it looks at this point I could use the child *item reference and iterate through the toplevelitem children until I find an item match so I can remove it, but this seems like an awkward way to solve the problem.
Is there something I am missing? Is there no way to remove a QTreeWidget item directly using it's QTreeWidgetItem reference? Searched forum and docs and still have not found a solution :confused:
Any help would be appreciated.