[Solved]Custom TableModel and redraw View data
-
Hi everyone!
I have some raw data, and CustomTableModel which build table from it. Data frequently updated from remote source. Model knows it, and should send some signal to a view for redraw all data. I expect from my model, QSqlTableModel like behavior. Emitting dataChanged() signal has no effect, calling beginInser() and endInsert methods too. Only setModel for a view works for now. I look at QSqlTableModel code but cant figure out how model send update signal to view. Can you tell me please what is right solution of this issue.Thank you!
-
Let me close my own question.
When you add new rows to the model use:
@beginInsertRows();
//Adding new rows
endInsertRows();@
when you remove rows:
@beginRemoveRows();
//Removing rows
endRemoveRows();@
in your case when you reload all data you can use:
@beginResetModel();
//Removing rows
endResetModel();@
Emitting dataChanged() useful if you change value of already existing item