Hello there.

I have a QTreeView and am using a QStandardItemModel to fill that tree view. I allready have a constructed read/write list of data but would need to implement adding children to particular items as well.
I tried a few ways, but just can't get it.

This is how I'm adding items:
Qt Code:
  1.  
  2. model->insertRow(itemCount, QModelIndex());
  3. pI = model->index(itemCount,0,QModelIndex());
  4. model->setData( pI, title, Qt::DisplayRole);
  5. model->item(itemCount, 0)->setEditable( false );
To copy to clipboard, switch view to plain text mode 

model is a QStandardItemModel pointer and title is a QString variable.

And this is how I tried to add a child to only one item:
Qt Code:
  1.  
  2. model->insertRow(1, QModelIndex());
  3. cI = model->index(1, 0, QModelIndex());
  4. model->setData( cI, "test", Qt::DisplayRole);
  5. model->item(1, 0)->setChild(0, 1, model->item(5,0));
To copy to clipboard, switch view to plain text mode 
The list is filled with data and then this piece of code get's executed.
But what happens is that another item is added("test") and an empty child is assigned to it. But I would like to assign this "test" to an existing item on second row in the list.

I did read the docs up and down but can't figure it out.