PDA

View Full Version : How to merge/append a portion of QStandardItemModel list to an existing list item;



startyourengine
13th June 2012, 19:47
hello everyone
i made a model and treeview list according to the model/view tutorial, suppose the list structure is as following(each indent indicates a child level):

item1

a
item2

b

c


d

how can i take item2 as a pointer or whatever and append it item1 as a child, and still the item2 retains all its childrens, so I want to do this:

item1

a

item2


b


c



d

is there a way to do this? thank you.

wysota
13th June 2012, 20:26
QStandardItemModel::takeItem(), QStandardItemModel::insertRow()

startyourengine
13th June 2012, 20:41
hi wysota
takeItem() returns a QStandardItem, does it retain all the children? also insertRow() needs a QList<QStandardItem*> as the second argument. how do I fit the Item in there?

wysota
13th June 2012, 20:57
takeItem() returns a QStandardItem, does it retain all the children?
Why don't you just try and see for yourself?


also insertRow() needs a QList<QStandardItem*> as the second argument. how do I fit the Item in there?
There are three variants of this method.

startyourengine
14th June 2012, 23:33
ah, it worked. Thanks a bunch!