Can't make child in Qtreeview using QStandardItemModel

  • Hi
    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 :
    @QStandardItemModel m_model = new QStandardItemModel(0,4,parent);
    then setSourceModel(m_model) for the widget
    set the treeview with QSortFilterProxyModel. something like this :
    GroupProxyModel = new GroupSortFilterProxyModel;


    then later i fill the first row like this :

    @QList<QStandardItem *> items;
    items.insert(0,new QStandardItem("Test 0"));>setEditable(false);

    until now every thing working fine and i see the row with the data . but when i like to
    add child to the row like this :

    @QModelIndex parentQModelIndex = m_model->item(0,0)->index();
    QModelIndex indexB = m_model->index(0, 0, parentQModelIndex);
    m_model->setData(indexB,"Child test",Qt::DisplayRole);

    but i dont see the child , why ?

  • Try to use QStandardItemModel directly with your QTreeView. If you can see the "child" then the problem is with your GroupSortFilterProxyModel which in your case is located between QTreeView and QStandardItemModel.

Log in to reply