Save the structure as a model in a file
I can Save the structure as a model in a file, treeview model.
Code:
for (int i = 0; i < 4; ++i) {
parentItem->appendRow(item);
parentItem = item;
}
QFile file("catalogo/catalogo.cat");
saveModel(&file, CatalogoModel); //code crash
//if(file.open(QIODevice::ReadOnly))
//loadModel(&file, CatalogoModel);
}
//*******************************************************************
int rowCount, columnCount;
stream >> rowCount;
stream >> columnCount;
for(int row = 0; row < rowCount; row++)
for(int column = 0; column < columnCount; column++) {
stream >> item;
model->setItem(row, column, w_item);
}
}
//****************************************************************************
int rowCount = model->rowCount();
int columnCount = model->columnCount();
stream << rowCount;
stream << columnCount;
for(int row = 0; row < rowCount; row++)
for(int column = 0; column < columnCount; column++) {
stream << model->item(row, column)->text();
}
}
Re: Save the structure as a model in a file
Quote:
Originally Posted by
valgaba
I can Save the structure as a model in a file, treeview model.
Good for you!
Re: Save the structure as a model in a file
I think the announcement and congratulations are premature judging by the comment on line 16.
Have you single-stepped the routine to see where it "crashes"?
Are you handling the tree structure correctly in your save routine?
Re: Save the structure as a model in a file
The problem is that it keeps all the engine functions, is there any way to keep all the engine functions?, Just save the parent object did any solution to this problem?
Thanks