PDA

View Full Version : Adding a small tree to an existing tree in QTreeview.



salcin
25th September 2013, 17:27
Hi,

I'm trying to drag an item from a listview to a qtreeview. When I drop the item on a node it shall create a new entry with two children. I get the drop event but I'm not sure when
beginInsertRows(parent, first, last ) and endInsertRows(); shall be called.

The underlaying data structure is a tree.

I have this:
Root
->Node1
-->Child1:1
-->Child1:2
->Node2
-->Child2:1
-->Child2:2


When I drop a new item on the Root I want to get:
Root
->Node1
-->Child1:1
-->Child1:2
->Node2
-->Child2:1
-->Child2:2
->Node3
-->Child3:1
-->Child3:2

Should I call beginInsertRows(parent, first, last ) one time
where parent = root
first = 2
last = 2
Or do I need to call beginInsertRows(parent, first, last ) for the two children too?

After every beginInsertRows(parent, first, last ) I will call endInsertRows().

Thank you!