I have tried to populate the model in the models constructor
{
MyModel model;
m_Private->rootItem = model.invisibleRootItem();
for(int i =0; i < model.rowCount(); ++i)
{
for(int j = 0; j < model.columnCount(); ++j)
{
if(MyModel::MANUFACTURER == model.index(i, j).column())
{
QString manufacturetStr
= model.
index(i,DevicesModel
::MANUFACTURER).
data().
toString();
QString typeStr
= model.
index(i,DevicesModel
::TYPE).
data().
toString();
QString bandStr
= model.
index(i,DevicesModel
::BAND).
data().
toString();
m_rootItem->appendRow(typeItem );
m_rootItem = typeItem ;
m_rootItem->appendRow(bandItem);
m_rootItem = bandItem;
}
this->setData(index(i, j), manufacturerItem);
}
}
}
{
MyModel model;
m_Private->rootItem = model.invisibleRootItem();
for(int i =0; i < model.rowCount(); ++i)
{
for(int j = 0; j < model.columnCount(); ++j)
{
if(MyModel::MANUFACTURER == model.index(i, j).column())
{
QString manufacturetStr = model.index(i,DevicesModel::MANUFACTURER).data().toString();
QString typeStr = model.index(i,DevicesModel::TYPE).data().toString();
QString bandStr = model.index(i,DevicesModel::BAND).data().toString();
QStandardItem *manufacturerItem = new QStandardItem(manufacturetStr);
QStandardItem *typeItem = new QStandardItem(typelStr);
QStandardItem *bandItem = new QStandardItem(bandStr);
m_rootItem->appendRow(typeItem );
m_rootItem = typeItem ;
m_rootItem->appendRow(bandItem);
m_rootItem = bandItem;
}
this->setData(index(i, j), manufacturerItem);
}
}
}
To copy to clipboard, switch view to plain text mode
I am having problem with inserting data into the model and how do i implement rowCount() and columnCount() functions
Bookmarks