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
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
To copy to clipboard, switch view to plain text mode
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
Any help would be appreciated.
Bookmarks