after reading some examples i still missing here something . i have Qtreeview for view and QStandardItemModel for the data interface , also using QSortFilterProxyModel subclass but i dont know if its relevant. this is my logic :
first i create the model with the QWidget as the parent :
Qt Code:
  1. QStandardItemModel m_model = new QStandardItemModel(0,4,parent);
  2. then setSourceModel(m_model) for the widget
  3. set the treeview with QSortFilterProxyModel. something like this :
  4. GroupProxyModel = new GroupSortFilterProxyModel;
  5. GroupProxyModel->setDynamicSortFilter(true);
  6. setSourceModel(createSubjectModel(parent));
  7.  
  8. ui.treeView_mainwindow->setModel(GroupProxyModel);
  9. ui.treeView_mainwindow->setSortingEnabled(true);
  10. then later i fill the first row like this :
  11.  
  12. QList<QStandardItem *> items;
  13. items.insert(0,new QStandardItem("Test 0"));
  14. items.at(0)->setEditable(false);
  15. m_model->insertRow(0,items);
  16. until now every thing working fine and i see the row with the data . but when i like to
  17. add child to the row like this :
  18.  
  19. QModelIndex parentQModelIndex = m_model->item(0,0)->index();
  20. m_model->insertRows(0,1,parentQModelIndex);
  21. m_model->insertColumns(0,1,parentQModelIndex);
  22. QModelIndex indexB = m_model->index(0, 0, parentQModelIndex);
  23. m_model->setData(indexB,"Child test",Qt::DisplayRole);
To copy to clipboard, switch view to plain text mode 
but i dont see the child , why ?