
Originally Posted by
tomeks
Are you talking about QAbstractItemModel::rowsInserted(), QAbstractItemModel::rowsRemoved() and QAbstractItemModel::dataChanged() signals?
er, I think the pairs begininsetrows() ,endinsetrows() and beginRemoveRows(), end removerows() are proper functions you should call to insert/remove data. Their implementation emit the proper signals. dataChanged() is mostly used in setData().
Should i really emit these signals, even if i don't change data directly in model? Model contains only pointer to data, which is changed in other dialog. All changed data appears on the view, only number of rows is constant.
I guess you try to avoid let the model become a editable model to make things easier.But the way you choose is not efficent esp when your data is large. Becasue reset() really tell the view to do much more things than you need. I suggest you implement
int role = Qt::EditRole);
Qt::ItemFlags flags(const QModelIndex &index) const;
bool setData(const QModelIndex &index, const QVariant &value,
int role = Qt::EditRole);
bool insertRows(int position, int rows, const QModelIndex &index = QModelIndex());
bool removeRows(int position, int rows, const QModelIndex &index = QModelIndex());
To copy to clipboard, switch view to plain text mode
to achieve your goal. They allow you to edit your model flexiblely.
Bookmarks