PDA

View Full Version : How to set parent of a QTreeWidgetItem



Seishin
7th December 2012, 21:55
Hi,

I'm using QTreeWidget to implement a tree like

root
/ \
a b
| /\
d e f

I want to reset the parent of "e" to "a", like e->setParent(a);
But I cannot find any function in QTreeWidgetItem to change the parent.
I 'm not using drag and drop. Is there a way to do it without using model and view?
Thanks in advance.

wysota
7th December 2012, 22:06
Call addChild() on the new parent item passing the "e" item as the argument.

Seishin
7th December 2012, 22:30
Thanks for the quick reply. I was focus on searching "changing parent" and missed "child".