Prevent Destruction of QList<QTreeWidgetItem *>
-
I'm creating a
QList<QTreeWidgetItem *>which holds an INI-backed list of virtual files and folders specified by the end user.The problem is that because the items from the
QListare associated with aQTreeWidgetwhen presented to the user, they are also destroyed when theQTreeWidgetis destroyed.Is there any way I can stop this happening?
I have looked into using a
QTreeViewbut the implementation seems to be pretty horrible and would prefer using theQTreeWidgetif it is possible. -
I'm creating a
QList<QTreeWidgetItem *>which holds an INI-backed list of virtual files and folders specified by the end user.The problem is that because the items from the
QListare associated with aQTreeWidgetwhen presented to the user, they are also destroyed when theQTreeWidgetis destroyed.Is there any way I can stop this happening?
I have looked into using a
QTreeViewbut the implementation seems to be pretty horrible and would prefer using theQTreeWidgetif it is possible.@webzoid
in the destructor of your QTreeWidget call takeChildren that should take all items from the widget and return it as a list.
You can ignore the returned list, as you have one in memory already.This is untested, I'm not 100% sure the TreeWidget won't still delete the items.