
Originally Posted by
awhite1159
I removed the beginInsertRows() and endInsertRows. I replaced it with an 'emit layoutChanged()' and now it seems to work. Is thier any downside to doing it this way?
Yes, the whole model needs to be reread by the view.
would it be best to put a generic or blank record in and then go back with a setData() or just put the valid data in immediately? I'll be using a dialog to enter the new row.
Put the valid data immediately, for instance like this:
void myModel::appendNewRow(.... someData){
beginInsertRows
(QModelIndex(), rowCount
(), rowCount
());
MyStruct struct = someData;
m_list << struct; // m_list is the container the model operates on
endInsertRows();
}
void myModel::appendNewRow(.... someData){
beginInsertRows(QModelIndex(), rowCount(), rowCount());
MyStruct struct = someData;
m_list << struct; // m_list is the container the model operates on
endInsertRows();
}
To copy to clipboard, switch view to plain text mode
Bookmarks