then setSourceModel(m_model) for the widget
GroupProxyModel = new GroupSortFilterProxyModel;
GroupProxyModel->setDynamicSortFilter(true);
setSourceModel(createSubjectModel(parent));
ui.treeView_mainwindow->setModel(GroupProxyModel);
ui.treeView_mainwindow->setSortingEnabled(true);
then later i fill the first row like this :
QList<QStandardItem *> items;
items.at(0)->setEditable(false);
m_model->insertRow(0,items);
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
();
m_model->insertRows(0,1,parentQModelIndex);
m_model->insertColumns(0,1,parentQModelIndex);
QModelIndex indexB
= m_model
->index
(0,
0, parentQModelIndex
);
m_model->setData(indexB,"Child test",Qt::DisplayRole);
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;
GroupProxyModel->setDynamicSortFilter(true);
setSourceModel(createSubjectModel(parent));
ui.treeView_mainwindow->setModel(GroupProxyModel);
ui.treeView_mainwindow->setSortingEnabled(true);
then later i fill the first row like this :
QList<QStandardItem *> items;
items.insert(0,new QStandardItem("Test 0"));
items.at(0)->setEditable(false);
m_model->insertRow(0,items);
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();
m_model->insertRows(0,1,parentQModelIndex);
m_model->insertColumns(0,1,parentQModelIndex);
QModelIndex indexB = m_model->index(0, 0, parentQModelIndex);
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 ?
Bookmarks